diff --git a/application/Espo/Classes/AppInfo/Binding.php b/application/Espo/Classes/AppInfo/Binding.php index feafbf3a7f..02f48ba0cf 100644 --- a/application/Espo/Classes/AppInfo/Binding.php +++ b/application/Espo/Classes/AppInfo/Binding.php @@ -29,16 +29,14 @@ namespace Espo\Classes\AppInfo; -use Espo\Core\{ - Utils\Module, - Binding\EspoBindingLoader, - Binding\Binding as BindingItem, - Console\Command\Params, -}; +use Espo\Core\Binding\Binding as BindingItem; +use Espo\Core\Binding\EspoBindingLoader; +use Espo\Core\Console\Command\Params; +use Espo\Core\Utils\Module; class Binding { - private $module; + private Module $module; public function __construct(Module $module) { diff --git a/application/Espo/Core/Binding/Binder.php b/application/Espo/Core/Binding/Binder.php index 163373f3f6..586b9fcf49 100644 --- a/application/Espo/Core/Binding/Binder.php +++ b/application/Espo/Core/Binding/Binder.php @@ -45,7 +45,7 @@ class Binder * Bind an interface to an implementation. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $implementationClassName An implementation class name. + * @param class-string $implementationClassName An implementation class name. */ public function bindImplementation(string $key, string $implementationClassName): self { @@ -117,7 +117,7 @@ class Binder * Bind an interface to a factory. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $factoryClassName A factory class name. + * @param class-string $factoryClassName A factory class name. */ public function bindFactory(string $key, string $factoryClassName): self { @@ -134,7 +134,7 @@ class Binder /** * Creates a contextual binder and pass it as an argument of a callback. * - * @param string $className A context. + * @param class-string $className A context. * @param Closure(ContextualBinder): void $callback A callback with a `ContextualBinder` argument. */ public function inContext(string $className, Closure $callback): self @@ -149,7 +149,7 @@ class Binder /** * Creates a contextual binder. * - * @param string $className A context. + * @param class-string $className A context. */ public function for(string $className): ContextualBinder { diff --git a/application/Espo/Core/Binding/BindingContainerBuilder.php b/application/Espo/Core/Binding/BindingContainerBuilder.php index abd16bcd8c..cba1d0c4e7 100644 --- a/application/Espo/Core/Binding/BindingContainerBuilder.php +++ b/application/Espo/Core/Binding/BindingContainerBuilder.php @@ -46,7 +46,7 @@ class BindingContainerBuilder * Bind an interface to an implementation. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $implementationClassName An implementation class name. + * @param class-string $implementationClassName An implementation class name. */ public function bindImplementation(string $key, string $implementationClassName): self { @@ -98,7 +98,7 @@ class BindingContainerBuilder * Bind an interface to a factory. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $factoryClassName A factory class name. + * @param class-string $factoryClassName A factory class name. */ public function bindFactory(string $key, string $factoryClassName): self { @@ -110,7 +110,7 @@ class BindingContainerBuilder /** * Creates a contextual binder and pass it as an argument of a callback. * - * @param string $className A context. + * @param class-string $className A context. * @param Closure(ContextualBinder): void $callback A callback with a `ContextualBinder` argument. */ public function inContext(string $className, Closure $callback): self diff --git a/application/Espo/Core/Binding/BindingData.php b/application/Espo/Core/Binding/BindingData.php index e162e51a82..0a9d0dcd5c 100644 --- a/application/Espo/Core/Binding/BindingData.php +++ b/application/Espo/Core/Binding/BindingData.php @@ -57,6 +57,9 @@ class BindingData $this->global->$key = $binding; } + /** + * @param class-string $className + */ public function hasContext(string $className, string $key): bool { if (!property_exists($this->context, $className)) { @@ -70,6 +73,9 @@ class BindingData return true; } + /** + * @param class-string $className + */ public function getContext(string $className, string $key): Binding { if (!$this->hasContext($className, $key)) { @@ -108,10 +114,11 @@ class BindingData } /** - * @return string[] + * @return class-string[] */ public function getContextList(): array { + /** @var class-string[] */ return array_keys( get_object_vars($this->context) ); diff --git a/application/Espo/Core/Binding/ContextualBinder.php b/application/Espo/Core/Binding/ContextualBinder.php index 9425588e1d..fc81162388 100644 --- a/application/Espo/Core/Binding/ContextualBinder.php +++ b/application/Espo/Core/Binding/ContextualBinder.php @@ -34,8 +34,12 @@ use LogicException; class ContextualBinder { private BindingData $data; + /** @var class-string */ private string $className; + /** + * @param class-string $className + */ public function __construct(BindingData $data, string $className) { $this->data = $data; @@ -46,7 +50,7 @@ class ContextualBinder * Bind an interface to an implementation. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $implementationClassName An implementation class name. + * @param class-string $implementationClassName An implementation class name. */ public function bindImplementation(string $key, string $implementationClassName): self { @@ -142,7 +146,7 @@ class ContextualBinder * Bind an interface to a factory. * * @param string $key An interface or interface with a parameter name (`Interface $name`). - * @param string $factoryClassName A factory class name. + * @param class-string $factoryClassName A factory class name. */ public function bindFactory(string $key, string $factoryClassName): self { diff --git a/application/Espo/Core/Binding/EspoBindingLoader.php b/application/Espo/Core/Binding/EspoBindingLoader.php index e3c7cbba28..da8d2053a6 100644 --- a/application/Espo/Core/Binding/EspoBindingLoader.php +++ b/application/Espo/Core/Binding/EspoBindingLoader.php @@ -45,7 +45,6 @@ class EspoBindingLoader implements BindingLoader public function load(): BindingData { $data = new BindingData(); - $binder = new Binder($data); (new Binding())->process($binder); diff --git a/application/Espo/Core/ORM/EntityFactory.php b/application/Espo/Core/ORM/EntityFactory.php index b825a2ccaa..238d6fc148 100644 --- a/application/Espo/Core/ORM/EntityFactory.php +++ b/application/Espo/Core/ORM/EntityFactory.php @@ -29,34 +29,26 @@ namespace Espo\Core\ORM; -use Espo\Core\{ - Utils\ClassFinder, - InjectableFactory, - ORM\Entity as BaseEntity, - Binding\BindingContainer, - Binding\BindingData, - Binding\Binder, -}; +use Espo\Core\Binding\Binder; +use Espo\Core\Binding\BindingContainer; +use Espo\Core\Binding\BindingData; +use Espo\Core\InjectableFactory; +use Espo\Core\ORM\Entity as BaseEntity; +use Espo\Core\Utils\ClassFinder; -use Espo\ORM\{ - Entity, - EntityManager, - EntityFactory as EntityFactoryInterface, - Value\ValueAccessorFactory, -}; +use Espo\ORM\Entity; +use Espo\ORM\EntityFactory as EntityFactoryInterface; +use Espo\ORM\EntityManager; +use Espo\ORM\Value\ValueAccessorFactory; use RuntimeException; class EntityFactory implements EntityFactoryInterface { private ClassFinder $classFinder; - private Helper $helper; - private InjectableFactory $injectableFactory; - private ?EntityManager $entityManager = null; - private ?ValueAccessorFactory $valueAccessorFactory = null; public function __construct(ClassFinder $classFinder, Helper $helper, InjectableFactory $injectableFactory) @@ -67,11 +59,11 @@ class EntityFactory implements EntityFactoryInterface } /** - * @return ?class-string<\Espo\ORM\Entity> + * @return ?class-string */ private function getClassName(string $entityType): ?string { - /** @var ?class-string<\Espo\ORM\Entity> */ + /** @var ?class-string */ return $this->classFinder->find('Entities', $entityType); } @@ -117,7 +109,8 @@ class EntityFactory implements EntityFactoryInterface } /** - * @param array $defs + * @param class-string $className + * @param array $defs */ private function getBindingContainer(string $className, string $entityType, array $defs): BindingContainer {