Merge branch 'master' into combine-phpstan-and-phpcs-in-lint-script

pull/705/head
n0nag0n 18 hours ago committed by GitHub
commit 68f0942127
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 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 & Check code style: `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)
- Test coverage: `composer test-coverage` - Test coverage: `composer test-coverage`
## Coding Standards ## Coding Standards

@ -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 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 & Check code style: `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)
- Test coverage: `composer test-coverage` - Test coverage: `composer test-coverage`
## Coding Standards ## Coding Standards

1
.gitignore vendored

@ -13,3 +13,4 @@ phpunit.xml
.runway-config.json .runway-config.json
.runway-creds.json .runway-creds.json
.DS_Store .DS_Store
.phpunit-watcher.yml

@ -45,17 +45,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": {
@ -67,10 +68,7 @@
}, },
"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", "rm -f clover.xml",
"@putenv XDEBUG_MODE=coverage", "@putenv XDEBUG_MODE=coverage",
@ -103,11 +101,12 @@
"phpstan --no-progress --memory-limit=256M -n", "phpstan --no-progress --memory-limit=256M -n",
"phpcs" "phpcs"
], ],
"beautify": "phpcbf", "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'

@ -88,7 +88,7 @@ class SimplePdoTest extends TestCase
public function testRunQueryWithoutParamsWithMaxQueryMetrics(): void public function testRunQueryWithoutParamsWithMaxQueryMetrics(): void
{ {
$db = new class( $db = new class (
'sqlite::memory:', 'sqlite::memory:',
null, null,
null, null,

@ -75,7 +75,7 @@ final class FlightTest extends TestCase
{ {
$dateTime = new DateTimeImmutable(); $dateTime = new DateTimeImmutable();
$controller = new class($dateTime) { $controller = new class ($dateTime) {
public function __construct(private DateTimeImmutable $dateTime) public function __construct(private DateTimeImmutable $dateTime)
{ {
// //

Loading…
Cancel
Save