class ClassMetadata
Same name in this branch
- 11.1.x vendor/symfony/validator/Mapping/ClassMetadata.php \Symfony\Component\Validator\Mapping\ClassMetadata
@author Kévin Dunglas <dunglas@gmail.com>
Hierarchy
- class \Symfony\Component\Serializer\Mapping\ClassMetadata implements \Symfony\Component\Serializer\Mapping\ClassMetadataInterface
Expanded class hierarchy of ClassMetadata
2 files declare their use of ClassMetadata
- ClassMetadataFactory.php in vendor/
symfony/ serializer/ Mapping/ Factory/ ClassMetadataFactory.php - CompiledClassMetadataFactory.php in vendor/
symfony/ serializer/ Mapping/ Factory/ CompiledClassMetadataFactory.php
File
-
vendor/
symfony/ serializer/ Mapping/ ClassMetadata.php, line 17
Namespace
Symfony\Component\Serializer\MappingView source
class ClassMetadata implements ClassMetadataInterface {
/**
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
* {@link getName()} instead.
*/
public string $name;
/**
* @var AttributeMetadataInterface[]
*
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
* {@link getAttributesMetadata()} instead.
*/
public array $attributesMetadata = [];
private ?\ReflectionClass $reflClass = null;
/**
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
* {@link getClassDiscriminatorMapping()} instead.
*/
public ?ClassDiscriminatorMapping $classDiscriminatorMapping = null;
/**
* Constructs a metadata for the given class.
*/
public function __construct(string $class, ?ClassDiscriminatorMapping $classDiscriminatorMapping = null) {
$this->name = $class;
$this->classDiscriminatorMapping = $classDiscriminatorMapping;
}
public function getName() : string {
return $this->name;
}
public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata) : void {
$this->attributesMetadata[$attributeMetadata->getName()] = $attributeMetadata;
}
public function getAttributesMetadata() : array {
return $this->attributesMetadata;
}
public function merge(ClassMetadataInterface $classMetadata) : void {
foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
if (isset($this->attributesMetadata[$attributeMetadata->getName()])) {
$this->attributesMetadata[$attributeMetadata->getName()]
->merge($attributeMetadata);
}
else {
$this->addAttributeMetadata($attributeMetadata);
}
}
}
public function getReflectionClass() : \ReflectionClass {
return $this->reflClass ??= new \ReflectionClass($this->getName());
}
public function getClassDiscriminatorMapping() : ?ClassDiscriminatorMapping {
return $this->classDiscriminatorMapping;
}
public function setClassDiscriminatorMapping(?ClassDiscriminatorMapping $mapping) : void {
$this->classDiscriminatorMapping = $mapping;
}
/**
* Returns the names of the properties that should be serialized.
*
* @return string[]
*/
public function __sleep() : array {
return [
'name',
'attributesMetadata',
'classDiscriminatorMapping',
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ClassMetadata::$attributesMetadata | public | property | @internal This property is public in order to reduce the size of the class' serialized representation. Do not access it. Use {@link getAttributesMetadata()} instead. |
|
ClassMetadata::$classDiscriminatorMapping | public | property | @internal This property is public in order to reduce the size of the class' serialized representation. Do not access it. Use {@link getClassDiscriminatorMapping()} instead. |
|
ClassMetadata::$name | public | property | @internal This property is public in order to reduce the size of the class' serialized representation. Do not access it. Use {@link getName()} instead. |
|
ClassMetadata::$reflClass | private | property | ||
ClassMetadata::addAttributeMetadata | public | function | Adds an {@link AttributeMetadataInterface}. | Overrides ClassMetadataInterface::addAttributeMetadata |
ClassMetadata::getAttributesMetadata | public | function | Gets the list of {@link AttributeMetadataInterface}. | Overrides ClassMetadataInterface::getAttributesMetadata |
ClassMetadata::getClassDiscriminatorMapping | public | function | Overrides ClassMetadataInterface::getClassDiscriminatorMapping | |
ClassMetadata::getName | public | function | Returns the name of the backing PHP class. | Overrides ClassMetadataInterface::getName |
ClassMetadata::getReflectionClass | public | function | Returns a {@link \ReflectionClass} instance for this class. | Overrides ClassMetadataInterface::getReflectionClass |
ClassMetadata::merge | public | function | Merges a {@link ClassMetadataInterface} in the current one. | Overrides ClassMetadataInterface::merge |
ClassMetadata::setClassDiscriminatorMapping | public | function | Overrides ClassMetadataInterface::setClassDiscriminatorMapping | |
ClassMetadata::__construct | public | function | Constructs a metadata for the given class. | |
ClassMetadata::__sleep | public | function | Returns the names of the properties that should be serialized. |