Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Mar 31, 2014
2 parents 2ab27ab + f7fb855 commit c5a3008
Show file tree
Hide file tree
Showing 13 changed files with 817 additions and 593 deletions.
43 changes: 42 additions & 1 deletion UPGRADE-2.5.md
Expand Up @@ -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
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
---------

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/PropertyAccess/CHANGELOG.md
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
------

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

2.3.0
------
Expand Down
@@ -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
{
}

0 comments on commit c5a3008

Please sign in to comment.