Skip to content
New issue

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

Full PHP 8.0 Support #1083

Open
6 of 8 tasks
GrahamCampbell opened this issue Jul 9, 2020 · 7 comments
Open
6 of 8 tasks

Full PHP 8.0 Support #1083

GrahamCampbell opened this issue Jul 9, 2020 · 7 comments

Comments

@GrahamCampbell
Copy link
Contributor

GrahamCampbell commented Jul 9, 2020

PHP 8.0 has not stopped making changes yet, but when they do, we can assess the full situation.

Current PHP 8.0 state:

  • Support for all PHP 7.4 syntax on PHP 8.0 (done as of 1.3.2 and 1.4.1)
  • Support for union types without null (done as of 1.3.2 and 1.4.1)
  • Support for mixed/union types with null (currently broken*) [[1.3] Improved PHP 8.0 support #1088]
  • What to do with Mockery\Generator\Parameter::getClass() (do we deprecate this function**) [[1.3] Improved PHP 8.0 support #1088]
  • Support for the static return type hint (I was aware of this before, but possible solutions need to be discussed)
  • Support for the parent param and return type [[1.3] Improved PHP 8.0 support #1088]
  • Support for other language features (have we missed anything, is there more to come before the 8.0.0RC releases?)
  • Add tests covering all the new PHP 8.0 syntax (which would have caught the union nullable issue) [[1.3] Improved PHP 8.0 support #1088]

* I just discovered this an hour ago - no big deal though - as long as it's fixed by November.
** I don't think this is used anywhere? In my last PR, I updated that function so it basically returns null for union typed cases.

@remicollet
Copy link
Contributor

Notice, test suite is failing with 8.0.0RC1

PHP Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /dev/shm/BUILDROOT/php-mockery-1.4.2-1.fc31.remi.x86_64/usr/share/php/Mockery1/Loader/EvalLoader.php(34) : eval()'d code on line 21

This may looks like a regression, reported as https://bugs.php.net/bug.php?id=80225

a quick fix could be

-        eval("?>" . $definition->getCode());
+        eval(substr($definition->getCode(), 5));

Probably worth waiting for some inputs on this upstream issue

@GrahamCampbell
Copy link
Contributor Author

Thanks for letting us know @remicollet. :)

@remicollet
Copy link
Contributor

This in 8.0.0RC2 ;)

@GrahamCampbell
Copy link
Contributor Author

Fix commit: php/php-src@f9b7609.

@raveren
Copy link

raveren commented Jun 2, 2021

whooo an hour wasted debugging

ParseError : syntax error, unexpected token "static", expecting identifier
 /private/var/folders/4r/nyfsnst15kz019tl_4xmfml80000gn/T/MockeryYx5sWT:1

Turns out Mockery does not support static return type on methods.

Hear that, google? Mockery does not support static return type!

Anyway, I think the fix can be implemented in method \Mockery\Mock::mockery_returnValueForMethod where the $returnType value is "static" you can reproduce this issue by:

https://gist.github.com/raveren/05005bbbaf22ce8528e436d89b855221

@tezhm
Copy link

tezhm commented Aug 12, 2021

Any status on static return type support?

@LastDragon-ru
Copy link
Contributor

@raveren probably this will work

$mock->expects('myMethod')->once()->andReturnSelf();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants