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

Php73 compatibility #38

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

igorbga
Copy link

@igorbga igorbga commented Jan 9, 2020

Fixes compatibility issues with new syntax introduced in PHP 7.0 and 7.3
It does so by maintaining backwards compatibilidy with PHP 5.

When available uses ReflectionType in order to allow the use of nullable parameters. If it is not available that means that we are using PHP prior to 7 so no nullable parameters should exists.
ReflectionType does not allow to distinguish parameter "int $a=null" from "?int $a=null" but in fact they are equivalent and compatible signatures so in this case we prefer "int $a=null" to maintain compatibility with PHP 7.0.

The return values are always set using ReflectionType so it supports also built-in type "void" that was introduced in PHP 7.3 . Of course apart from using ReflectionType InterceptionGeneration was slightly modified to achieve this. Heavily inspired by SymfonyRotEbal@7bcc767

A new test was added to check the generation of method with ": void"

Fixes #35

Using the ReflectionType instead of the custom BuiltinType class makes
sure that future builtin types will be supported and also solves the
current issue related to the fact that "void" is not a builtin type in
PHP prior to 7.3.
We also had to make some small changes for the use of the special return
or parameter value "self".
The generator always included a return but when void is used as return
value no return is allowed.
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

Successfully merging this pull request may close these issues.

return void cases
1 participant