You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any @param class-string/@return class-string contract fed $anonymous::class throws:
TypeError: Registry::addService(): Argument $handlerClass must be of type class-string,
string 'App\Fixtures\EchoService@anonymous...' given
Cause. PHP mangles the name to Parent@anonymous\0/path/to/file.php:12$3. The identifier
regexes reject @, the NUL byte and the path:
src/Internal/ClassNameValidator.php:28
src/Validator/IdentifierValidator.php:54
Impact. Anonymous classes are the idiomatic test double in PHPUnit suites. Every one whose ::class crosses a class-string boundary fails, and the only workarounds are to weaken the
contract or @typephp-ignore the method.
Suggested fix. Accept a name whose prefix up to @anonymous is a valid identifier, or defer to class_exists() when the name contains @anonymous.
Activity
rcalicdan commentedon Aug 24, 2026
@FluffyDiscord Thank you for the issue, already fix at #49