class PropertyMetadata extends MemberMetadata

Stores all metadata needed for validating a class property.

The value of the property is obtained by directly accessing the property. The property will be accessed by reflection, so the access of private and protected properties is supported.

This class supports serialization and cloning.

Properties

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

Methods

string[]
__sleep()

Returns the names of the properties that should be serialized.

__clone()

Clones this object.

$this
addConstraint(Constraint $constraint)

Adds a constraint.

$this
addConstraints(array $constraints)

Adds an list of constraints.

getConstraints()

Returns all constraints of this element.

bool
hasConstraints()

Returns whether this element has any constraints.

findConstraints(string $group)

Returns all constraints for a given validation group.

int
getCascadingStrategy()

Returns the strategy for cascading objects.

int
getTraversalStrategy()

Returns the strategy for traversing traversable objects.

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

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

__construct(string $class, string $name)

No description

string
getName()

Returns the name of the member.

string
getClassName()

Returns the name of the backing PHP class.

string
getPropertyName()

Returns the name of the property.

bool
isPublic(object|string $objectOrClassName)

Returns whether this member is public.

bool
isProtected(object|string $objectOrClassName)

Returns whether this member is protected.

bool
isPrivate(object|string $objectOrClassName)

Returns whether this member is private.

bool
isCascaded() deprecated

Returns whether objects stored in this member should be validated.

bool
isCollectionCascaded() deprecated

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

bool
isCollectionCascadedDeeply() deprecated

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

getReflectionMember(object|string $objectOrClassName)

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

newReflectionMember(object|string $objectOrClassName)

Creates a new reflection instance for accessing the member's value.

mixed
getPropertyValue($object)

Extracts the value of the property from the given container.

Details

in MemberMetadata at line 103
string[] __sleep()

Returns the names of the properties that should be serialized.

Return Value

string[]

in GenericMetadata at line 96
__clone()

Clones this object.

in MemberMetadata at line 89
$this 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:

  • {@link TraversalStrategy::IMPLICIT} if $traverse is enabled and $deep is enabled
  • {@link TraversalStrategy::IMPLICIT} | {@link TraversalStrategy::STOP_RECURSION} if $traverse is enabled, but $deep is disabled
  • {@link TraversalStrategy::NONE} if $traverse is disabled

Parameters

Constraint $constraint

Return Value

$this

Exceptions

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

in GenericMetadata at line 166
$this addConstraints(array $constraints)

Adds an list of constraints.

Parameters

array $constraints The constraints to add

Return Value

$this

in GenericMetadata at line 178
Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

in GenericMetadata at line 188
bool hasConstraints()

Returns whether this element has any constraints.

Return Value

bool

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

Returns all constraints for a given validation group.

Parameters

string $group The validation group

Return Value

Constraint[] A list of constraint instances

in GenericMetadata at line 208
int getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

int The cascading strategy

in GenericMetadata at line 216
int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

int The traversal strategy

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

deprecated since version 2.5, to be removed in 3.0.

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

Should not be used.

Implemented for backward compatibility with Symfony < 2.5.

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 37
__construct(string $class, string $name)

Parameters

string $class The name of the class this member is defined on
string $name The name of the member

Exceptions

ValidatorException

in MemberMetadata at line 117
string getName()

Returns the name of the member.

Return Value

string

in MemberMetadata at line 125
string getClassName()

Returns the name of the backing PHP class.

Return Value

string The name of the backing class

in MemberMetadata at line 133
string getPropertyName()

Returns the name of the property.

Return Value

string The property name

in MemberMetadata at line 145
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 157
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 169
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 182
bool isCascaded() deprecated

deprecated since version 2.5, to be removed in 3.0. Use {@link getCascadingStrategy()} instead.

Returns whether objects stored in this member should be validated.

Return Value

bool

in MemberMetadata at line 198
bool isCollectionCascaded() deprecated

deprecated since version 2.5, to be removed in 3.0. Use {@link getTraversalStrategy()} instead.

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 214
bool isCollectionCascadedDeeply() deprecated

deprecated since version 2.5, to be removed in 3.0. Use {@link getTraversalStrategy()} instead.

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 228
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 57
protected ReflectionMethod|ReflectionProperty newReflectionMember(object|string $objectOrClassName)

Creates a new reflection instance for accessing the member's value.

Must be implemented by subclasses.

Parameters

object|string $objectOrClassName The object or the class name

Return Value

ReflectionMethod|ReflectionProperty The reflection instance

at line 49
mixed getPropertyValue($object)

Extracts the value of the property from the given container.

Parameters

$object

Return Value

mixed The value of the property