-
Notifications
You must be signed in to change notification settings - Fork 78
PHP 7.1 support #87
PHP 7.1 support #87
Conversation
@weierophinney can we drop PHP 5 at some point? |
[NullableHintsClass::class, 'callableParameter', 'foo', '?callable'], | ||
[NullableHintsClass::class, 'intParameter', 'foo', '?int'], | ||
[NullableHintsClass::class, 'floatParameter', 'foo', '?float'], | ||
// [NullableHintsClass::class, 'stringParameter', 'foo', '?string'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, but not yet. 5.6 is still supported. Once that goes off active support, we can do a new minor version that bumps minimum to a v7 release. |
I'll start ticking off the days. |
Please don't drop the PHP 5.6 support too early. There are a lot of projects out there which won't be merged to PHP 7.x so quickly. I would favour a new major release rather than a new minor release. Should be 4.x then to drop PHP 5.6 support. People tend to configure their
and not like this:
Jm2c |
@RalfEggert this targets 4.0 |
Great! then I misunderstood Matthews comment... |
What about support for these things in the Scanner classes? |
@djmattyg007 didn't check them at all, sorry. |
So is it safe to say at this point that the Scanner classes are no longer maintained? |
No, i simply didn't t look at them, nor will do so in this PR. You can work on them basing your work on the test assets in this PR, if you want. |
[NullNullableDefaultHintsClass::class, 'callableParameter', 'foo', '?callable'], | ||
[NullNullableDefaultHintsClass::class, 'intParameter', 'foo', '?int'], | ||
[NullNullableDefaultHintsClass::class, 'floatParameter', 'foo', '?float'], | ||
// [NullNullableDefaultHintsClass::class, 'stringParameter', 'foo', '?string'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - to be tried again with 7.1-beta
Are you still seeing the "allowed memory size" issue on the RC1 build? |
I think that this is ready for review/merge. Works on 5.6, 7.0, 7.1. Dropped |
You mean you dropped 5.5. Which is perfectly acceptable for the next minor release. 😄 |
Yep, typo, sorry :-) |
@nikic that's gone, thanks! :-) |
* @var string[] | ||
* | ||
* @link http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration | ||
*/ | ||
private static $internalPhpTypes = ['int', 'float', 'string', 'bool', 'array', 'callable']; | ||
private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about iterable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, that passed? :O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, to be added (as separate test asset, since iterable
can be a class/interface in 5.6 and 7.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely want iterable
as part of the final changes. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane! The primary concerns I have are noted in other review comments, but include:
- Should
static
and/or$this
be considered for type hint generation if generating types from docblocks? - License docblocks in test assets.
- Adding support for the
iterable
type.
Thanks, @Ocramius !
- php: 5.6 | ||
env: | ||
- EXECUTE_CS_CHECK=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this into the PHP 7 target, so that we can get results earlier, please. (That's what we've done in other components as well.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just verified: can't do, since the lock file was generated with 5.x deps
* | ||
* @return string | ||
*/ | ||
private static function expandLiteralType($literalReturnType, ReflectionMethod $methodReflection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading this correctly in that it pulls the type from reflecting the docblock in this case? If so, should it also consider static
and $this
? (If it's strictly from declared return type, ignore.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, should it also consider static and $this? (If it's strictly from declared return type, ignore.)
static
is not a valid type hint (for good reasons). static
is used when resolving methods to call inside an instance, but it is not possible to use it as a hint due to its natural non-LSP-compliance.
$this
is not a type
In general, reflecting from docblocks is now a deprecated feature (there are explicit tests that verify that docblocks aren't used for reflecting anymore)
* | ||
* @return string | ||
*/ | ||
private static function expandLiteralParameterType($literalParameterType, ReflectionParameter $reflectionParameter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as with MethodGenerator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as with MethodGenerator
[ClassTypeHintedClass::class, 'classParameter', 'foo', '\\' . ClassTypeHintedClass::class], | ||
[ClassTypeHintedClass::class, 'otherClassParameter', 'foo', '\\' . InternalHintsClass::class], | ||
[ClassTypeHintedClass::class, 'closureParameter', 'foo', '\\' . \Closure::class], | ||
[ClassTypeHintedClass::class, 'importedClosureParameter', 'foo', '\\' . \Closure::class], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiousity... why are the Null*
cases prior to the others, which are all in alpha order by class name otherwise? (I ask, because I thought at first you'd removed the ClassTypeHintedClass
cases until I discovered they'd been shifted down...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the assets in the order in which I copied them and adapted them. That's why they don't appear at the end of the list
@@ -0,0 +1,38 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EmptyClass
includes the license docblock, but this and those following do not; should they? or are they used for comparison purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docblocks are not important here, and may actually confuse the reader of the assets, so maybe I should remove it from EmptyClass
as well.
@weierophinney implemented |
b0617d6
to
46baca8
Compare
@weierophinney this is ready for merge |
…parent class hint
… confusing the reader)
…ould be rendered by `TypeGenerator`
…cial" in parameter generation code
…cial" in return type generation code
f23f389
to
c682384
Compare
review completed - discussed directly on IRC with @weierophinney
Merging. The failure is caused by a CS check that is fixed in |
This PR introduces initial support for PHP 7.1 nullable (
?
syntax) return and parameter hints, as well asvoid
return hint.Implements #84
Implements #85