Skip to content

Commit

Permalink
added property typehints to Container
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 22, 2023
1 parent e721997 commit 523aa5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/DI/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ class Container
public $parameters = [];

/** @var string[] services name => type (complete list of available services) */
protected $types = [];
protected array $types = [];

/** @var string[] alias => service name */
protected $aliases = [];
protected array $aliases = [];

/** @var array[] tag name => service name => tag value */
protected $tags = [];
protected array $tags = [];

/** @var array[] type => level => services */
protected $wiring = [];
protected array $wiring = [];

/** @var object[] service name => instance */
private array $instances = [];
Expand Down
3 changes: 2 additions & 1 deletion src/DI/PhpGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function generate(string $className): Php\ClassType
foreach ($this->builder->exportMeta() as $key => $value) {
$class->addProperty($key)
->setProtected()
->setValue($value);
->setValue($value)
->setType(get_debug_type($value));
}

$definitions = $this->builder->getDefinitions();
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/Container.getServiceType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php';

class MyContainer extends Container
{
protected $aliases = [
protected array $aliases = [
'three' => 'one',
];

Expand Down

0 comments on commit 523aa5b

Please sign in to comment.