Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix that style objects cannot be passed to element constructors #2685

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hazington
Copy link
Contributor

@hazington hazington commented Sep 22, 2024

Description

I generally prefer to use style objects over style arrays in elements. But, if you pass a \PhpOffice\PhpWord\Style\Cell style element to the \PhpOffice\PhpWord\Element\Cell constructor then the $returnObject: true argument of the setNewStyle() method in the constructor completely ignores the passed style element, because the setNewStyle() method only checks if $styleValue is an array and returns $styleObject as empty style object otherwise. Imho, if $styleValue is a style object with the same type as $styleObject then the $returnObject: true should also be "ignored" and the passed style object should then be returned instead of the empty base style object.

Fixes # (issue)

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes (not applicable, bugfix did not change the behavior)
  • I have updated the changelog

…NewStyle() method could not return style objects as value arguments, when $returnObject is true, like in the Cell element.
@hazington hazington changed the title Ensured that mt_rand() is passed as string to md5. Fixed that the set… Fix that style objects cannot be passed to elements Sep 22, 2024
@coveralls
Copy link

coveralls commented Sep 22, 2024

Coverage Status

coverage: 96.918%. remained the same
when pulling 15e69a6 on hazington:patch-abstract-element
into 43785fe on PHPOffice:master.

@hazington
Copy link
Contributor Author

It took me a while to find the cause of the phpstan errors. Never imagined that there would be such a long list of ignored errors.

@hazington hazington changed the title Fix that style objects cannot be passed to elements Fix that style objects cannot be passed to element constructors Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants