Merge master into autoload-rework

autoload-rework
copilot-swe-agent[bot] 14 hours ago committed by GitHub
commit 46e457f9c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,9 +15,8 @@ This is the main FlightPHP core library for building fast, simple, and extensibl
## Development & Testing ## Development & Testing
- Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher) - Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher)
- Run test server: `composer test-server` or `composer test-server-v2` - Run test server: `composer test-server` or `composer test-server-v2`
- Lint code: `composer lint` (uses phpstan/phpstan, level 6) - 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)
- Check code style: `composer phpcs`
- Test coverage: `composer test-coverage` - Test coverage: `composer test-coverage`
## Coding Standards ## Coding Standards

@ -15,9 +15,8 @@ This is the main FlightPHP core library for building fast, simple, and extensibl
## Development & Testing ## Development & Testing
- Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher) - Run tests: `composer test` (uses phpunit/phpunit and spatie/phpunit-watcher)
- Run test server: `composer test-server` or `composer test-server-v2` - Run test server: `composer test-server` or `composer test-server-v2`
- Lint code: `composer lint` (uses phpstan/phpstan, level 6) - 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)
- Check code style: `composer phpcs`
- Test coverage: `composer test-coverage` - Test coverage: `composer test-coverage`
## Coding Standards ## Coding Standards

19
.gitignore vendored

@ -1,15 +1,18 @@
.idea/ *.sublime-*
.vscode/ .DS_Store
vendor/
composer.phar
composer.lock
.phpunit.result.cache .phpunit.result.cache
coverage/ .runway-config.json
*.sublime* .runway-creds.json
/.idea
/.vscode
/coverage
/vendor
clover.xml clover.xml
composer.lock
composer.phar
phpcs.xml phpcs.xml
phpstan.neon phpstan.neon
phpunit.xml phpunit.xml
.runway-config.json .runway-config.json
.runway-creds.json .runway-creds.json
.DS_Store .phpunit-watcher.yml

@ -40,17 +40,18 @@
} }
}, },
"require-dev": { "require-dev": {
"ext-mbstring": "*",
"ext-fileinfo": "*", "ext-fileinfo": "*",
"ext-mbstring": "*",
"ext-pdo_sqlite": "*", "ext-pdo_sqlite": "*",
"flightphp/container": "^1.3", "flightphp/container": "^1.3",
"flightphp/runway": "^1.2", "flightphp/runway": "^1.2",
"league/container": "^4.2", "league/container": "^4.2",
"level-2/dice": "^4.0", "level-2/dice": "^4.0",
"phpstan/extension-installer": "^1.4", "phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1", "phpstan/phpstan": "^2.2",
"phpunit/phpunit": "^9.6", "phpunit/phpunit": "^9.6",
"rregeer/phpunit-coverage-check": "^0.3.1", "rregeer/phpunit-coverage-check": "^0.3.1",
"spatie/phpunit-watcher": "^1.23",
"squizlabs/php_codesniffer": "^4.0" "squizlabs/php_codesniffer": "^4.0"
}, },
"config": { "config": {
@ -62,12 +63,8 @@
}, },
"scripts": { "scripts": {
"test": "phpunit", "test": "phpunit",
"test-watcher": [ "test-watcher": "phpunit-watcher watch",
"phpunit-watcher || composer global require spatie/phpunit-watcher --dev",
"phpunit-watcher watch"
],
"test-coverage": [ "test-coverage": [
"rm -f clover.xml",
"@putenv XDEBUG_MODE=coverage", "@putenv XDEBUG_MODE=coverage",
"phpunit --coverage-html=coverage --coverage-clover=clover.xml", "phpunit --coverage-html=coverage --coverage-clover=clover.xml",
"coverage-check clover.xml 100" "coverage-check clover.xml 100"
@ -80,11 +77,6 @@
"echo \"Running Test Server\"", "echo \"Running Test Server\"",
"@php -S localhost:8000 -t tests/server_v2" "@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": [ "test-performance": [
"echo \"Running Performance Tests...\"", "echo \"Running Performance Tests...\"",
"@php -S localhost:8077 -t tests/performance/ > /dev/null 2>&1 & echo $! > server.pid", "@php -S localhost:8077 -t tests/performance/ > /dev/null 2>&1 & echo $! > server.pid",
@ -94,13 +86,16 @@
"rm server.pid", "rm server.pid",
"echo \"Performance Tests Completed.\"" "echo \"Performance Tests Completed.\""
], ],
"lint": "phpstan --no-progress --memory-limit=256M", "lint": [
"beautify": "phpcbf", "phpstan --no-progress --memory-limit=256M -n",
"phpcs": "phpcs", "phpcs"
],
"format": "phpcbf -q",
"post-install-cmd": [ "post-install-cmd": [
"@php -r \"if (!file_exists('phpcs.xml')) copy('phpcs.xml.dist', 'phpcs.xml');\"", "@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('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": { "suggest": {

@ -99,7 +99,7 @@ class RouteCommand extends AbstractBaseCommand
$arrayOfRoutes[] = [ $arrayOfRoutes[] = [
'Pattern' => $route->pattern, 'Pattern' => $route->pattern,
'Methods' => implode(', ', $route->methods), 'Methods' => implode(', ', $route->methods),
'Alias' => $route->alias ?? '', 'Alias' => $route->alias,
'Streamed' => $route->is_streamed ? 'Yes' : 'No', 'Streamed' => $route->is_streamed ? 'Yes' : 'No',
'Middleware' => !empty($middlewares) ? implode(",", $middlewares) : '-' 'Middleware' => !empty($middlewares) ? implode(",", $middlewares) : '-'
]; ];

@ -348,10 +348,8 @@ class Request
* *
* @param string $header Header name. Can be caps, lowercase, or mixed. * @param string $header Header name. Can be caps, lowercase, or mixed.
* @param string $default Default value if the header does not exist * @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)); $header = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
return self::getVar($header, $default); return self::getVar($header, $default);
@ -380,10 +378,8 @@ class Request
* *
* @param string $header Header name. Can be caps, lowercase, or mixed. * @param string $header Header name. Can be caps, lowercase, or mixed.
* @param string $default Default value if the header does not exist * @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); return self::getHeader($header, $default);
} }

@ -2,26 +2,10 @@
<ruleset <ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- <arg name="report" value="source" /> -->
<!-- <arg name="report" value="summary" /> -->
<!-- <arg name="report" value="diff" /> -->
<arg name="report" value="full" />
<arg name="report-width" value="80" />
<arg name="colors" /> <arg name="colors" />
<arg name="encoding" value="utf-8" />
<arg name="tab-width" value="4" />
<rule ref="PSR1">
</rule>
<rule ref="PSR2">
</rule>
<rule ref="PSR12">
<exclude name="PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword"/>
</rule>
<file>index.php</file>
<file>flight</file> <file>flight</file>
<file>tests</file> <file>tests</file>
<rule ref="PSR1" />
<rule ref="PSR2" />
<rule ref="PSR12" />
</ruleset> </ruleset>

@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
rawMessage: 'Method flight\core\Dispatcher::parseStringClassAndMethod() should return array{class-string|object, string} but returns non-empty-list<string>.'
identifier: return.type
count: 1
path: flight/core/Dispatcher.php

@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fadrian06/phpstan/add-schema/schema.json
includes: includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon - vendor/phpstan/phpstan/conf/bleedingEdge.neon
- phpstan-baseline.neon - phpstan-baseline.neon
@ -6,5 +8,4 @@ parameters:
level: 6 level: 6
paths: paths:
- flight - flight
- index.php
treatPhpDocTypesAsCertain: false treatPhpDocTypesAsCertain: false

@ -1,13 +1,13 @@
hideManual: true hideManual: true
watch:
directories:
- tests
- flight
fileMask: '*.php'
notifications: notifications:
passingTests: false
failingTests: false failingTests: false
passingTests: false
phpunit: phpunit:
binaryPath: ./vendor/bin/phpunit
arguments: '--stop-on-failure' arguments: '--stop-on-failure'
binaryPath: ./vendor/bin/phpunit
timeout: 180 timeout: 180
watch:
directories:
- tests
- flight
fileMask: '*.php'

Loading…
Cancel
Save