Closed pavelkouril closed 9 years ago
One special case is probably missing, returning/typehinting self
(PHP does not dereference it automatically).
Thanks for pointing out the self
dereferencing, I totally forgot about that. :)
EDIT: It seems the "self" and "parent" types are already available in 5.x. Should it even be in the scope of this PR (since this one is about adding PHP7 features) or done in a separate one?
One more thing up for discussion - should setting the return type via setter (or converting to string) be limited by PHP version? In the DI use case, I did the check it on caller's side, but maybe it should be solved here instead?
(I didn't solve it here initially because I wanted to be consistent with variadics implementation, which don't check for PHP version in setters and __toString
too.)
No, it should generate code for PHP 7 even in PHP 5.
Can you squash it to single commit?
Just squashed commits for the first time. I hope I did it correctly! :)
What about commit message added support for PHP 7 type hints
?
It's not just typehints, but also the return type declarations - so what about added support for PHP 7 type hints and return types
or Method, Parameter: added support for PHP 7 type hints and return type declarations
(it seems that you usually use the classes names that were affected by change in the commit message)?
OK.
(return type hint is subset of type hint)
Great, thanks!
This PR adds support for new PHP7 language syntax & features, namely return type declarations and scalar type hints for generated files.
This feature is mandatory for PHP7 support in nette/di - ie. support of using return type declaration (instead of annotations) in automatically generated factories.