schema
3 years ago
AbstractLoader.php
4 years ago
AnnotationLoader.php
1 year ago
AutoMappingTrait.php
1 year ago
FileLoader.php
4 years ago
FilesLoader.php
4 years ago
LoaderChain.php
4 years ago
LoaderInterface.php
4 years ago
PropertyInfoLoader.php
1 year ago
StaticMethodLoader.php
4 years ago
XmlFileLoader.php
4 years ago
XmlFilesLoader.php
4 years ago
YamlFileLoader.php
4 years ago
YamlFilesLoader.php
4 years ago
index.php
3 years ago
StaticMethodLoader.php
33 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Validator\Mapping\Loader; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\Validator\Exception\MappingException; |
| 5 | use MailPoetVendor\Symfony\Component\Validator\Mapping\ClassMetadata; |
| 6 | class StaticMethodLoader implements LoaderInterface |
| 7 | { |
| 8 | protected $methodName; |
| 9 | public function __construct(string $methodName = 'loadValidatorMetadata') |
| 10 | { |
| 11 | $this->methodName = $methodName; |
| 12 | } |
| 13 | public function loadClassMetadata(ClassMetadata $metadata) |
| 14 | { |
| 15 | $reflClass = $metadata->getReflectionClass(); |
| 16 | if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) { |
| 17 | $reflMethod = $reflClass->getMethod($this->methodName); |
| 18 | if ($reflMethod->isAbstract()) { |
| 19 | return \false; |
| 20 | } |
| 21 | if (!$reflMethod->isStatic()) { |
| 22 | throw new MappingException(\sprintf('The method "%s::%s()" should be static.', $reflClass->name, $this->methodName)); |
| 23 | } |
| 24 | if ($reflMethod->getDeclaringClass()->name != $reflClass->name) { |
| 25 | return \false; |
| 26 | } |
| 27 | $reflMethod->invoke(null, $metadata); |
| 28 | return \true; |
| 29 | } |
| 30 | return \false; |
| 31 | } |
| 32 | } |
| 33 |