Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

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

@kaurov

Description

@kaurov
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions