Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Config] Fix for signatures of typed properties#32466
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas left a comment
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.
(for 3.4)
derrabus commentedJul 9, 2019
Can we please add a test? And yes, I know that that test would be skipped in our current CI setup, but still… 😅 |
tvandervorm commentedJul 10, 2019
I'd be happy to write a testcase for this issue, but it's not clear to me how I could do this without breaking the test for PHP < 7.4 . The most straightforward way would be to add a line to |
xabbuh commentedJul 10, 2019
Adding a new test case annotation with |
tvandervorm commentedJul 10, 2019
ah, I wasn't aware one could specify PHP versions in annotations like that, will give it a go, thanks |
tvandervorm commentedJul 14, 2019
I added a little testcase, which I tested with both PHP7.2 & PHP 7.4. It gets skipped in the first case, passes in the second case and fails in the second case if I revert my change, so it does what it should do. Now, I've always been taught that dependencies between tests should be avoided, which I failed to do here. However, the alternative would be to copy/paste the content of Finally, I tried whether the |
| publicfunctionprovideTypedProperties() | ||
| { | ||
| yield [1,5,'public array $pub;']; |
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 if we updated theprovideHashedSignature() method instead and yield these three examples only ifPHP_VERSION_ID >= 70400 istrue?
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.
that works as well, and is a little cleaner indeed, I've updated the test.
5d528cf to611bce2Comparefabpot commentedJul 15, 2019
Thank you@tvandervorm. |
This PR was submitted for the 4.3 branch but it was squashed and merged into the 3.4 branch instead (closes#32466).Discussion----------[Config] Fix for signatures of typed properties| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#32465| License | MIT| Doc PR | -Also see the issue description, when using public typed properties ([new in PHP7.4](https://wiki.php.net/rfc/typed_properties_v2)) like this:```namespace App;class Foo { public int $bar;}```will cause `$defaults['bar']` not to be set in Symfony/Component/Config/Resource/ReflectionClassResource.php::139.This is because `$bar` doesn't have a default value, but does have a type hint, meaning it's default value is not `null` but undefined. This causes an 'undefined index' error when clearing the cache through `bin/console cache:clear` when running PHP7.4.The default value is used here for the class signature, having `null` should be appropriate for all cases.Commits-------bad2a2c [Config] Fix for signatures of typed properties
Uh oh!
There was an error while loading.Please reload this page.
Also see the issue description, when using public typed properties (new in PHP7.4) like this:
will cause
$defaults['bar']not to be set in Symfony/Component/Config/Resource/ReflectionClassResource.php::139.This is because
$bardoesn't have a default value, but does have a type hint, meaning it's default value is notnullbut undefined. This causes an 'undefined index' error when clearing the cache throughbin/console cache:clearwhen running PHP7.4.The default value is used here for the class signature, having
nullshould be appropriate for all cases.