Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Validator] fix access to uninitialized property when getting value #35532

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2020
Merged

[Validator] fix access to uninitialized property when getting value #35532

merged 1 commit into from
Jan 31, 2020

Conversation

greedyivan
Copy link
Contributor

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #35454
License MIT
Doc PR

In PHP 7.4, the type-hinted property is uninitialized by default. So it needs to be checked before use.

@greedyivan greedyivan changed the title fix access to uninitialized property when getting value [Validator] fix access to uninitialized property when getting value Jan 30, 2020
@xabbuh xabbuh added this to the 3.4 milestone Jan 31, 2020
@fabpot
Copy link
Member

fabpot commented Jan 31, 2020

Thank you @greedyivan.

fabpot added a commit that referenced this pull request Jan 31, 2020
…ing value (greedyivan)

This PR was squashed before being merged into the 3.4 branch (closes #35532).

Discussion
----------

[Validator] fix access to uninitialized property when getting value

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35454
| License       | MIT
| Doc PR        |

In PHP 7.4, the type-hinted property is [uninitialized](https://wiki.php.net/rfc/typed_properties_v2#uninitialized_and_unset_properties) by default. So it needs to be checked before use.

Commits
-------

1edecf7 [Validator] fix access to uninitialized property when getting value
@fabpot fabpot merged commit 1edecf7 into symfony:3.4 Jan 31, 2020
@greedyivan greedyivan deleted the bugfix_35454_34 branch January 31, 2020 09:00
This was referenced Jan 31, 2020
@fabpot fabpot mentioned this pull request Feb 29, 2020
@realjjaveweb
Copy link

@nicolas-grekas Hi, would you mind please documenting this also here:
https://symfony.com/doc/current/reference/constraints/NotNull.html or maybe on some generic constraints/validator level?

Because there's not name of Constraint that would imply check for uninitialized property, so people often times just use
#[Assert\NotNull] (Assert = \Symfony\Component\Validator\Constraints).

Which is completely fine since this commit/MR merged but it's not documented anywhere - or at least I didn't find it anywhere in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants