Documentation

PropertyAccessor
in package
implements PropertyAccessorInterface

Default implementation of {@link PropertyAccessorInterface}.

Tags
author

Bernhard Schussek bschussek@gmail.com

author

Kévin Dunglas dunglas@gmail.com

author

Nicolas Grekas p@tchwork.com

Table of Contents

Interfaces

PropertyAccessorInterface
Writes and reads values to/from an object/array graph.

Constants

DISALLOW_MAGIC_METHODS  = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::DISALLOW_MAGIC_METHODS
DO_NOT_THROW  = 0
MAGIC_CALL  = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_CALL
MAGIC_GET  = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_GET
MAGIC_SET  = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_SET
THROW_ON_INVALID_INDEX  = 1
THROW_ON_INVALID_PROPERTY_PATH  = 2
CACHE_PREFIX_PROPERTY_PATH  = 'p'
CACHE_PREFIX_READ  = 'r'
CACHE_PREFIX_WRITE  = 'w'
IS_REF_CHAINED  = 2
REF  = 1
RESULT_PROTO  = [self::VALUE => null]
VALUE  = 0

Properties

$cacheItemPool  : CacheItemPoolInterface
$ignoreInvalidIndices  : mixed
$ignoreInvalidProperty  : mixed
$magicMethodsFlags  : mixed
$propertyPathCache  : mixed
$readInfoExtractor  : PropertyReadInfoExtractorInterface
$readPropertyCache  : mixed
$writeInfoExtractor  : PropertyWriteInfoExtractorInterface
$writePropertyCache  : mixed

Methods

__construct()  : mixed
Should not be used by application code. Use {@link PropertyAccess::createPropertyAccessor()} instead.
createCache()  : AdapterInterface
Creates the APCu adapter if applicable.
getValue()  : mixed
Returns the value at the end of the property path of the object graph.
isReadable()  : bool
Returns whether a property path can be read from an object graph.
isWritable()  : bool
Returns whether a value can be written at a given property path.
setValue()  : mixed
Sets the value at the end of the property path of the object graph.
getPropertyPath()  : PropertyPath
Gets a PropertyPath instance and caches it.
getReadInfo()  : PropertyReadInfo|null
Guesses how to read the property value.
getWriteInfo()  : PropertyWriteInfo
isPropertyWritable()  : bool
Returns whether a property is writable in the given object.
readIndex()  : array<string|int, mixed>
Reads a key from an array-like structure.
readPropertiesUntil()  : array<string|int, mixed>
Reads the path from an object up to a given path index.
readProperty()  : array<string|int, mixed>
Reads the value of a property from an object.
throwInvalidArgumentException()  : void
writeCollection()  : mixed
Adjusts a collection-valued property by calling add*() and remove*() methods.
writeIndex()  : mixed
Sets the value of an index in a given array-accessible value.
writeProperty()  : mixed
Sets the value of a property in the given object.

Constants

DISALLOW_MAGIC_METHODS

public int DISALLOW_MAGIC_METHODS = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::DISALLOW_MAGIC_METHODS

Allow none of the magic methods

MAGIC_CALL

public int MAGIC_CALL = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_CALL

Allow magic __call methods

MAGIC_GET

public int MAGIC_GET = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_GET

Allow magic __get methods

MAGIC_SET

public int MAGIC_SET = \Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor::ALLOW_MAGIC_SET

Allow magic __set methods

THROW_ON_INVALID_PROPERTY_PATH

public mixed THROW_ON_INVALID_PROPERTY_PATH = 2

CACHE_PREFIX_PROPERTY_PATH

private mixed CACHE_PREFIX_PROPERTY_PATH = 'p'

Properties

Methods

__construct()

Should not be used by application code. Use {@link PropertyAccess::createPropertyAccessor()} instead.

public __construct([int $magicMethods = self::MAGIC_GET | self::MAGIC_SET ][, int $throw = self::THROW_ON_INVALID_PROPERTY_PATH ][, CacheItemPoolInterface $cacheItemPool = null ][, PropertyReadInfoExtractorInterface $readInfoExtractor = null ][, PropertyWriteInfoExtractorInterface $writeInfoExtractor = null ]) : mixed
Parameters
$magicMethods : int = self::MAGIC_GET | self::MAGIC_SET

A bitwise combination of the MAGIC_* constants to specify the allowed magic methods (__get, __set, __call) or self::DISALLOW_MAGIC_METHODS for none

$throw : int = self::THROW_ON_INVALID_PROPERTY_PATH

A bitwise combination of the THROW_* constants to specify when exceptions should be thrown

$cacheItemPool : CacheItemPoolInterface = null
$readInfoExtractor : PropertyReadInfoExtractorInterface = null
$writeInfoExtractor : PropertyWriteInfoExtractorInterface = null

createCache()

Creates the APCu adapter if applicable.

public static createCache(string $namespace, int $defaultLifetime, string $version[, LoggerInterface $logger = null ]) : AdapterInterface
Parameters
$namespace : string
$defaultLifetime : int
$version : string
$logger : LoggerInterface = null
Tags
throws
LogicException

When the Cache Component isn't available

Return values
AdapterInterface

getValue()

Returns the value at the end of the property path of the object graph.

public getValue(object|array<string|int, mixed> $objectOrArray, string|PropertyPathInterface $propertyPath) : mixed
Parameters
$objectOrArray : object|array<string|int, mixed>
$propertyPath : string|PropertyPathInterface

isReadable()

Returns whether a property path can be read from an object graph.

public isReadable(object|array<string|int, mixed> $objectOrArray, string|PropertyPathInterface $propertyPath) : bool
Parameters
$objectOrArray : object|array<string|int, mixed>
$propertyPath : string|PropertyPathInterface
Return values
bool

isWritable()

Returns whether a value can be written at a given property path.

public isWritable(object|array<string|int, mixed> $objectOrArray, string|PropertyPathInterface $propertyPath) : bool
Parameters
$objectOrArray : object|array<string|int, mixed>
$propertyPath : string|PropertyPathInterface
Return values
bool

setValue()

Sets the value at the end of the property path of the object graph.

public setValue(object|array<string|int, mixed> &$objectOrArray, string|PropertyPathInterface $propertyPath, mixed $value) : mixed
Parameters
$objectOrArray : object|array<string|int, mixed>
$propertyPath : string|PropertyPathInterface
$value : mixed

getReadInfo()

Guesses how to read the property value.

private getReadInfo(string $class, string $property) : PropertyReadInfo|null
Parameters
$class : string
$property : string
Return values
PropertyReadInfo|null

getWriteInfo()

private getWriteInfo(string $class, string $property, mixed $value) : PropertyWriteInfo
Parameters
$class : string
$property : string
$value : mixed
Return values
PropertyWriteInfo

isPropertyWritable()

Returns whether a property is writable in the given object.

private isPropertyWritable(object $object, string $property) : bool
Parameters
$object : object
$property : string
Return values
bool

readIndex()

Reads a key from an array-like structure.

private readIndex(array<string|int, mixed> $zval, string|int $index) : array<string|int, mixed>
Parameters
$zval : array<string|int, mixed>
$index : string|int
Tags
throws
NoSuchIndexException

If the array does not implement \ArrayAccess or it is not an array

Return values
array<string|int, mixed>

readPropertiesUntil()

Reads the path from an object up to a given path index.

private readPropertiesUntil(array<string|int, mixed> $zval, PropertyPathInterface $propertyPath, int $lastIndex[, bool $ignoreInvalidIndices = true ]) : array<string|int, mixed>
Parameters
$zval : array<string|int, mixed>
$propertyPath : PropertyPathInterface
$lastIndex : int
$ignoreInvalidIndices : bool = true
Tags
throws
UnexpectedTypeException

if a value within the path is neither object nor array

throws
NoSuchIndexException

If a non-existing index is accessed

Return values
array<string|int, mixed>

readProperty()

Reads the value of a property from an object.

private readProperty(array<string|int, mixed> $zval, string $property[, bool $ignoreInvalidProperty = false ]) : array<string|int, mixed>
Parameters
$zval : array<string|int, mixed>
$property : string
$ignoreInvalidProperty : bool = false
Tags
throws
NoSuchPropertyException

If $ignoreInvalidProperty is false and the property does not exist or is not public

Return values
array<string|int, mixed>

throwInvalidArgumentException()

private static throwInvalidArgumentException(string $message, array<string|int, mixed> $trace, int $i, string $propertyPath[, Throwable $previous = null ]) : void
Parameters
$message : string
$trace : array<string|int, mixed>
$i : int
$propertyPath : string
$previous : Throwable = null

writeCollection()

Adjusts a collection-valued property by calling add*() and remove*() methods.

private writeCollection(array<string|int, mixed> $zval, string $property, iterable<string|int, mixed> $collection, PropertyWriteInfo $addMethod, PropertyWriteInfo $removeMethod) : mixed
Parameters
$zval : array<string|int, mixed>
$property : string
$collection : iterable<string|int, mixed>
$addMethod : PropertyWriteInfo
$removeMethod : PropertyWriteInfo

writeIndex()

Sets the value of an index in a given array-accessible value.

private writeIndex(array<string|int, mixed> $zval, string|int $index, mixed $value) : mixed
Parameters
$zval : array<string|int, mixed>
$index : string|int
$value : mixed
Tags
throws
NoSuchIndexException

If the array does not implement \ArrayAccess or it is not an array

writeProperty()

Sets the value of a property in the given object.

private writeProperty(array<string|int, mixed> $zval, string $property, mixed $value) : mixed
Parameters
$zval : array<string|int, mixed>
$property : string
$value : mixed
Tags
throws
NoSuchPropertyException

if the property does not exist or is not public


        
On this page

Search results