Skip to content

Error with PHP8 and __toString for Symfony project when use DoctrineBehaviors translation on entities #5497

@RomulusED69

Description

@RomulusED69

Bug report

Hi ✋,

I have a Symfony project with https://github.com/KnpLabs/DoctrineBehaviors.
I tried to update project to PHP8 but I'm having problem with phpstan.

Bundle created its own extensions https://github.com/KnpLabs/DoctrineBehaviors/tree/master/utils/phpstan-behaviors/src/Type

No problem with PHP7.4 but with PHP8:
Sélection_152
Sélection_153

After investigations, problem occurs only when method __toString is defined.
Problem appears on invoke here https://github.com/KnpLabs/DoctrineBehaviors/blob/master/utils/phpstan-behaviors/src/Type/TranslationTypeHelper.php#L36

Code snippet that reproduces the problem

https://github.com/RomulusED69/phpstan-knp-doctrine-behaviors-bug

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions