From d2ad016623d549b656b4ecbc7d20ceb4e43325e1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 11 Dec 2023 18:11:23 +0100 Subject: [PATCH] typos --- src/DI/Container.php | 2 +- src/DI/ContainerLoader.php | 2 +- src/DI/Definitions/LocatorDefinition.php | 2 +- src/DI/Extensions/DefinitionSchema.php | 7 ++----- src/DI/Extensions/InjectExtension.php | 3 +-- src/DI/Extensions/SearchExtension.php | 2 +- src/DI/Extensions/ServicesExtension.php | 8 ++++---- src/DI/Resolver.php | 11 +++++------ 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/DI/Container.php b/src/DI/Container.php index 88274b8be..c96be8a59 100644 --- a/src/DI/Container.php +++ b/src/DI/Container.php @@ -360,7 +360,7 @@ public function createInstance(string $class, array $args = []): object /** - * Calls all methods starting with with "inject" using autowiring. + * Calls all methods starting with "inject" using autowiring. */ public function callInjects(object $service): void { diff --git a/src/DI/ContainerLoader.php b/src/DI/ContainerLoader.php index d8b04cb62..8d71235f8 100644 --- a/src/DI/ContainerLoader.php +++ b/src/DI/ContainerLoader.php @@ -20,7 +20,7 @@ class ContainerLoader use Nette\SmartObject; /** @var bool */ - private $autoRebuild = false; + private $autoRebuild; /** @var string */ private $tempDirectory; diff --git a/src/DI/Definitions/LocatorDefinition.php b/src/DI/Definitions/LocatorDefinition.php index 0412ff7ab..6a0cbb0d2 100644 --- a/src/DI/Definitions/LocatorDefinition.php +++ b/src/DI/Definitions/LocatorDefinition.php @@ -119,7 +119,7 @@ public function complete(Nette\DI\Resolver $resolver): void $this->getName(), $this->tagged, $tag - ), E_USER_NOTICE); + )); } $this->references[$tag] = new Reference($name); diff --git a/src/DI/Extensions/DefinitionSchema.php b/src/DI/Extensions/DefinitionSchema.php index 77146ebd0..8c546dde5 100644 --- a/src/DI/Extensions/DefinitionSchema.php +++ b/src/DI/Extensions/DefinitionSchema.php @@ -98,7 +98,7 @@ public function normalize($def, Context $context) } elseif (!is_array($def) || isset($def[0], $def[1])) { return ['create' => $def]; - } elseif (is_array($def)) { + } else { // back compatibility if (isset($def['factory']) && !isset($def['create'])) { $def['create'] = $def['factory']; @@ -133,9 +133,6 @@ public function normalize($def, Context $context) } return $def; - - } else { - throw new Nette\DI\InvalidConfigurationException('Unexpected format of service definition'); } } @@ -149,7 +146,7 @@ private function sniffType($key, array $def): string { if (is_string($key)) { $name = preg_match('#^@[\w\\\\]+$#D', $key) - ? $this->builder->getByType(substr($key, 1), false) + ? $this->builder->getByType(substr($key, 1)) : $key; if ($name && $this->builder->hasDefinition($name)) { diff --git a/src/DI/Extensions/InjectExtension.php b/src/DI/Extensions/InjectExtension.php index 5916bd653..7309bb97a 100644 --- a/src/DI/Extensions/InjectExtension.php +++ b/src/DI/Extensions/InjectExtension.php @@ -119,7 +119,6 @@ public static function getInjectProperties(string $class): array { $res = []; foreach ((new \ReflectionClass($class))->getProperties() as $rp) { - $name = $rp->getName(); $hasAttr = PHP_VERSION_ID >= 80000 && $rp->getAttributes(DI\Attributes\Inject::class); if ($hasAttr || DI\Helpers::parseAnnotation($rp, 'inject') !== null) { if (!$rp->isPublic() || $rp->isStatic()) { @@ -147,7 +146,7 @@ public static function getInjectProperties(string $class): array /** - * Calls all methods starting with with "inject" using autowiring. + * Calls all methods starting with "inject" using autowiring. * @param object $service */ public static function callInjects(DI\Container $container, $service): void diff --git a/src/DI/Extensions/SearchExtension.php b/src/DI/Extensions/SearchExtension.php index 34b6daea1..275f9637f 100644 --- a/src/DI/Extensions/SearchExtension.php +++ b/src/DI/Extensions/SearchExtension.php @@ -144,7 +144,7 @@ public function beforeCompile() private static function buildNameRegexp(array $masks): ?string { $res = []; - foreach ((array) $masks as $mask) { + foreach ($masks as $mask) { $mask = (strpos($mask, '\\') === false ? '**\\' : '') . $mask; $mask = preg_quote($mask, '#'); $mask = str_replace('\*\*\\\\', '(.*\\\\)?', $mask); diff --git a/src/DI/Extensions/ServicesExtension.php b/src/DI/Extensions/ServicesExtension.php index 7a92aeedd..1f848ed8c 100644 --- a/src/DI/Extensions/ServicesExtension.php +++ b/src/DI/Extensions/ServicesExtension.php @@ -16,7 +16,7 @@ /** - * Service definitions loader. + * Services definitions loader. */ final class ServicesExtension extends Nette\DI\CompilerExtension { @@ -103,7 +103,7 @@ private function updateServiceDefinition(Definitions\ServiceDefinition $definiti $definition->setSetup([]); } - foreach (Helpers::filterArguments($config->setup) as $id => $setup) { + foreach (Helpers::filterArguments($config->setup) as $setup) { if (is_array($setup)) { $setup = new Statement(key($setup), array_values($setup)); } @@ -136,7 +136,7 @@ private function updateFactoryDefinition(Definitions\FactoryDefinition $definiti if (isset($config->implement)) { $definition->setImplement($config->implement); - $definition->setAutowired(true); + $definition->setAutowired(); } if ($config->create) { @@ -161,7 +161,7 @@ private function updateFactoryDefinition(Definitions\FactoryDefinition $definiti $resultDef->setSetup([]); } - foreach (Helpers::filterArguments($config->setup) as $id => $setup) { + foreach (Helpers::filterArguments($config->setup) as $setup) { if (is_array($setup)) { $setup = new Statement(key($setup), array_values($setup)); } diff --git a/src/DI/Resolver.php b/src/DI/Resolver.php index 15ec7db1a..b62550dde 100644 --- a/src/DI/Resolver.php +++ b/src/DI/Resolver.php @@ -19,7 +19,6 @@ use Nette\Utils\Reflection; use Nette\Utils\Strings; use Nette\Utils\Validators; -use ReflectionClass; /** @@ -221,11 +220,11 @@ public function completeStatement(Statement $statement, bool $currentServiceAllo case is_string($entity): // create class if (!class_exists($entity)) { throw new ServiceCreationException(sprintf("Class '%s' not found.", $entity)); - } elseif ((new ReflectionClass($entity))->isAbstract()) { + } elseif ((new \ReflectionClass($entity))->isAbstract()) { throw new ServiceCreationException(sprintf('Class %s is abstract.', $entity)); - } elseif (($rm = (new ReflectionClass($entity))->getConstructor()) !== null && !$rm->isPublic()) { + } elseif (($rm = (new \ReflectionClass($entity))->getConstructor()) !== null && !$rm->isPublic()) { throw new ServiceCreationException(sprintf('Class %s has %s constructor.', $entity, $rm->isProtected() ? 'protected' : 'private')); - } elseif ($constructor = (new ReflectionClass($entity))->getConstructor()) { + } elseif ($constructor = (new \ReflectionClass($entity))->getConstructor()) { $arguments = self::autowireArguments($constructor, $arguments, $getter); $this->addDependency($constructor); } elseif ($arguments) { @@ -281,7 +280,7 @@ public function completeStatement(Statement $statement, bool $currentServiceAllo ? $this->resolveReferenceType($entity[0]) : $this->resolveEntityType($entity[0] instanceof Statement ? $entity[0] : new Statement($entity[0])) ) { - $rc = new ReflectionClass($type); + $rc = new \ReflectionClass($type); if ($rc->hasMethod($entity[1])) { $rm = $rc->getMethod($entity[1]); if (!$rm->isPublic()) { @@ -506,7 +505,7 @@ private function convertReferences(array $arguments): array $pair = explode('::', substr($val, 1), 2); if (!isset($pair[1])) { // @service $val = new Reference($pair[0]); - } elseif (preg_match('#^[A-Z][a-zA-Z0-9_]*$#D', $pair[1], $m)) { // @service::CONSTANT + } elseif (preg_match('#^[A-Z][a-zA-Z0-9_]*$#D', $pair[1])) { // @service::CONSTANT $val = ContainerBuilder::literal($this->resolveReferenceType(new Reference($pair[0])) . '::' . $pair[1]); } else { // @service::property $val = new Statement([new Reference($pair[0]), '$' . $pair[1]]);