[PropertyAccess] Add missing arguments to PropertyAccess::createPropertyAccessor()
This commit is contained in:
parent
052c314bd0
commit
5ded8047ec
@ -21,21 +21,35 @@ final class PropertyAccess
|
|||||||
/**
|
/**
|
||||||
* Creates a property accessor with the default configuration.
|
* Creates a property accessor with the default configuration.
|
||||||
*
|
*
|
||||||
|
* @param bool $throwExceptionOnInvalidIndex
|
||||||
|
*
|
||||||
* @return PropertyAccessor The new property accessor
|
* @return PropertyAccessor The new property accessor
|
||||||
*/
|
*/
|
||||||
public static function createPropertyAccessor()
|
public static function createPropertyAccessor($throwExceptionOnInvalidIndex = false, $magicCall = false)
|
||||||
{
|
{
|
||||||
return self::createPropertyAccessorBuilder()->getPropertyAccessor();
|
return self::createPropertyAccessorBuilder($throwExceptionOnInvalidIndex, $magicCall)->getPropertyAccessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a property accessor builder.
|
* Creates a property accessor builder.
|
||||||
*
|
*
|
||||||
|
* @param bool $enableExceptionOnInvalidIndex
|
||||||
|
*
|
||||||
* @return PropertyAccessorBuilder The new property accessor builder
|
* @return PropertyAccessorBuilder The new property accessor builder
|
||||||
*/
|
*/
|
||||||
public static function createPropertyAccessorBuilder()
|
public static function createPropertyAccessorBuilder($enableExceptionOnInvalidIndex = false, $enableMagicCall = false)
|
||||||
{
|
{
|
||||||
return new PropertyAccessorBuilder();
|
$propertyAccessorBuilder = new PropertyAccessorBuilder();
|
||||||
|
|
||||||
|
if ($enableExceptionOnInvalidIndex) {
|
||||||
|
$propertyAccessorBuilder->enableExceptionOnInvalidIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($enableMagicCall) {
|
||||||
|
$propertyAccessorBuilder->enableMagicCall();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $propertyAccessorBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?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\Tests;
|
||||||
|
|
||||||
|
use Symfony\Component\PropertyAccess\PropertyAccess;
|
||||||
|
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robin Chalas <robin.chalas@gmail.com
|
||||||
|
*/
|
||||||
|
final class PropertyAccessTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testCreatePropertyAccessor()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(PropertyAccessor::class, PropertyAccess::createPropertyAccessor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreatePropertyAccessorWithExceptionOnInvalidIndex()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(PropertyAccessor::class, PropertyAccess::createPropertyAccessor(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreatePropertyAccessorWithMagicCallEnabled()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(PropertyAccessor::class, PropertyAccess::createPropertyAccessor(false, true));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user