From 4e4186ebf272da0f45492ab3e83a8c3d7c3278a1 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 8 Mar 2022 14:51:55 +0200 Subject: [PATCH] type fixes --- application/Espo/Core/InjectableFactory.php | 49 ++++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/application/Espo/Core/InjectableFactory.php b/application/Espo/Core/InjectableFactory.php index 5c9daecb55..ab08879318 100644 --- a/application/Espo/Core/InjectableFactory.php +++ b/application/Espo/Core/InjectableFactory.php @@ -65,8 +65,8 @@ class InjectableFactory * Create an instance by a class name. * * @template T of object - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @return T */ public function create(string $className): object { @@ -78,8 +78,9 @@ class InjectableFactory * defined in an associative array. A key should match the parameter name. * * @template T of object - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @param array $with + * @return T */ public function createWith(string $className, array $with): object { @@ -90,8 +91,8 @@ class InjectableFactory * Create an instance by a class name with a specific binding. * * @template T of object - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @return T */ public function createWithBinding(string $className, BindingContainer $bindingContainer): object { @@ -100,8 +101,9 @@ class InjectableFactory /** * @template T of object - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @param ?array $with + * @return T */ private function createInternal( string $className, @@ -131,6 +133,11 @@ class InjectableFactory return $obj; } + /** + * @param ReflectionClass $class + * @param ?array $with + * @return mixed[] + */ private function getConstructorInjectionList( ReflectionClass $class, ?array $with = null, @@ -155,6 +162,8 @@ class InjectableFactory } /** + * @param? ReflectionClass $class + * @param ?array $with * @return mixed */ private function getMethodParamInjection( @@ -239,6 +248,9 @@ class InjectableFactory ); } + /** + * @return mixed[] + */ private function getCallbackInjectionList(callable $callback): array { $injectionList = []; @@ -269,6 +281,7 @@ class InjectableFactory } if ($type === Binding::IMPLEMENTATION_CLASS_NAME) { + /** @var class-string $value */ return $this->createInternal($value, null, $bindingContainer); } @@ -285,6 +298,7 @@ class InjectableFactory } if ($type === Binding::FACTORY_CLASS_NAME) { + /** @var class-string $value */ /** @var Factory $factory */ $factory = $this->createInternal($value, null, $bindingContainer); @@ -294,6 +308,10 @@ class InjectableFactory throw new Error("InjectableFactory: Bad binding."); } + /** + * @param ReflectionClass $paramHintClass + * @param ReflectionClass $returnHintClass + */ private function areDependencyClassesMatching( ReflectionClass $paramHintClass, ReflectionClass $returnHintClass @@ -310,6 +328,10 @@ class InjectableFactory return false; } + /** + * @param ReflectionClass $class + * @param string[] $ignoreList + */ private function applyAwareInjections(ReflectionClass $class, object $obj, array $ignoreList = []): void { foreach ($class->getInterfaces() as $interface) { @@ -337,6 +359,9 @@ class InjectableFactory } } + /** + * @param ReflectionClass $class + */ private function classHasDependencySetter( ReflectionClass $class, string $name, @@ -387,8 +412,9 @@ class InjectableFactory * @deprecated Use create or createWith methods instead. * * @template T of object - * @phpstan-param class-string $className - * @phpstan-return T + * @param class-string $className + * @param ?array $with + * @return T */ public function createByClassName(string $className, ?array $with = null): object { @@ -397,7 +423,8 @@ class InjectableFactory /** * @deprecated - * @todo Remove in 6.4. + * @param ReflectionClass $class + * @todo Remove in 7.4. */ private function applyInjectable(ReflectionClass $class, object $obj): void {