Class

Symfony\Component\Validator\Mapping\GetterMetadata

class GetterMetadata extends MemberMetadata

Stores all metadata needed for validating a class property via its getter method.

A property getter is any method that is equal to the property's name, prefixed with either "get" or "is". That method will be used to access the property's value.

The getter will be invoked by reflection, so the access of private and protected getters is supported.

This class supports serialization and cloning.

Properties

Constraint[] $constraints
array $constraintsByGroup
int $cascadingStrategy The strategy for cascading objects.
int $traversalStrategy The strategy for traversing traversable objects.
string $class
string $name
string $property

Methods

string[] __sleep()

Returns the names of the properties that should be serialized.

from MemberMetadata
__clone()

Clones this object.

from GenericMetadata
GenericMetadata addConstraint(Constraint $constraint)

Adds a constraint.

from MemberMetadata
GenericMetadata addConstraints(array $constraints)

Adds an list of constraints.

from GenericMetadata
Constraint[] getConstraints()

Returns all constraints of this element.

from GenericMetadata
bool hasConstraints()

Returns whether this element has any constraints.

from GenericMetadata
Constraint[] findConstraints(string $group)

Returns the constraints of the given group and global ones (* group).

from GenericMetadata
int getCascadingStrategy()

Returns the strategy for cascading objects.

from GenericMetadata
int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

from GenericMetadata
accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath, $propagatedGroup = null)

Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}.

from MemberMetadata
__construct(string $class, string $property)

Constructor.

string getName()

Returns the name of the member.

from MemberMetadata
string getClassName()

Returns the name of the backing PHP class.

from MemberMetadata
string getPropertyName()

Returns the name of the property.

from MemberMetadata
bool isPublic(object|string $objectOrClassName)

Returns whether this member is public.

from MemberMetadata
bool isProtected(object|string $objectOrClassName)

Returns whether this member is protected

from MemberMetadata
bool isPrivate(object|string $objectOrClassName)

Returns whether this member is private.

from MemberMetadata
bool isCascaded()

Returns whether objects stored in this member should be validated.

from MemberMetadata
bool isCollectionCascaded()

Returns whether arrays or traversable objects stored in this member should be traversed and validated in each entry.

from MemberMetadata
bool isCollectionCascadedDeeply()

Returns whether arrays or traversable objects stored in this member should be traversed recursively for inner arrays/traversable objects.

from MemberMetadata
ReflectionMethod|ReflectionProperty getReflectionMember(object|string $objectOrClassName)

Returns the reflection instance for accessing the member's value.

from MemberMetadata
mixed getPropertyValue($object)

Extracts the value of the property from the given container.

Details

in MemberMetadata at line 112
public string[] __sleep()

Returns the names of the properties that should be serialized.

Return Value

string[]

in GenericMetadata at line 97
public __clone()

Clones this object.

in MemberMetadata at line 95
public GenericMetadata addConstraint(Constraint $constraint)

Adds a constraint.

If the constraint {@link Valid} is added, the cascading strategy will be changed to {@link CascadingStrategy::CASCADE}. Depending on the properties $traverse and $deep of that constraint, the traversal strategy will be set to one of the following:

Parameters

Constraint $constraint The constraint to add

Return Value

GenericMetadata This object

Exceptions

ConstraintDefinitionException When trying to add the {@link Traverse} constraint

in GenericMetadata at line 173
public GenericMetadata addConstraints(array $constraints)

Adds an list of constraints.

Parameters

array $constraints The constraints to add

Return Value

GenericMetadata This object

in GenericMetadata at line 187
public Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

in GenericMetadata at line 197
public bool hasConstraints()

Returns whether this element has any constraints.

Return Value

bool

in GenericMetadata at line 210
public Constraint[] findConstraints(string $group)

Returns the constraints of the given group and global ones (* group).

Parameters

string $group The group name

Return Value

Constraint[] An list of all the Constraint instances belonging to the group

in GenericMetadata at line 220
public int getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

int The cascading strategy

in GenericMetadata at line 228
public int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

int The traversal strategy

in MemberMetadata at line 83
public accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath, $propagatedGroup = null)

Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}.

Should not be used.

Parameters

ValidationVisitorInterface $visitor The visitor implementing the validation logic
mixed $value The value to validate
string|string[] $group The validation group to validate in
string $propertyPath The current property path in the validation graph
$propagatedGroup

Exceptions

BadMethodCallException

at line 43
public __construct(string $class, string $property)

Constructor.

Parameters

string $class The class the getter is defined on
string $property The property which the getter returns

Exceptions

ValidatorException

in MemberMetadata at line 126
public string getName()

Returns the name of the member.

Return Value

string

in MemberMetadata at line 134
public string getClassName()

Returns the name of the backing PHP class.

Return Value

string The name of the backing class.

in MemberMetadata at line 142
public string getPropertyName()

Returns the name of the property.

Return Value

string The property name.

in MemberMetadata at line 154
public bool isPublic(object|string $objectOrClassName)

Returns whether this member is public.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line 166
public bool isProtected(object|string $objectOrClassName)

Returns whether this member is protected

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line 178
public bool isPrivate(object|string $objectOrClassName)

Returns whether this member is private.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

bool

in MemberMetadata at line 191
public bool isCascaded()

Returns whether objects stored in this member should be validated.

Return Value

bool

in MemberMetadata at line 205
public bool isCollectionCascaded()

Returns whether arrays or traversable objects stored in this member should be traversed and validated in each entry.

Return Value

bool

in MemberMetadata at line 219
public bool isCollectionCascadedDeeply()

Returns whether arrays or traversable objects stored in this member should be traversed recursively for inner arrays/traversable objects.

Return Value

bool

in MemberMetadata at line 231
public ReflectionMethod|ReflectionProperty getReflectionMember(object|string $objectOrClassName)

Returns the reflection instance for accessing the member's value.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

ReflectionMethod|ReflectionProperty The reflection instance

at line 65
public mixed getPropertyValue($object)

Extracts the value of the property from the given container.

Parameters

$object

Return Value

mixed The value of the property.