[PropertyAccess] Added missing new args in PropertyAccessorBuilder
This commit is contained in:
parent
c0ee02bf19
commit
e1be8cd61b
@ -12,6 +12,8 @@
|
|||||||
namespace Symfony\Component\PropertyAccess;
|
namespace Symfony\Component\PropertyAccess;
|
||||||
|
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
|
use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
|
||||||
|
use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A configurable builder to create a PropertyAccessor.
|
* A configurable builder to create a PropertyAccessor.
|
||||||
@ -29,6 +31,16 @@ class PropertyAccessorBuilder
|
|||||||
*/
|
*/
|
||||||
private $cacheItemPool;
|
private $cacheItemPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PropertyReadInfoExtractorInterface|null
|
||||||
|
*/
|
||||||
|
private $readInfoExtractor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PropertyWriteInfoExtractorInterface|null
|
||||||
|
*/
|
||||||
|
private $writeInfoExtractor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables the use of "__call" by the PropertyAccessor.
|
* Enables the use of "__call" by the PropertyAccessor.
|
||||||
*
|
*
|
||||||
@ -157,6 +169,36 @@ class PropertyAccessorBuilder
|
|||||||
return $this->cacheItemPool;
|
return $this->cacheItemPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setReadInfoExtractor(?PropertyReadInfoExtractorInterface $readInfoExtractor)
|
||||||
|
{
|
||||||
|
$this->readInfoExtractor = $readInfoExtractor;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReadInfoExtractor(): ?PropertyReadInfoExtractorInterface
|
||||||
|
{
|
||||||
|
return $this->readInfoExtractor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setWriteInfoExtractor(?PropertyWriteInfoExtractorInterface $writeInfoExtractor)
|
||||||
|
{
|
||||||
|
$this->writeInfoExtractor = $writeInfoExtractor;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWriteInfoExtractor(): ?PropertyWriteInfoExtractorInterface
|
||||||
|
{
|
||||||
|
return $this->writeInfoExtractor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds and returns a new PropertyAccessor object.
|
* Builds and returns a new PropertyAccessor object.
|
||||||
*
|
*
|
||||||
@ -164,6 +206,6 @@ class PropertyAccessorBuilder
|
|||||||
*/
|
*/
|
||||||
public function getPropertyAccessor()
|
public function getPropertyAccessor()
|
||||||
{
|
{
|
||||||
return new PropertyAccessor($this->magicCall, $this->throwExceptionOnInvalidIndex, $this->cacheItemPool, $this->throwExceptionOnInvalidPropertyPath);
|
return new PropertyAccessor($this->magicCall, $this->throwExceptionOnInvalidIndex, $this->cacheItemPool, $this->throwExceptionOnInvalidPropertyPath, $this->readInfoExtractor, $this->writeInfoExtractor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||||
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
|
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
|
||||||
|
use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
|
||||||
|
use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
|
||||||
|
|
||||||
class PropertyAccessorBuilderTest extends TestCase
|
class PropertyAccessorBuilderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -63,4 +65,24 @@ class PropertyAccessorBuilderTest extends TestCase
|
|||||||
$this->assertEquals($cacheItemPool, $this->builder->getCacheItemPool());
|
$this->assertEquals($cacheItemPool, $this->builder->getCacheItemPool());
|
||||||
$this->assertInstanceOf(PropertyAccessor::class, $this->builder->getPropertyAccessor());
|
$this->assertInstanceOf(PropertyAccessor::class, $this->builder->getPropertyAccessor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUseReadInfoExtractor()
|
||||||
|
{
|
||||||
|
$readInfoExtractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
|
||||||
|
|
||||||
|
$this->builder->setReadInfoExtractor($readInfoExtractor);
|
||||||
|
|
||||||
|
$this->assertSame($readInfoExtractor, $this->builder->getReadInfoExtractor());
|
||||||
|
$this->assertInstanceOf(PropertyAccessor::class, $this->builder->getPropertyAccessor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUseWriteInfoExtractor()
|
||||||
|
{
|
||||||
|
$writeInfoExtractor = $this->createMock(PropertyWriteInfoExtractorInterface::class);
|
||||||
|
|
||||||
|
$this->builder->setWriteInfoExtractor($writeInfoExtractor);
|
||||||
|
|
||||||
|
$this->assertSame($writeInfoExtractor, $this->builder->getWriteInfoExtractor());
|
||||||
|
$this->assertInstanceOf(PropertyAccessor::class, $this->builder->getPropertyAccessor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user