8000 feature #10570 [PropertyAccess] Added isReadable() and isWritable() (… · symfony/symfony@c5a3008 · GitHub
[go: up one dir, main page]

Skip to content

Commit c5a3008

Browse files
committed
feature #10570 [PropertyAccess] Added isReadable() and isWritable() (webmozart)
This PR was merged into the 2.5-dev branch. Discussion ---------- [PropertyAccess] Added isReadable() and isWritable() | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8659 | License | MIT | Doc PR | symfony/symfony-docs#3729 This PR introduces BC breaks that are described in detail in the UPGRADE file. The BC breaks conform to our policy. They shouldn't affect many people, so I think we can safely do them. Commits ------- f7fb855 [PropertyAccess] Added missing exceptions to phpdoc 9aee2ad [PropertyAccess] Removed the argument $value from isWritable() 4262707 [PropertyAccess] Fixed CS and added missing documentation 6d2af21 [PropertyAccess] Added isReadable() and isWritable() 20e6bf8 [PropertyAccess] Refactored PropertyAccessorCollectionTest 0488389 [PropertyAccess] Refactored PropertyAccessorTest
2 parents 2ab27ab + f7fb855 commit c5a3008

13 files changed

+817
-593
lines changed

UPGRADE-2.5.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,47 @@ Form
4545
{
4646
```
4747

48+
PropertyAccess
49+
--------------
50+
51+
* The methods `isReadable()` and `isWritable()` were added to
52+
`PropertyAccessorInterface`. If you implemented this interface in your own
53+
code, you should add these two methods.
54+
55+
* The methods `getValue()` and `setValue()` now throw an
56+
`NoSuchIndexException` instead of a `NoSuchPropertyException` when an index
57+
is accessed on an object that does not implement `ArrayAccess`. If you catch
58+
this exception in your code, you should adapt the catch statement:
59+
60+
Before:
61+
62+
```php
63+
$object = new \stdClass();
64+
65+
try {
66+
$propertyAccessor->getValue($object, '[index]');
67+
$propertyAccessor->setValue($object, '[index]', 'New value');
68+
} catch (NoSuchPropertyException $e) {
69+
// ...
70+
}
71+
```
72+
73+
After:
74+
75+
```php
76+
$object = new \stdClass();
77+
78+
try {
79+
$propertyAccessor->getValue($object, '[index]');
80+
$propertyAccessor->setValue($object, '[index]', 'New value');
81+
} catch (NoSuchIndexException $e) {
82+
// ...
83+
}
84+
```
85+
86+
A `NoSuchPropertyException` is still thrown when a non-existing property is
87+
accessed on an object or an array.
88+
4889
Validator
4990
---------
5091

@@ -56,7 +97,7 @@ Validator
5697

5798
After:
5899

59-
Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be
100+
Default email validation is now done via a simple regex which may cause invalid emails (not RFC compilant) to be
60101
valid. This is the default behaviour.
61102

62103
Strict email validation has to be explicitly activated in the configuration file by adding

src/Symfony/Component/PropertyAccess/CHANGELOG.md

Line 8000 s changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ CHANGELOG
55
------
66

77
* allowed non alpha numeric characters in second level and deeper object properties names
8+
* [BC BREAK] when accessing an index on an object that does not implement
9+
ArrayAccess, a NoSuchIndexException is now thrown instead of the
10+
semantically wrong NoSuchPropertyException
11+
* [BC BREAK] added isReadable() and isWritable() to PropertyAccessorInterface
812

913
2.3.0
1014
------
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyAccess\Exception;
13+
14+
/**
15+
* Base InvalidArgumentException for the PropertyAccess component.
16+
*
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
20+
{
21+
}

0 commit comments

Comments
 (0)
0