ClassMetadata
extends GenericMetadata
in package
implements
ClassMetadataInterface
Default implementation of {@link ClassMetadataInterface}.
This class supports serialization and cloning.
Tags
Table of Contents
Interfaces
- ClassMetadataInterface
- Stores all metadata needed for validating objects of specific class.
Properties
- $reflClass : ReflectionClass
Methods
- __clone() : mixed
- Clones this object.
- __construct() : mixed
- __sleep() : array<string|int, string>
- Returns the names of the properties that should be serialized.
- addConstraint() : $this
- Adds a constraint.
- addConstraints() : $this
- Adds an list of constraints.
- addGetterConstraint() : $this
- Adds a constraint to the getter of the given property.
- addGetterConstraints() : $this
- addGetterMethodConstraint() : $this
- Adds a constraint to the getter of the given property.
- addGetterMethodConstraints() : $this
- addPropertyConstraint() : $this
- Adds a constraint to the given property.
- addPropertyConstraints() : $this
- findConstraints() : array<string|int, Constraint>
- Returns all constraints for a given validation group.
- getAutoMappingStrategy() : int
- getCascadingStrategy() : int
- Returns the strategy for cascading objects.
- getClassName() : string
- Returns the name of the backing PHP class.
- getConstrainedProperties() : array<string|int, string>
- Returns the names of all constrained properties.
- getConstraints() : array<string|int, Constraint>
- Returns all constraints of this element.
- getDefaultGroup() : string
- Returns the name of the default group for this class.
- getGroupSequence() : GroupSequence|null
- Returns the group sequence that overrides the "Default" group for this class.
- getPropertyMetadata() : array<string|int, PropertyMetadataInterface>
- Returns all metadata instances for the given named property.
- getReflectionClass() : ReflectionClass
- Returns a ReflectionClass instance for this class.
- getTraversalStrategy() : int
- Returns the strategy for traversing traversable objects.
- hasConstraints() : bool
- Returns whether this element has any constraints.
- hasGroupSequence() : bool
- Returns whether the "Default" group is overridden by a group sequence.
- hasPropertyMetadata() : bool
- Check if there's any metadata attached to the given named property.
- isGroupSequenceProvider() : bool
- Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.
- mergeConstraints() : mixed
- Merges the constraints of the given metadata into this object.
- setGroupSequence() : $this
- Sets the default group sequence for this class.
- setGroupSequenceProvider() : mixed
- Sets whether a group sequence provider should be used.
- addPropertyMetadata() : mixed
- checkConstraint() : mixed
Properties
$reflClass
private
ReflectionClass
$reflClass
Methods
__clone()
Clones this object.
public
__clone() : mixed
__construct()
public
__construct(string $class) : mixed
Parameters
- $class : string
__sleep()
Returns the names of the properties that should be serialized.
public
__sleep() : array<string|int, string>
Return values
array<string|int, string>addConstraint()
Adds a constraint.
public
addConstraint(Constraint $constraint) : $this
If the constraint is added, the cascading strategy will be changed to .
If the constraint is added, the traversal strategy will be changed. Depending on the $traverse property of that constraint, the traversal strategy will be set to one of the following:
Parameters
- $constraint : Constraint
Return values
$thisaddConstraints()
Adds an list of constraints.
public
addConstraints(array<string|int, Constraint> $constraints) : $this
Parameters
- $constraints : array<string|int, Constraint>
-
The constraints to add
Return values
$thisaddGetterConstraint()
Adds a constraint to the getter of the given property.
public
addGetterConstraint(string $property, Constraint $constraint) : $this
The name of the getter is assumed to be the name of the property with an uppercased first letter and the prefix "get", "is" or "has".
Parameters
- $property : string
- $constraint : Constraint
Return values
$thisaddGetterConstraints()
public
addGetterConstraints(string $property, array<string|int, Constraint> $constraints) : $this
Parameters
- $property : string
- $constraints : array<string|int, Constraint>
Return values
$thisaddGetterMethodConstraint()
Adds a constraint to the getter of the given property.
public
addGetterMethodConstraint(string $property, string $method, Constraint $constraint) : $this
Parameters
- $property : string
- $method : string
- $constraint : Constraint
Return values
$thisaddGetterMethodConstraints()
public
addGetterMethodConstraints(string $property, string $method, array<string|int, Constraint> $constraints) : $this
Parameters
- $property : string
- $method : string
- $constraints : array<string|int, Constraint>
Return values
$thisaddPropertyConstraint()
Adds a constraint to the given property.
public
addPropertyConstraint(string $property, Constraint $constraint) : $this
Parameters
- $property : string
- $constraint : Constraint
Return values
$thisaddPropertyConstraints()
public
addPropertyConstraints(string $property, array<string|int, Constraint> $constraints) : $this
Parameters
- $property : string
- $constraints : array<string|int, Constraint>
Return values
$thisfindConstraints()
Returns all constraints for a given validation group.
public
findConstraints(string $group) : array<string|int, Constraint>
Aware of the global group (* group).
Parameters
- $group : string
-
The validation group
Return values
array<string|int, Constraint>getAutoMappingStrategy()
public
getAutoMappingStrategy() : int
Tags
Return values
intgetCascadingStrategy()
Returns the strategy for cascading objects.
public
getCascadingStrategy() : int
Return values
intgetClassName()
Returns the name of the backing PHP class.
public
getClassName() : string
Return values
stringgetConstrainedProperties()
Returns the names of all constrained properties.
public
getConstrainedProperties() : array<string|int, string>
Return values
array<string|int, string>getConstraints()
Returns all constraints of this element.
public
getConstraints() : array<string|int, Constraint>
Return values
array<string|int, Constraint>getDefaultGroup()
Returns the name of the default group for this class.
public
getDefaultGroup() : string
For each class, the group "Default" is an alias for the group "<ClassName>", where <ClassName> is the non-namespaced name of the class. All constraints implicitly or explicitly assigned to group "Default" belong to both of these groups, unless the class defines a group sequence.
If a class defines a group sequence, validating the class in "Default" will validate the group sequence. The constraints assigned to "Default" can still be validated by validating the class in "<ClassName>".
Return values
stringgetGroupSequence()
Returns the group sequence that overrides the "Default" group for this class.
public
getGroupSequence() : GroupSequence|null
Return values
GroupSequence|nullgetPropertyMetadata()
Returns all metadata instances for the given named property.
public
getPropertyMetadata(string $property) : array<string|int, PropertyMetadataInterface>
Parameters
- $property : string
-
The property name
Return values
array<string|int, PropertyMetadataInterface>getReflectionClass()
Returns a ReflectionClass instance for this class.
public
getReflectionClass() : ReflectionClass
Return values
ReflectionClassgetTraversalStrategy()
Returns the strategy for traversing traversable objects.
public
getTraversalStrategy() : int
Return values
inthasConstraints()
Returns whether this element has any constraints.
public
hasConstraints() : bool
Return values
boolhasGroupSequence()
Returns whether the "Default" group is overridden by a group sequence.
public
hasGroupSequence() : bool
Return values
boolhasPropertyMetadata()
Check if there's any metadata attached to the given named property.
public
hasPropertyMetadata(string $property) : bool
Parameters
- $property : string
-
The property name
Return values
boolisGroupSequenceProvider()
Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.
public
isGroupSequenceProvider() : bool
Return values
boolmergeConstraints()
Merges the constraints of the given metadata into this object.
public
mergeConstraints(self $source) : mixed
Parameters
- $source : self
setGroupSequence()
Sets the default group sequence for this class.
public
setGroupSequence(array<string|int, string>|GroupSequence $groupSequence) : $this
Parameters
- $groupSequence : array<string|int, string>|GroupSequence
-
An array of group names
Tags
Return values
$thissetGroupSequenceProvider()
Sets whether a group sequence provider should be used.
public
setGroupSequenceProvider(bool $active) : mixed
Parameters
- $active : bool
Tags
addPropertyMetadata()
private
addPropertyMetadata(PropertyMetadataInterface $metadata) : mixed
Parameters
- $metadata : PropertyMetadataInterface
checkConstraint()
private
checkConstraint(Constraint $constraint) : mixed
Parameters
- $constraint : Constraint