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

PHP Fatal error: Uncaught Error: Object of class PhpParser\Node\UnionType could not be converted to string in /vendor/php-censor/phpdoc-checker/src/FileProcessor.php:173 #49

Open
kaurov opened this issue Nov 24, 2022 · 0 comments

Comments

@kaurov
Copy link

kaurov commented Nov 24, 2022

PHPDOCCHECK 
PHPDoc Checker
PHP Fatal error:  Uncaught Error: Object of class PhpParser\Node\UnionType could not be converted to string in /vendor/php-censor/phpdoc-checker/src/FileProcessor.php:173

was caused by:
public function getInstance(Class1|Class2 $item = null): self

and temporarily fixed by

  • either removal of null:
    public function getInstance(Class1|Class2 $item): self

  • either adding the null to types:
    public function factoryMethod(Class1|Class2|null $item = null): self

Acceptance Criteria:
PHPDoc Checker can read functions with union typed properties without the causing PHP error and output readable notice about deveoper's error. Something like:
Please add |null to $item in getInstance() to be able to set the value = null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant