diff --git a/flight/core/Loader.php b/flight/core/Loader.php index 62e3de8..8dbf843 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -23,7 +23,7 @@ class Loader { /** * Registered classes. - * @var array, ?callable}> $classes + * @var array, ?callable}> $classes */ protected array $classes = []; @@ -44,11 +44,11 @@ class Loader * @template T of object * * @param string $name Registry name - * @param class-string $class Class name or function to instantiate class + * @param class-string|Closure(): T $class Class name or function to instantiate class * @param array $params Class initialization parameters * @param ?callable(T $instance): void $callback $callback Function to call after object instantiation */ - public function register(string $name, string $class, array $params = [], ?callable $callback = null): void + public function register(string $name, $class, array $params = [], ?callable $callback = null): void { unset($this->instances[$name]); diff --git a/tests/EngineTest.php b/tests/EngineTest.php index 0a13fcb..3f5b2f5 100644 --- a/tests/EngineTest.php +++ b/tests/EngineTest.php @@ -115,9 +115,8 @@ class EngineTest extends PHPUnit\Framework\TestCase }; // doing this so we can overwrite some parts of the response $engine->getLoader()->register('response', function() { - return new class extends \flight\net\Response { - public function __construct() {} - public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response + return new class extends Response { + public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self { return $this; }