diff --git a/.gemini/GEMINI.md b/.gemini/GEMINI.md
index 4c6da83..226a40d 100644
--- a/.gemini/GEMINI.md
+++ b/.gemini/GEMINI.md
@@ -16,7 +16,7 @@ This is the main FlightPHP core library for building fast, simple, and extensibl
- Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher)
- Run test server: `composer test-server` or `composer test-server-v2`
- Lint code & Check code style: `composer lint` (uses phpstan/phpstan, level 6)
-- Beautify code: `composer beautify` (uses squizlabs/php_codesniffer, PSR1)
+- 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 4c6da83..226a40d 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -16,7 +16,7 @@ This is the main FlightPHP core library for building fast, simple, and extensibl
- Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher)
- Run test server: `composer test-server` or `composer test-server-v2`
- Lint code & Check code style: `composer lint` (uses phpstan/phpstan, level 6)
-- Beautify code: `composer beautify` (uses squizlabs/php_codesniffer, PSR1)
+- Beautify code: `composer format` (uses squizlabs/php_codesniffer, PSR1)
- Test coverage: `composer test-coverage`
## Coding Standards
diff --git a/.gitignore b/.gitignore
index cb308cf..ee01cae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ phpunit.xml
.runway-config.json
.runway-creds.json
.DS_Store
+.phpunit-watcher.yml
diff --git a/composer.json b/composer.json
index 17c4cda..611c2d2 100644
--- a/composer.json
+++ b/composer.json
@@ -45,17 +45,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": {
@@ -67,10 +68,7 @@
},
"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",
@@ -103,11 +101,12 @@
"phpstan --no-progress --memory-limit=256M -n",
"phpcs"
],
- "beautify": "phpcbf",
+ "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 6593450..0d5abff 100644
--- a/tests/named-arguments/FlightTest.php
+++ b/tests/named-arguments/FlightTest.php
@@ -75,7 +75,7 @@ final class FlightTest extends TestCase
{
$dateTime = new DateTimeImmutable();
- $controller = new class($dateTime) {
+ $controller = new class ($dateTime) {
public function __construct(private DateTimeImmutable $dateTime)
{
//