We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
static
PHP 8.0 introduced the static return type.
When using Mockery to mock a method with a return type hint of static, PHP generates a ParseError, with a message similar to the following:
ParseError
ParseError : syntax error, unexpected token "static", expecting identifier /private/var/folders/jt/dm973jds5b33ffvl0x2b8f940000gn/T/MockeryYyJCuE:1
The generated file contains the following:
<?php class static {}
#1149 describes a similar issue with the mixed return type.
mixed
💡 NOTE: To help, I've created a repository so you can quickly reproduce the issue: https://github.com/ramsey/mockery-static-return-type-bug
Create a class with a method on it that has a static return type hint:
<?php namespace Foo; class Foo { public function setFoo(string $value): static { return $this; } }
Create a PHPUnit test that attempts to create a Mockery mock of the class and method:
<?php namespace Foo\Tests; use Foo\Foo; use Mockery; use PHPUnit\Framework\TestCase; class FooTest extends TestCase { public function testFoo(): void { $fooMock = Mockery::mock(Foo::class); $fooMock->allows('setFoo'); $fooMock->setFoo('some value'); $this->assertTrue(true); } }
Run the test on PHP 8.0 or 8.1.
The text was updated successfully, but these errors were encountered:
Resolved via #1157.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
PHP 8.0 introduced the
static
return type.When using Mockery to mock a method with a return type hint of
static
, PHP generates aParseError
, with a message similar to the following:The generated file contains the following:
#1149 describes a similar issue with the
mixed
return type.To Reproduce
💡 NOTE: To help, I've created a repository so you can quickly reproduce the issue: https://github.com/ramsey/mockery-static-return-type-bug
Create a class with a method on it that has a
static
return type hint:Create a PHPUnit test that attempts to create a Mockery mock of the class and method:
Run the test on PHP 8.0 or 8.1.
The text was updated successfully, but these errors were encountered: