Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:3.4fromtvandervorm:4.3
Jul 15, 2019

Conversation

@tvandervorm
Copy link
Contributor

@tvandervormtvandervorm commentedJul 9, 2019
edited
Loading

QA
Branch?4.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#32465
LicenseMIT
Doc PR-

Also see the issue description, when using public typed properties (new in PHP7.4) 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 notnull but undefined. This causes an 'undefined index' error when clearing the cache throughbin/console cache:clear when running PHP7.4.

The default value is used here for the class signature, havingnull should be appropriate for all cases.

derrabus reacted with thumbs up emojiderrabus reacted with hooray emoji
@tvandervormtvandervorm changed the titleFix for signatures of public typed properties (new in PHP7.4)[Cache] Fix for signatures of public typed properties (new in PHP7.4)Jul 9, 2019
Copy link
Member

@nicolas-grekasnicolas-grekas left a 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
Copy link
Member

Can we please add a test? And yes, I know that that test would be skipped in our current CI setup, but still… 😅

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneJul 10, 2019
@nicolas-grekasnicolas-grekas changed the title[Cache] Fix for signatures of public typed properties (new in PHP7.4)[Config] Fix for signatures of typed propertiesJul 10, 2019
@tvandervorm
Copy link
ContributorAuthor

Can we please add a test? And yes, I know that that test would be skipped in our current CI setup, but still… sweat_smile

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 totestHashedSignature() inReflectionClassResourceTest, but this will cause the currently passing PHP7.1. & PHP7.3 tests to fail.

@xabbuh
Copy link
Member

Adding a new test case annotation with@requires PHP 7.4 should, right?

tvandervorm and derrabus reacted with thumbs up emoji

@tvandervorm
Copy link
ContributorAuthor

ah, I wasn't aware one could specify PHP versions in annotations like that, will give it a go, thanks

xabbuh reacted with thumbs up emoji

@tvandervorm
Copy link
ContributorAuthor

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 oftestHashedSignature(), which seems ugly to me as well. Let me know what is preferred, I'll change it if needed.

Finally, I tried whether the@requires annotation gets taken into account for@dataProvider functions, which would've been the cleanest solution, this is sadly not the case however.


publicfunctionprovideTypedProperties()
{
yield [1,5,'public array $pub;'];
Copy link
Member

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?

Copy link
ContributorAuthor

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.

@tvandervormtvandervormforce-pushed the4.3 branch 2 times, most recently from5d528cf to611bce2CompareJuly 14, 2019 13:23
@fabpotfabpot changed the base branch from4.3 to3.4July 15, 2019 06:55
@fabpot
Copy link
Member

Thank you@tvandervorm.

@fabpotfabpot merged commitbad2a2c intosymfony:3.4Jul 15, 2019
fabpot added a commit that referenced this pull requestJul 15, 2019
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
This was referencedJul 27, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@derrabusderrabusderrabus approved these changes

@xabbuhxabbuhxabbuh approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@tvandervorm@derrabus@xabbuh@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp