-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] Add nullsafe operator support #34497
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
[PropertyAccess] Add nullsafe operator support #34497
Conversation
908618f
to
66f5307
Compare
b22389d
to
bd0de68
Compare
I have updated the the Pull Requests; the unit tests are updated as well. I can update the documentation but before that I would like to know if the feature will be kept. Regards, Edit: There are errors with the ci's but other Pull Request seems to have the same issue with "already" existing table errors. |
src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
Outdated
Show resolved
Hide resolved
bd0de68
to
30a80a3
Compare
30a80a3
to
79b2fa1
Compare
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.
maybe "nullable" is a better wording for this? or "nullsafe"?
I had to open the RFC to get what "optional" was about.
* | ||
* @throws Exception\OutOfBoundsException If the offset is invalid | ||
*/ | ||
public function isOptional(int $index); |
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.
Missing return type.
Note that adding a new method on an existing interface is a BC break.
We use @method
annotations in similar cases. See branch 4.4 for examples.
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.
Did it,
just when I am using it shouldn't I trigger a deprecation if the method is not set?
I found this example in the 4.4 branch and it's not present: https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php#L120
@oliverde8 Still interested in finishing this PR? |
I missed nicolas-grekas last comment, I will do the changes this weekend. sorry about that. |
src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php
Outdated
Show resolved
Hide resolved
5236eb4
to
759432c
Compare
759432c
to
4996cd3
Compare
…nal-property-access # Conflicts: # src/Symfony/Component/PropertyAccess/PropertyAccessor.php
8ec7c15
to
f1630f0
Compare
if (method_exists($propertyPath, 'isNullSafe')) { | ||
// To be removed in symfony 6 once we are sure isNullSafe is always implemented. | ||
$isNullSafe = $propertyPath->isNullSafe($i); | ||
} |
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.
I think we need to add an else
clause here to raise a deprecation notice to help people with upgrading their code.
We've just moved away from |
…s (fsoedjede) This PR was merged into the 6.2 branch. Discussion ---------- [Form][PropertyAccess] Allow optional property accesses | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #34483 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#17288 <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> This PR is basically a copy of #34497 with some minor changes. I needed it and I have some time now to help advance in implementing it. **TODO** - [x] Add nullsafe operator usage - [x] Update unit test - [x] Update documentation Regards Commits ------- 6455feb feature #34483 - Allow optional property accesses
TODO: