Properties

$magicCall

$magicCall

$ignoreInvalidIndices

$ignoreInvalidIndices

$readPropertyCache

$readPropertyCache

$writePropertyCache

$writePropertyCache

$previousErrorHandler

$previousErrorHandler

$errorHandler

$errorHandler

$resultProto

$resultProto

Methods

__construct()

__construct(bool  $magicCall = false, bool  $throwExceptionOnInvalidIndex = false) : mixed

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

Parameters

bool $magicCall
bool $throwExceptionOnInvalidIndex

Returns

mixed —

getValue()

getValue(mixed  $objectOrArray, mixed  $propertyPath) : mixed

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

Parameters

mixed $objectOrArray

The object or array to traverse

mixed $propertyPath

The property path to read

Returns

mixed —

The value at the end of the property path

setValue()

setValue(mixed  $objectOrArray, mixed  $propertyPath, mixed  $value) : mixed

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

Parameters

mixed $objectOrArray

The object or array to modify

mixed $propertyPath

The property path to modify

mixed $value

The value to set at the end of the property path

Returns

mixed —

isReadable()

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

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

Parameters

mixed $objectOrArray

The object or array to check

mixed $propertyPath

The property path to check

Returns

bool —

Whether the property path can be read

isWritable()

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

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

Parameters

mixed $objectOrArray

The object or array to check

mixed $propertyPath

The property path to check

Returns

bool —

Whether the value can be set

throwInvalidArgumentException()

throwInvalidArgumentException(mixed  $message, mixed  $trace, mixed  $i) : mixed

Parameters

mixed $message
mixed $trace
mixed $i

Returns

mixed —

readPropertiesUntil()

readPropertiesUntil(array  $zval, \Symfony\Component\PropertyAccess\PropertyPathInterface  $propertyPath, int  $lastIndex, bool  $ignoreInvalidIndices = true) : array

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

Parameters

array $zval

The array containing the object or array to read from

\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath

The property path to read

int $lastIndex

The index up to which should be read

bool $ignoreInvalidIndices

Whether to ignore invalid indices or throw an exception

Throws

\Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException

if a value within the path is neither object nor array

\Symfony\Component\PropertyAccess\Exception\NoSuchIndexException

If a non-existing index is accessed

Returns

array —

The values read in the path

readIndex()

readIndex(array  $zval, string|int  $index) : array

Reads a key from an array-like structure.

Parameters

array $zval

The array containing the array or \ArrayAccess object to read from

string|int $index

The key to read

Throws

\Symfony\Component\PropertyAccess\Exception\NoSuchIndexException

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

Returns

array —

The array containing the value of the key

readProperty()

readProperty(array  $zval, string  $property) : array

Reads the a property from an object.

Parameters

array $zval

The array containing the object to read from

string $property

The property to read

Throws

\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException

if the property does not exist or is not public

Returns

array —

The array containing the value of the property

getReadAccessInfo()

getReadAccessInfo(string  $class, string  $property) : array

Guesses how to read the property value.

Parameters

string $class
string $property

Returns

array —

writeIndex()

writeIndex(array  $zval, string|int  $index, mixed  $value) : mixed

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

Parameters

array $zval

The array containing the array or \ArrayAccess object to write to

string|int $index

The index to write at

mixed $value

The value to write

Throws

\Symfony\Component\PropertyAccess\Exception\NoSuchIndexException

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

Returns

mixed —

writeProperty()

writeProperty(array  $zval, string  $property, mixed  $value) : mixed

Sets the value of a property in the given object.

Parameters

array $zval

The array containing the object to write to

string $property

The property to write

mixed $value

The value to write

Throws

\Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException

if the property does not exist or is not public

Returns

mixed —

writeCollection()

writeCollection(array  $zval, string  $property, iterable  $collection, string  $addMethod, string  $removeMethod) : mixed

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

Parameters

array $zval

The array containing the object to write to

string $property

The property to write

iterable $collection

The collection to write

string $addMethod

The add*() method

string $removeMethod

The remove*() method

Returns

mixed —

getWriteAccessInfo()

getWriteAccessInfo(string  $class, string  $property, mixed  $value) : array

Guesses how to write the property value.

Parameters

string $class
string $property
mixed $value

Returns

array —

isPropertyWritable()

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

Returns whether a property is writable in the given object.

Parameters

object $object

The object to write to

string $property

The property to write

Returns

bool —

Whether the property is writable

camelize()

camelize(string  $string) : string

Camelizes a given string.

Parameters

string $string

Some string

Returns

string —

The camelized version of the string

findAdderAndRemover()

findAdderAndRemover(\ReflectionClass  $reflClass, array  $singulars) : array|null

Searches for add and remove methods.

Parameters

\ReflectionClass $reflClass

The reflection class for the given object

array $singulars

The singular form of the property name or null

Returns

array|null —

An array containing the adder and remover when found, null otherwise

isMethodAccessible()

isMethodAccessible(\ReflectionClass  $class, string  $methodName, int  $parameters) : bool

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

Parameters

\ReflectionClass $class

The class of the method

string $methodName

The method name

int $parameters

The number of parameters

Returns

bool —

Whether the method is public and has $parameters required parameters