update deps & install rector

This commit is contained in:
Dominik Liebler
2019-12-14 12:50:05 +01:00
parent 04acce6759
commit 579a5ac946
87 changed files with 2432 additions and 786 deletions

View File

@@ -2,17 +2,20 @@
namespace DesignPatterns\More\ServiceLocator;
use OutOfRangeException;
use InvalidArgumentException;
class ServiceLocator
{
/**
* @var string[][]
*/
private $services = [];
private array $services = [];
/**
* @var Service[]
*/
private $instantiated = [];
private array $instantiated = [];
public function addInstance(string $class, Service $service)
{
@@ -51,11 +54,11 @@ class ServiceLocator
$object = new $class($args[0], $args[1], $args[2]);
break;
default:
throw new \OutOfRangeException('Too many arguments given');
throw new OutOfRangeException('Too many arguments given');
}
if (!$object instanceof Service) {
throw new \InvalidArgumentException('Could not register service: is no instance of Service');
throw new InvalidArgumentException('Could not register service: is no instance of Service');
}
$this->instantiated[$class] = $object;

View File

@@ -8,10 +8,7 @@ use PHPUnit\Framework\TestCase;
class ServiceLocatorTest extends TestCase
{
/**
* @var ServiceLocator
*/
private $serviceLocator;
private ServiceLocator $serviceLocator;
public function setUp(): void
{