- md5
- 458679346a93b1a74537c246943b1010
- sha1
- 9e43e7a7a072bb043ba2f6551188dbffac8820f6
- sha256
- 4e09dff7a78dcce1b55683c94fd28c1575c330574ca57eddaf57b4bddb1e632f
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Loader;
use Symfony\Component\Validator\Exception\MappingException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* Loads validation metadata by calling a static method on the loaded class.
*
* @author Bernhard Schussek <[email protected]>
*/
class StaticMethodLoader implements LoaderInterface
{
protected $methodName;
/**
* Creates a new loader.
*
* @param string $methodName The name of the static method to call
*/
public function __construct(string $methodName = 'loadValidatorMetadata')
{
$this->methodName = $methodName;
}
public function loadClassMetadata(ClassMetadata $metadata): bool
{
/** @var \ReflectionClass $reflClass */
$reflClass = $metadata->getReflectionClass();
if (!$reflClass->isInterface() && $reflClass->hasMethod($this->methodName)) {
$reflMethod = $reflClass->getMethod($this->methodName);
if ($reflMethod->isAbstract()) {
return false;
}
if (!$reflMethod->isStatic()) {
throw new MappingException(\sprintf('The method "%s::%s()" should be static.', $reflClass->name, $this->methodName));
}
if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
return false;
}
$reflMethod->invoke(null, $metadata);
return true;
}
return false;
}
}
The same content is in 70 releases, Joomla 5.4.0-rc1 to 6.2.1-rc1. See them all, or every version of this file.