File tree Expand file tree Collapse file tree 2 files changed +54
-4
lines changed
src/Symfony/Component/PropertyAccess Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -21,21 +21,35 @@ final class PropertyAccess
21
21
/**
22
22
* Creates a property accessor with the default configuration.
23
23
*
24
+ * @param bool $throwExceptionOnInvalidIndex
25
+ *
24
26
* @return PropertyAccessor The new property accessor
25
27
*/
26
- public static function createPropertyAccessor ()
28
+ public static function createPropertyAccessor ($ throwExceptionOnInvalidIndex = false , $ magicCall = false )
27
29
{
28
- return self ::createPropertyAccessorBuilder ()->getPropertyAccessor ();
30
+ return self ::createPropertyAccessorBuilder ($ throwExceptionOnInvalidIndex , $ magicCall )->getPropertyAccessor ();
29
31
}
30
32
31
33
/**
32
34
* Creates a property accessor builder.
33
35
*
36
+ * @param bool $enableExceptionOnInvalidIndex
37
+ *
34
38
* @return PropertyAccessorBuilder The new property accessor builder
35
39
*/
36
- public static function createPropertyAccessorBuilder ()
40
+ public static function createPropertyAccessorBuilder ($ enableExceptionOnInvalidIndex = false , $ enableMagicCall = false )
37
41
{
38
- return new PropertyAccessorBuilder ();
42
+ $ propertyAccessorBuilder = new PropertyAccessorBuilder ();
43
+
44
+ if ($ enableExceptionOnInvalidIndex ) {
45
+ $ propertyAccessorBuilder ->enableExceptionOnInvalidIndex ();
46
+ }
47
+
48
+ if ($ enableMagicCall ) {
49
+ $ propertyAccessorBuilder ->enableMagicCall ();
50
+ }
51
+
52
+ return $ propertyAccessorBuilder ;
39
53
}
40
54
41
55
/**
Original file line number Diff line number Diff line change
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 \Tests ;
13
+
14
+ use Symfony \Component \PropertyAccess \PropertyAccess ;
15
+ use Symfony \Component \PropertyAccess \PropertyAccessor ;
16
+
17
+ /**
18
+ * @author Robin Chalas <robin.chalas@gmail.com
19
+ */
20
+ final class PropertyAccessTest extends \PHPUnit_Framework_TestCase
21
+ {
22
+ public function testCreatePropertyAccessor ()
23
+ {
24
+ $ this ->assertInstanceOf (PropertyAccessor::class, PropertyAccess::createPropertyAccessor ());
25
+ }
26
+
27
+ public function testCreatePropertyAccessorWithExceptionOnInvalidIndex ()
28
+ {
29
+ $ this ->assertInstanceOf (PropertyAccessor::class, PropertyAccess::createPropertyAccessor (true ));
30
+ }
31
+
32
+ public function testCreatePropertyAccessorWithMagicCallEnabled ()
33
+ {
34
+ $ this ->assertInstanceOf (PropertyAccessor::class, PropertyAccess::createPropertyAccessor (false , true ));
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments