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'], |
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.
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! :-) |
| * | ||
| * @link http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration | ||
| */ | ||
| private static $internalPhpTypes = ['int', 'float', 'string', 'bool', 'array', 'callable']; |
There was a problem hiding this comment.
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.
Definitely want iterable as part of the final changes. 😄
weierophinney
left a comment
There was a problem hiding this comment.
Looks sane! The primary concerns I have are noted in other review comments, but include:
- Should
staticand/or$thisbe considered for type hint generation if generating types from docblocks? - License docblocks in test assets.
- Adding support for the
iterabletype.
Thanks, @Ocramius !
.travis.yml
Outdated
| - EXECUTE_CS_CHECK=true | ||
| - php: 5.6 | ||
| env: | ||
| - EXECUTE_CS_CHECK=true |
There was a problem hiding this comment.
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.
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.
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.
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)
| * @param ReflectionParameter $reflectionParameter | ||
| * | ||
| * @return string | ||
| */ |
There was a problem hiding this comment.
Same comment as with MethodGenerator.
There was a problem hiding this comment.
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.
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.
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.
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.
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 asvoidreturn hint.Implements #84
Implements #85