Fixed conflicting typehint in Loader::class

pull/528/head
fadrian06 1 year ago
parent 13fd2eb96a
commit 751f17be0d

@ -23,7 +23,7 @@ class Loader
{ {
/** /**
* Registered classes. * Registered classes.
* @var array<string, array{class-string, array<int, mixed>, ?callable}> $classes * @var array<string, array{class-string|Closure(): object, array<int, mixed>, ?callable}> $classes
*/ */
protected array $classes = []; protected array $classes = [];
@ -44,11 +44,11 @@ class Loader
* @template T of object * @template T of object
* *
* @param string $name Registry name * @param string $name Registry name
* @param class-string<T> $class Class name or function to instantiate class * @param class-string<T>|Closure(): T $class Class name or function to instantiate class
* @param array<int, mixed> $params Class initialization parameters * @param array<int, mixed> $params Class initialization parameters
* @param ?callable(T $instance): void $callback $callback Function to call after object instantiation * @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]); unset($this->instances[$name]);

@ -115,9 +115,8 @@ class EngineTest extends PHPUnit\Framework\TestCase
}; };
// doing this so we can overwrite some parts of the response // doing this so we can overwrite some parts of the response
$engine->getLoader()->register('response', function() { $engine->getLoader()->register('response', function() {
return new class extends \flight\net\Response { return new class extends Response {
public function __construct() {} public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): Response
{ {
return $this; return $this;
} }

Loading…
Cancel
Save