Fixes --version and --help

This commit is contained in:
Nuno Maduro
2022-09-17 23:47:47 +01:00
parent 08b62f6633
commit 0e0e2adfbe
26 changed files with 511 additions and 86 deletions

View File

@ -35,16 +35,21 @@ final class Container
/**
* Gets a dependency from the container.
*
* @param class-string $id
* @return mixed
* @template TObject of object
*
* @param class-string<TObject> $id
* @return TObject
*/
public function get(string $id)
public function get(string $id): mixed
{
if (! array_key_exists($id, $this->instances)) {
$this->instances[$id] = $this->build($id);
}
return $this->instances[$id];
/** @var TObject $concrete */
$concrete = $this->instances[$id];
return $concrete;
}
/**
@ -58,9 +63,12 @@ final class Container
/**
* Tries to build the given instance.
*
* @param class-string $id
* @template TObject of object
*
* @param class-string<TObject> $id
* @return TObject
*/
private function build(string $id): object
private function build(string $id): mixed
{
$reflectionClass = new ReflectionClass($id);