mediatekformation

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

Interfaces, Classes, Traits and Enums

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

Table of Contents

ACCESS_ADDER  = 4
ACCESS_HAS_PROPERTY  = 0
ACCESS_NAME  = 2
ACCESS_REF  = 3
ACCESS_REMOVER  = 5
ACCESS_TYPE  = 1
ACCESS_TYPE_ADDER_AND_REMOVER  = 3
ACCESS_TYPE_MAGIC  = 2
ACCESS_TYPE_METHOD  = 0
ACCESS_TYPE_NOT_FOUND  = 4
ACCESS_TYPE_PROPERTY  = 1
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
$cacheItemPool  : CacheItemPoolInterface
$ignoreInvalidIndices  : mixed
$ignoreInvalidProperty  : mixed
$magicCall  : bool
$propertyPathCache  : mixed
$readPropertyCache  : mixed
$writePropertyCache  : mixed
__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.
camelize()  : string
Camelizes a given string.
findAdderAndRemover()  : iteratable<string|int, mixed>
Searches for add and remove methods.
getPropertyPath()  : PropertyPath
Gets a PropertyPath instance and caches it.
getReadAccessInfo()  : array<string|int, mixed>
Guesses how to read the property value.
getWriteAccessInfo()  : array<string|int, mixed>
Guesses how to write the property value.
isMethodAccessible()  : bool
Returns whether a method is public and has the number of required parameters.
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 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

ACCESS_TYPE_ADDER_AND_REMOVER

private mixed ACCESS_TYPE_ADDER_AND_REMOVER = 3

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([bool $magicCall = false ][, bool $throwExceptionOnInvalidIndex = false ][, CacheItemPoolInterface $cacheItemPool = null ][, bool $throwExceptionOnInvalidPropertyPath = true ]) : mixed
Parameters
$magicCall : bool = false
$throwExceptionOnInvalidIndex : bool = false
$cacheItemPool : CacheItemPoolInterface = null
$throwExceptionOnInvalidPropertyPath : bool = true
Return values
mixed —

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(mixed $objectOrArray, mixed $propertyPath) : mixed
Parameters
$objectOrArray : mixed

The object or array to traverse

$propertyPath : mixed

The property path to read

Return values
mixed —

The value at the end of the property path

isReadable()

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

public isReadable(mixed $objectOrArray, mixed $propertyPath) : bool
Parameters
$objectOrArray : mixed

The object or array to check

$propertyPath : mixed

The property path to check

Return values
bool —

Whether the property path can be read

isWritable()

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

public isWritable(mixed $objectOrArray, mixed $propertyPath) : bool
Parameters
$objectOrArray : mixed

The object or array to check

$propertyPath : mixed

The property path to check

Return values
bool —

Whether the value can be set

setValue()

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

public setValue(mixed &$objectOrArray, mixed $propertyPath, mixed $value) : mixed
Parameters
$objectOrArray : mixed

The object or array to modify

$propertyPath : mixed

The property path to modify

$value : mixed

The value to set at the end of the property path

Return values
mixed —

camelize()

Camelizes a given string.

private camelize(string $string) : string
Parameters
$string : string
Return values
string —

findAdderAndRemover()

Searches for add and remove methods.

private findAdderAndRemover(ReflectionClass $reflClass, array<string|int, mixed> $singulars) : iteratable<string|int, mixed>
Parameters
$reflClass : ReflectionClass
$singulars : array<string|int, mixed>
Return values
iteratable<string|int, mixed> —

getReadAccessInfo()

Guesses how to read the property value.

private getReadAccessInfo(string $class, string $property) : array<string|int, mixed>
Parameters
$class : string
$property : string
Return values
array<string|int, mixed> —

getWriteAccessInfo()

Guesses how to write the property value.

private getWriteAccessInfo(string $class, string $property, mixed $value) : array<string|int, mixed>
Parameters
$class : string
$property : string
$value : mixed
Return values
array<string|int, mixed> —

isMethodAccessible()

Returns whether a method is public and has the number of required parameters.

private isMethodAccessible(ReflectionClass $class, string $methodName, int $parameters) : bool
Parameters
$class : ReflectionClass
$methodName : string
$parameters : int
Return values
bool —

isPropertyWritable()

Returns whether a property is writable in the given object.

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

The object to write to

$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

The key to read

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 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
Return values
void —

writeCollection()

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

private writeCollection(array<string|int, mixed> $zval, string $property, iteratable<string|int, mixed> $collection, string $addMethod, string $removeMethod) : mixed
Parameters
$zval : array<string|int, mixed>
$property : string
$collection : iteratable<string|int, mixed>
$addMethod : string
$removeMethod : string
Return values
mixed —

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

The index to write at

$value : mixed

The value to write

Tags
throws
NoSuchIndexException

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

Return values
mixed —

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

The value to write

Tags
throws
NoSuchPropertyException

if the property does not exist or is not public

Return values
mixed —

Search results