bug #36119 [PropertyAccess] Added missing new args in PropertyAccessorBuilder
(HeahDude)
This PR was merged into the 5.1-dev branch.
Discussion
----------
[PropertyAccess] Added missing new args in `PropertyAccessorBuilder`
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | ~
| License | MIT
| Doc PR | ~
Following #30704.
Commits
-------
e1be8cd61b
[PropertyAccess] Added missing new args in PropertyAccessorBuilder
This commit is contained in:
commit
6902a56e75
@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\PropertyAccess;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
|
||||
|
||||
/**
|
||||
* A configurable builder to create a PropertyAccessor.
|
||||
@ -29,6 +31,16 @@ class PropertyAccessorBuilder
|
||||
*/
|
||||
private $cacheItemPool;
|
||||
|
||||
/**
|
||||
* @var PropertyReadInfoExtractorInterface|null
|
||||
*/
|
||||
private $readInfoExtractor;
|
||||
|
||||
/**
|
||||
* @var PropertyWriteInfoExtractorInterface|null
|
||||
*/
|
||||
private $writeInfoExtractor;
|
||||
|
||||
/**
|
||||
* Enables the use of "__call" by the PropertyAccessor.
|
||||
*
|
||||
@ -157,6 +169,36 @@ class PropertyAccessorBuilder
|
||||
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.
|
||||
*
|
||||
@ -164,6 +206,6 @@ class PropertyAccessorBuilder
|
||||
*/
|
||||
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\PropertyAccess\PropertyAccessor;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
|
||||
use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;
|
||||
|
||||
class PropertyAccessorBuilderTest extends TestCase
|
||||
{
|
||||
@ -63,4 +65,24 @@ class PropertyAccessorBuilderTest extends TestCase
|
||||
$this->assertEquals($cacheItemPool, $this->builder->getCacheItemPool());
|
||||
$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