diff --git a/.gemini/GEMINI.md b/.gemini/GEMINI.md index 59a33e4..226a40d 100644 --- a/.gemini/GEMINI.md +++ b/.gemini/GEMINI.md @@ -15,9 +15,8 @@ This is the main FlightPHP core library for building fast, simple, and extensibl ## Development & Testing - Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher) - Run test server: `composer test-server` or `composer test-server-v2` -- Lint code: `composer lint` (uses phpstan/phpstan, level 6) -- Beautify code: `composer beautify` (uses squizlabs/php_codesniffer, PSR1) -- Check code style: `composer phpcs` +- Lint code & Check code style: `composer lint` (uses phpstan/phpstan, level 6) +- Beautify code: `composer format` (uses squizlabs/php_codesniffer, PSR1) - Test coverage: `composer test-coverage` ## Coding Standards diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 59a33e4..226a40d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -15,9 +15,8 @@ This is the main FlightPHP core library for building fast, simple, and extensibl ## Development & Testing - Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher) - Run test server: `composer test-server` or `composer test-server-v2` -- Lint code: `composer lint` (uses phpstan/phpstan, level 6) -- Beautify code: `composer beautify` (uses squizlabs/php_codesniffer, PSR1) -- Check code style: `composer phpcs` +- Lint code & Check code style: `composer lint` (uses phpstan/phpstan, level 6) +- Beautify code: `composer format` (uses squizlabs/php_codesniffer, PSR1) - Test coverage: `composer test-coverage` ## Coding Standards diff --git a/.gitignore b/.gitignore index cb308cf..22fbea8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,18 @@ -.idea/ -.vscode/ -vendor/ -composer.phar -composer.lock +*.sublime-* +.DS_Store .phpunit.result.cache -coverage/ -*.sublime* +.runway-config.json +.runway-creds.json +/.idea +/.vscode +/coverage +/vendor clover.xml +composer.lock +composer.phar phpcs.xml phpstan.neon phpunit.xml .runway-config.json .runway-creds.json -.DS_Store +.phpunit-watcher.yml diff --git a/composer.json b/composer.json index b443848..49bafaf 100644 --- a/composer.json +++ b/composer.json @@ -40,17 +40,18 @@ } }, "require-dev": { - "ext-mbstring": "*", "ext-fileinfo": "*", + "ext-mbstring": "*", "ext-pdo_sqlite": "*", "flightphp/container": "^1.3", "flightphp/runway": "^1.2", "league/container": "^4.2", "level-2/dice": "^4.0", "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", + "phpstan/phpstan": "^2.2", "phpunit/phpunit": "^9.6", "rregeer/phpunit-coverage-check": "^0.3.1", + "spatie/phpunit-watcher": "^1.23", "squizlabs/php_codesniffer": "^4.0" }, "config": { @@ -62,12 +63,8 @@ }, "scripts": { "test": "phpunit", - "test-watcher": [ - "phpunit-watcher || composer global require spatie/phpunit-watcher --dev", - "phpunit-watcher watch" - ], + "test-watcher": "phpunit-watcher watch", "test-coverage": [ - "rm -f clover.xml", "@putenv XDEBUG_MODE=coverage", "phpunit --coverage-html=coverage --coverage-clover=clover.xml", "coverage-check clover.xml 100" @@ -80,11 +77,6 @@ "echo \"Running Test Server\"", "@php -S localhost:8000 -t tests/server_v2" ], - "test-coverage:win": [ - "del clover.xml", - "phpunit --coverage-html=coverage --coverage-clover=clover.xml", - "coverage-check clover.xml 100" - ], "test-performance": [ "echo \"Running Performance Tests...\"", "@php -S localhost:8077 -t tests/performance/ > /dev/null 2>&1 & echo $! > server.pid", @@ -94,13 +86,16 @@ "rm server.pid", "echo \"Performance Tests Completed.\"" ], - "lint": "phpstan --no-progress --memory-limit=256M", - "beautify": "phpcbf", - "phpcs": "phpcs", + "lint": [ + "phpstan --no-progress --memory-limit=256M -n", + "phpcs" + ], + "format": "phpcbf -q", "post-install-cmd": [ "@php -r \"if (!file_exists('phpcs.xml')) copy('phpcs.xml.dist', 'phpcs.xml');\"", "@php -r \"if (!file_exists('phpstan.neon')) copy('phpstan.dist.neon', 'phpstan.neon');\"", - "@php -r \"if (!file_exists('phpunit.xml')) copy('phpunit.xml.dist', 'phpunit.xml');\"" + "@php -r \"if (!file_exists('phpunit.xml')) copy('phpunit.xml.dist', 'phpunit.xml');\"", + "@php -r \"if (!file_exists('.phpunit-watcher.yml')) copy('phpunit-watcher.yml', '.phpunit-watcher.yml');\"" ] }, "suggest": { diff --git a/flight/commands/RouteCommand.php b/flight/commands/RouteCommand.php index 0ff8dc0..b35f03e 100644 --- a/flight/commands/RouteCommand.php +++ b/flight/commands/RouteCommand.php @@ -99,7 +99,7 @@ class RouteCommand extends AbstractBaseCommand $arrayOfRoutes[] = [ 'Pattern' => $route->pattern, 'Methods' => implode(', ', $route->methods), - 'Alias' => $route->alias ?? '', + 'Alias' => $route->alias, 'Streamed' => $route->is_streamed ? 'Yes' : 'No', 'Middleware' => !empty($middlewares) ? implode(",", $middlewares) : '-' ]; diff --git a/flight/net/Request.php b/flight/net/Request.php index fdaa7cb..24f02a5 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -348,10 +348,8 @@ class Request * * @param string $header Header name. Can be caps, lowercase, or mixed. * @param string $default Default value if the header does not exist - * - * @return string */ - public static function getHeader(string $header, $default = ''): string + public static function getHeader(string $header, string $default = ''): string { $header = 'HTTP_' . strtoupper(str_replace('-', '_', $header)); return self::getVar($header, $default); @@ -380,10 +378,8 @@ class Request * * @param string $header Header name. Can be caps, lowercase, or mixed. * @param string $default Default value if the header does not exist - * - * @return string */ - public static function header(string $header, $default = ''): string + public static function header(string $header, string $default = ''): string { return self::getHeader($header, $default); } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 2c95c3e..6694874 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,26 +2,10 @@ - - - - - - - - - - - - - - - - - - - index.php flight tests + + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e69de29..0db8468 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -0,0 +1,7 @@ +parameters: + ignoreErrors: + - + rawMessage: 'Method flight\core\Dispatcher::parseStringClassAndMethod() should return array{class-string|object, string} but returns non-empty-list.' + identifier: return.type + count: 1 + path: flight/core/Dispatcher.php diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 57ab298..1d9e153 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/fadrian06/phpstan/add-schema/schema.json + includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon - phpstan-baseline.neon @@ -6,5 +8,4 @@ parameters: level: 6 paths: - flight - - index.php treatPhpDocTypesAsCertain: false diff --git a/phpunit-watcher.yml b/phpunit-watcher.yml index 5b5fe13..d942a41 100644 --- a/phpunit-watcher.yml +++ b/phpunit-watcher.yml @@ -1,13 +1,13 @@ hideManual: true -watch: - directories: - - tests - - flight - fileMask: '*.php' notifications: - passingTests: false failingTests: false + passingTests: false phpunit: - binaryPath: ./vendor/bin/phpunit arguments: '--stop-on-failure' + binaryPath: ./vendor/bin/phpunit timeout: 180 +watch: + directories: + - tests + - flight + fileMask: '*.php' diff --git a/tests/SimplePdoTest.php b/tests/SimplePdoTest.php index 4e97dd7..08f8e16 100644 --- a/tests/SimplePdoTest.php +++ b/tests/SimplePdoTest.php @@ -88,7 +88,7 @@ class SimplePdoTest extends TestCase public function testRunQueryWithoutParamsWithMaxQueryMetrics(): void { - $db = new class( + $db = new class ( 'sqlite::memory:', null, null, diff --git a/tests/named_arguments/FlightTest.php b/tests/named_arguments/FlightTest.php index 9053b02..26cd46f 100644 --- a/tests/named_arguments/FlightTest.php +++ b/tests/named_arguments/FlightTest.php @@ -74,7 +74,7 @@ final class FlightTest extends TestCase { $dateTime = new DateTimeImmutable(); - $controller = new class($dateTime) { + $controller = new class ($dateTime) { public function __construct(private DateTimeImmutable $dateTime) { //