phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 241 forks source link

static unknown class #532

Closed that-guy-iain closed 3 years ago

that-guy-iain commented 3 years ago

I made the following change

-    public static function createForUser(UserInterface $user, string $email): self
+    public static function createForUser(UserInterface $user, string $email): static

And I got

Fatal error: '\static' is an invalid class name in /opt/atlassian/pipelines/agent/build/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code on line 58

I would expect it to treat static roughly the same way it treats self.

ciaranmcnulty commented 3 years ago

It looks like we're prefixing static with a \, which is what we do for classes.

I think this should be added as an exception like we do for void here https://github.com/phpspec/prophecy/blob/master/src/Prophecy/Doubler/Generator/Node/ReturnTypeNode.php#L11

dpi commented 3 years ago

Looks like this may be a dupe of #527

that-guy-iain commented 3 years ago

Yep. I'll close