PropertyAccessorBuilder example


    /** * Creates a property accessor with the default configuration. */
    public static function createPropertyAccessor(): PropertyAccessor
    {
        return self::createPropertyAccessorBuilder()->getPropertyAccessor();
    }

    public static function createPropertyAccessorBuilder(): PropertyAccessorBuilder
    {
        return new PropertyAccessorBuilder();
    }

    /** * This class cannot be instantiated. */
    private function __construct()
    {
    }
}
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
use Symfony\Component\PropertyInfo\PropertyReadInfoExtractorInterface;
use Symfony\Component\PropertyInfo\PropertyWriteInfoExtractorInterface;

class PropertyAccessorBuilderTest extends TestCase
{
    protected PropertyAccessorBuilder $builder;

    protected function setUp(): void
    {
        $this->builder = new PropertyAccessorBuilder();
    }

    public function testEnableMagicGet()
    {
        $this->assertSame($this->builder, $this->builder->enableMagicGet());
        $this->assertTrue($this->builder->isMagicGetEnabled());
    }

    public function testDisableMagicGet()
    {
        $this->assertSame($this->builder, $this->builder->disableMagicGet());
        
Home | Imprint | This part of the site doesn't use cookies.