Introduce PHP7.2 object type hint#112
Conversation
| */ | ||
| private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable', 'iterable']; | ||
| private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable', 'iterable', | ||
| 'object']; |
There was a problem hiding this comment.
What's the right alignment here ? I try to find a "too" long array property but can't find one in the project...
Is this ok?
private static $internalPhpTypes = [
'void',
'int',
'float',
'string',
'bool',
'array',
'callable',
'iterable',
'object'
];
| || ( | ||
| false === strpos($parameter[2], '?') | ||
| && ! in_array(strtolower($parameter[2]), ['void', 'iterable']) | ||
| && ! in_array(strtolower($parameter[2]), ['void', 'iterable', 'object']) |
There was a problem hiding this comment.
Careful about the php version comparison: should be 70200
| $compatibleParameters = array_filter( | ||
| $parameters, | ||
| function (array $parameter) { | ||
| return PHP_VERSION_ID >= 70100 |
There was a problem hiding this comment.
Same as above: different conditionals for 70200
| [IterableHintsClass::class, 'iterableParameter', 'foo', 'iterable'], | ||
| [IterableHintsClass::class, 'nullableIterableParameter', 'foo', '?iterable'], | ||
| [IterableHintsClass::class, 'nullDefaultIterableParameter', 'foo', '?iterable'], | ||
| [ObjectHintsClass::class, 'objectParameter', 'foo', 'object'], |
There was a problem hiding this comment.
These should only be added to the data providrr if the php version is 70200 or greater
| [NullableReturnTypeHintedClass::class, 'otherClassReturn', '?\\' . InternalHintsClass::class], | ||
| [IterableHintsClass::class, 'iterableReturnValue', 'iterable'], | ||
| [IterableHintsClass::class, 'nullableIterableReturnValue', '?iterable'], | ||
| [ObjectHintsClass::class, 'objectReturnValue', 'object'], |
There was a problem hiding this comment.
These should only be added to the data providrr if the php version is 70200 or greater
There was a problem hiding this comment.
I've updated the tests regarding PHP version.
|
Yup
…On 3 Jul 2017 13:04, "Stéphane HULARD" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/Generator/TypeGenerator.php
<#112 (comment)>
:
> @@ -33,7 +33,8 @@
*
* @link http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
*/
- private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable', 'iterable'];
+ private static $internalPhpTypes = ['void', 'int', 'float', 'string', 'bool', 'array', 'callable', 'iterable',
+ 'object'];
What's the right alignment here ? I try to find a "too" long array
property but can't find one in the project...
Is this ok?
private static $internalPhpTypes = [
'void',
'int',
'float',
'string',
'bool',
'array',
'callable',
'iterable',
'object'
];
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakOMzTKQhdY0auFDbefLE21Kdylqlks5sKMqsgaJpZM4OMGre>
.
|
fb4277e to
b95a4e4
Compare
|
Couple things here:
|
Allow the TypeGenerator to recognize this new PHP7.2 internal type. # Conflicts: # src/Generator/TypeGenerator.php
b95a4e4 to
754faf1
Compare
|
Hello, I've updated the target branch and rebased on the |
| || ( | ||
| false === strpos($parameter[2], 'object') | ||
| )) | ||
| && (PHP_VERSION_ID >= 70100 |
There was a problem hiding this comment.
We don't need this part of condition, as now develop supports only PHP 7.1+
| || ( | ||
| false === strpos($parameter[3], 'object') | ||
| )) | ||
| && (PHP_VERSION_ID >= 70100 |
|
@Ocramius tests still are failing ! |
|
Hmm, can you check up on the test failures? |
754faf1 to
c7b1922
Compare
|
I've just removed the PHP 7.1 conditions in the tests... |
michalbundyra
left a comment
There was a problem hiding this comment.
@shulard Please see my comments.
| [ObjectHintsClass::class, 'nullDefaultObjectParameter', 'foo', '?object'], | ||
| ]; | ||
|
|
||
| $compatibleParameters = array_filter( |
There was a problem hiding this comment.
You have to use this variable in line 487 and 489.
| $compatibleParameters = array_filter( | ||
| $parameters, | ||
| function (array $parameter) { | ||
|
|
There was a problem hiding this comment.
Please remove empty line above.
| ['\\ITERABLE'], | ||
| ['\\object'], | ||
| ['\\Object'], | ||
| ['\\OBJECT'], |
There was a problem hiding this comment.
Here you added these to invalidTypeProvider, don't we need remove 'object' from validTypeProvider?
c7b1922 to
a8acf4e
Compare
Introduce a new TestAsset\ObjectHintsClass as a sample to be used in test. Also update generator tests to check for object type.
a8acf4e to
b959211
Compare
|
Hello @webimpress, I've updated the code with your comments and fixed the test suite. I've made a mistake in the "validTypeProvider" method... |
michalbundyra
left a comment
There was a problem hiding this comment.
LGTM 👍 And all green now. Thanks @shulard !
|
🚢 |
Hello,
This PR is about introducing the PHP7.2
objecttype hint recently merged in the PHP core as requested in #110.