Skip to content

Commit

Permalink
INJECTOR: Add type declarations to properties
Browse files Browse the repository at this point in the history
And also missing method return types

Signed-off-by: Remy Bos <[email protected]>
  • Loading branch information
sjokkateer committed May 9, 2022
1 parent 4b88fb2 commit 2b357c0
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@ class Injector implements InjectorInterface
{
/** @var DefinitionInterface */
protected $definition;

/** @var ContainerInterface */
protected $container;

/** @var DependencyResolverInterface */
protected $resolver;

/** @var ConfigInterface */
protected $config;
protected ContainerInterface $container;
protected DependencyResolverInterface $resolver;
protected ConfigInterface $config;

/** @var string[] */
protected $instantiationStack = [];
protected array $instantiationStack = [];

/**
* Constructor
Expand Down Expand Up @@ -113,11 +107,10 @@ public function canCreate(string $name): bool
*
* @param string $name Class name or service alias
* @param array $parameters Constructor parameters, keyed by the parameter name.
* @return object|null
* @throws ClassNotFoundException
* @throws RuntimeException
*/
public function create(string $name, array $parameters = [])
public function create(string $name, array $parameters = []): ?object
{
if (in_array($name, $this->instantiationStack)) {
throw new Exception\CircularDependencyException(sprintf(
Expand Down Expand Up @@ -145,11 +138,10 @@ public function create(string $name, array $parameters = [])
*
* @param string $name The type name to instantiate.
* @param array $params Constructor arguments, keyed by the parameter name.
* @return object
* @throws InvalidCallbackException
* @throws ClassNotFoundException
*/
protected function createInstance(string $name, array $params)
protected function createInstance(string $name, array $params): object
{
$class = $this->getClassName($name);

Expand Down

0 comments on commit 2b357c0

Please sign in to comment.