Use ::class

This commit is contained in:
Fabien Potencier
2023-10-08 08:43:21 +02:00
parent 67c8798074
commit fed8dd102b
14 changed files with 33 additions and 33 deletions
+4 -4
View File
@@ -122,7 +122,7 @@ final class ExtensionSet
public function addExtension(ExtensionInterface $extension): void
{
$class = \get_class($extension);
$class = $extension::class;
if ($this->initialized) {
throw new \LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $class));
@@ -330,7 +330,7 @@ final class ExtensionSet
$extGlobals = $extension->getGlobals();
if (!\is_array($extGlobals)) {
throw new \UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', \get_class($extension)));
throw new \UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', $extension::class));
}
$globals = array_merge($globals, $extGlobals);
@@ -466,11 +466,11 @@ final class ExtensionSet
// operators
if ($operators = $extension->getOperators()) {
if (!\is_array($operators)) {
throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', \get_class($extension), \is_object($operators) ? \get_class($operators) : \gettype($operators).(\is_resource($operators) ? '' : '#'.$operators)));
throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', $extension::class, \is_object($operators) ? $operators::class : \gettype($operators).(\is_resource($operators) ? '' : '#'.$operators)));
}
if (2 !== \count($operators)) {
throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', \get_class($extension), \count($operators)));
throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', $extension::class, \count($operators)));
}
$this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);