diff --git a/flight/Flight.php b/flight/Flight.php index 39fe83e..25d650a 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -61,9 +61,18 @@ class Flight { /** * Framework engine. + * + * @var Engine $engine */ private static Engine $engine; + /** + * Whether or not the app has been initialized + * + * @var boolean + */ + private static bool $initialized = false; + /** * Don't allow object instantiation * @@ -98,7 +107,7 @@ class Flight * @param ?Closure(T $instance): void $callback Perform actions with the instance * @return void */ - static function register($name, $class, $params = [], $callback = null) + public static function register($name, $class, $params = [], $callback = null) { static::__callStatic('register', func_get_args()); } @@ -125,14 +134,12 @@ class Flight */ public static function app(): Engine { - static $initialized = false; - - if (!$initialized) { + if (!self::$initialized) { require_once __DIR__ . '/autoload.php'; self::setEngine(new Engine()); - $initialized = true; + self::$initialized = true; } return self::$engine; diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index e31d3f9..853a8f7 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -43,7 +43,7 @@ class Dispatcher * * @return mixed|null Output of callback */ - final public function run(string $name, array $params = []) + public function run(string $name, array $params = []) { $output = ''; @@ -70,7 +70,7 @@ class Dispatcher * @param string $name Event name * @param callable $callback Callback function */ - final public function set(string $name, callable $callback): void + public function set(string $name, callable $callback): void { $this->events[$name] = $callback; } @@ -82,7 +82,7 @@ class Dispatcher * * @return callable $callback Callback function */ - final public function get(string $name): ?callable + public function get(string $name): ?callable { return $this->events[$name] ?? null; } @@ -94,7 +94,7 @@ class Dispatcher * * @return bool Event status */ - final public function has(string $name): bool + public function has(string $name): bool { return isset($this->events[$name]); } @@ -105,7 +105,7 @@ class Dispatcher * * @param string|null $name Event name */ - final public function clear(?string $name = null): void + public function clear(?string $name = null): void { if (null !== $name) { unset($this->events[$name]); @@ -123,7 +123,7 @@ class Dispatcher * @param string $type Filter type * @param callable $callback Callback function */ - final public function hook(string $name, string $type, callable $callback): void + public function hook(string $name, string $type, callable $callback): void { $this->filters[$name][$type][] = $callback; } @@ -137,7 +137,7 @@ class Dispatcher * * @throws Exception */ - final public function filter(array $filters, array &$params, &$output): void + public function filter(array $filters, array &$params, &$output): void { $args = [&$params, &$output]; foreach ($filters as $callback) { @@ -204,7 +204,7 @@ class Dispatcher /** * Resets the object to the initial state. */ - final public function reset(): void + public function reset(): void { $this->events = []; $this->filters = []; diff --git a/flight/net/Request.php b/flight/net/Request.php index 207df19..0f2cef9 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -37,7 +37,7 @@ use flight\util\Collection; * - **accept** - HTTP accept parameters * - **proxy_ip** - Proxy IP address of the client */ -final class Request +class Request { /** * @var string URL being requested diff --git a/flight/net/Route.php b/flight/net/Route.php index 78b69a1..0ff17fa 100644 --- a/flight/net/Route.php +++ b/flight/net/Route.php @@ -15,7 +15,7 @@ namespace flight\net; * an assigned callback function. The Router tries to match the * requested URL against a series of URL patterns. */ -final class Route +class Route { /** * @var string URL pattern diff --git a/flight/util/Collection.php b/flight/util/Collection.php index 39c03bc..f47b43e 100644 --- a/flight/util/Collection.php +++ b/flight/util/Collection.php @@ -21,7 +21,7 @@ use JsonSerializable; * @implements ArrayAccess * @implements Iterator */ -final class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable +class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable { /** * Collection data. diff --git a/tests/EngineTest.php b/tests/EngineTest.php index 62fbf70..0a13fcb 100644 --- a/tests/EngineTest.php +++ b/tests/EngineTest.php @@ -227,7 +227,7 @@ class EngineTest extends PHPUnit\Framework\TestCase public function testEtagSimple() { $engine = new Engine(); $engine->etag('etag'); - $this->assertEquals('etag', $engine->response()->headers()['ETag']); + $this->assertEquals('"etag"', $engine->response()->headers()['ETag']); } public function testEtagWithHttpIfNoneMatch() { @@ -241,7 +241,7 @@ class EngineTest extends PHPUnit\Framework\TestCase }; $_SERVER['HTTP_IF_NONE_MATCH'] = 'etag'; $engine->etag('etag'); - $this->assertEquals('etag', $engine->response()->headers()['ETag']); + $this->assertEquals('"etag"', $engine->response()->headers()['ETag']); $this->assertEquals(304, $engine->response()->status()); }