Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 11, 2023
1 parent 742d303 commit d2ad016
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/DI/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/DI/ContainerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ContainerLoader
use Nette\SmartObject;

/** @var bool */
private $autoRebuild = false;
private $autoRebuild;

/** @var string */
private $tempDirectory;
Expand Down
2 changes: 1 addition & 1 deletion src/DI/Definitions/LocatorDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions src/DI/Extensions/DefinitionSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -133,9 +133,6 @@ public function normalize($def, Context $context)
}

return $def;

} else {
throw new Nette\DI\InvalidConfigurationException('Unexpected format of service definition');
}
}

Expand All @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions src/DI/Extensions/InjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/DI/Extensions/SearchExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/DI/Extensions/ServicesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


/**
* Service definitions loader.
* Services definitions loader.
*/
final class ServicesExtension extends Nette\DI\CompilerExtension
{
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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));
}
Expand Down
11 changes: 5 additions & 6 deletions src/DI/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Nette\Utils\Reflection;
use Nette\Utils\Strings;
use Nette\Utils\Validators;
use ReflectionClass;


/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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]]);
Expand Down

0 comments on commit d2ad016

Please sign in to comment.