$magicCall
$magicCall :
Default implementation of {@link PropertyAccessorInterface}.
getValue(object|array $objectOrArray, string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath) : mixed
Returns the value at the end of the property path of the object graph.
Example:
use Symfony\Component\PropertyAccess\PropertyAccess;
$propertyAccessor = PropertyAccess::createPropertyAccessor();
echo $propertyAccessor->getValue($object, 'child.name);
// equals echo $object->getChild()->getName();
This method first tries to find a public getter for each property in the path. The name of the getter must be the camel-cased property name prefixed with "get", "is", or "has".
If the getter does not exist, this method tries to find a public property. The value of the property is then returned.
If none of them are found, an exception is thrown.
object|array | $objectOrArray | The object or array to traverse |
string|\Symfony\Component\PropertyAccess\PropertyPathInterface | $propertyPath | The property path to read |
The value at the end of the property path
setValue(object|array $objectOrArray, string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath, mixed $value)
Sets the value at the end of the property path of the object graph.
Example:
use Symfony\Component\PropertyAccess\PropertyAccess;
$propertyAccessor = PropertyAccess::createPropertyAccessor();
echo $propertyAccessor->setValue($object, 'child.name', 'Fabien');
// equals echo $object->getChild()->setName('Fabien');
This method first tries to find a public setter for each property in the path. The name of the setter must be the camel-cased property name prefixed with "set".
If the setter does not exist, this method tries to find a public property. The value of the property is then changed.
If neither is found, an exception is thrown.
object|array | $objectOrArray | The object or array to modify |
string|\Symfony\Component\PropertyAccess\PropertyPathInterface | $propertyPath | The property path to modify |
mixed | $value | The value to set at the end of the property path |
isReadable(object|array $objectOrArray, string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath) : boolean
Returns whether a property path can be read from an object graph.
Whenever this method returns true, \Symfony\Component\PropertyAccess\getValue() is guaranteed not to throw an exception when called with the same arguments.
object|array | $objectOrArray | The object or array to check |
string|\Symfony\Component\PropertyAccess\PropertyPathInterface | $propertyPath | The property path to check |
Whether the property path can be read
isWritable(object|array $objectOrArray, string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath) : boolean
Returns whether a value can be written at a given property path.
Whenever this method returns true, \Symfony\Component\PropertyAccess\setValue() is guaranteed not to throw an exception when called with the same arguments.
object|array | $objectOrArray | The object or array to check |
string|\Symfony\Component\PropertyAccess\PropertyPathInterface | $propertyPath | The property path to check |
Whether the value can be set
readPropertiesUntil(array $zval, \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath, integer $lastIndex, boolean $ignoreInvalidIndices = true) : array
Reads the path from an object up to a given path index.
array | $zval | The array containing the object or array to read from |
\Symfony\Component\PropertyAccess\PropertyPathInterface | $propertyPath | The property path to read |
integer | $lastIndex | The index up to which should be read |
boolean | $ignoreInvalidIndices | Whether to ignore invalid indices or throw an exception |
if a value within the path is neither object nor array
If a non-existing index is accessed
The values read in the path
readIndex(array $zval, string|integer $index) : array
Reads a key from an array-like structure.
array | $zval | The array containing the array or \ArrayAccess object to read from |
string|integer | $index | The key to read |
If the array does not implement \ArrayAccess or it is not an array
The array containing the value of the key
readProperty(array $zval, string $property) : array
Reads the a property from an object.
array | $zval | The array containing the object to read from |
string | $property | The property to read |
if the property does not exist or is not public
The array containing the value of the property
writeIndex(array $zval, string|integer $index, mixed $value)
Sets the value of an index in a given array-accessible value.
array | $zval | The array containing the array or \ArrayAccess object to write to |
string|integer | $index | The index to write at |
mixed | $value | The value to write |
If the array does not implement \ArrayAccess or it is not an array
writeProperty(array $zval, string $property, mixed $value)
Sets the value of a property in the given object.
array | $zval | The array containing the object to write to |
string | $property | The property to write |
mixed | $value | The value to write |
if the property does not exist or is not public
writeCollection(array $zval, string $property, \Symfony\Component\PropertyAccess\iterable $collection, string $addMethod, string $removeMethod)
Adjusts a collection-valued property by calling add*() and remove*() methods.
array | $zval | The array containing the object to write to |
string | $property | The property to write |
\Symfony\Component\PropertyAccess\iterable | $collection | The collection to write |
string | $addMethod | The add*() method |
string | $removeMethod | The remove*() method |
findAdderAndRemover(\ReflectionClass $reflClass, array $singulars) : array|null
Searches for add and remove methods.
\ReflectionClass | $reflClass | The reflection class for the given object |
array | $singulars | The singular form of the property name or null |
An array containing the adder and remover when found, null otherwise
isMethodAccessible(\ReflectionClass $class, string $methodName, integer $parameters) : boolean
Returns whether a method is public and has the number of required parameters.
\ReflectionClass | $class | The class of the method |
string | $methodName | The method name |
integer | $parameters | The number of parameters |
Whether the method is public and has $parameters required parameters