-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] Added isReadable() and isWritable() #10570
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0488389
[PropertyAccess] Refactored PropertyAccessorTest
webmozart 20e6bf8
[PropertyAccess] Refactored PropertyAccessorCollectionTest
webmozart 6d2af21
[PropertyAccess] Added isReadable() and isWritable()
webmozart 4262707
[PropertyAccess] Fixed CS and added missing documentation
webmozart 9aee2ad
[PropertyAccess] Removed the argument $value from isWritable()
webmozart f7fb855
[PropertyAccess] Added missing exceptions to phpdoc
webmozart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,47 @@ Form | |
{ | ||
``` | ||
|
||
PropertyAccess | ||
-------------- | ||
|
||
* The methods `isReadable()` and `isWritable()` were added to | ||
`PropertyAccessorInterface`. If you implemented this interface in your own | ||
code, you should add these two methods. | ||
|
||
* The methods `getValue()` and `setValue()` now throw an | ||
`NoSuchIndexException` instead of a `NoSuchPropertyException` when an index | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I also had this one on my to-do list |
||
is accessed on an object that does not implement `ArrayAccess`. If you catch | ||
this exception in your code, you should adapt the catch statement: | ||
|
||
Before: | ||
|
||
```php | ||
$object = new \stdClass(); | ||
|
||
try { | ||
$propertyAccessor->getValue($object, '[index]'); | ||
$propertyAccessor->setValue($object, '[index]', 'New value'); | ||
} catch (NoSuchPropertyException $e) { | ||
// ... | ||
} | ||
``` | ||
|
||
After: | ||
|
||
```php | ||
$object = new \stdClass(); | ||
|
||
try { | ||
$propertyAccessor->getValue($object, '[index]'); | ||
$propertyAccessor->setValue($object, '[index]', 'New value'); | ||
} catch (NoSuchIndexException $e) { | ||
// ... | ||
} | ||
``` | ||
|
||
A `NoSuchPropertyException` is still thrown when a non-existing property is | ||
accessed on an object or an array. | ||
|
||
Validator | ||
--------- | ||
|
||
|
@@ -56,7 +97,7 @@ Validator | |
|
||
After: | ||
|
||
Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be | ||
Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be | ||
valid. This is the default behaviour. | ||
|
||
Strict email validation has to be explicitly activated in the configuration file by adding | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/PropertyAccess/Exception/InvalidArgumentException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\PropertyAccess\Exception; | ||
|
||
/** | ||
* Base InvalidArgumentException for the PropertyAccess component. | ||
* | ||
* @author Bernhard Schussek <bschussek@gmail.com> | ||
*/ | ||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface | ||
{ | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[BC Break]
prefixThere 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.
hmm, sorry, no. This file documents only BC breaks, so not needed
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.
We never have this prefix in the UPGRADE file.