diff --git a/.gitignore b/.gitignore index b108781..8ae88e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ /vendor /composer.lock -/.phpunit.result.cache /.phpunit.cache -/.php_cs.cache -/infection.log -/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist b/.php-cs-fixer.dist deleted file mode 100644 index ab697b0..0000000 --- a/.php-cs-fixer.dist +++ /dev/null @@ -1,26 +0,0 @@ -in(__DIR__) - ->notName('**/Middleware/OptionalRequired.php') - ->exclude('vendor'); - -return (new PhpCsFixer\Config()) - ->setRules([ - '@PSR12' => true, - '@PSR12:risky' => true, - 'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true], - 'native_function_invocation' => true, - 'declare_strict_types' => true, - 'strict_comparison' => true, - 'strict_param' => true, - 'explicit_string_variable' => true, - 'trailing_comma_in_multiline' => true, - 'array_indentation' => true, - 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], - 'no_unreachable_default_argument_value' => false, - ]) - ->setRiskyAllowed(true) - ->setFinder($finder); diff --git a/composer.json b/composer.json index bb8ee21..bbc2d2a 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { "name": "timacdonald/has-parameters", "description": "A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.", - "license": "MIT", "keywords": [ "laravel", "middleware", "parameters", "arguments" ], + "license": "MIT", "authors": [ { "name": "Tim MacDonald", @@ -15,25 +15,15 @@ "homepage": "https://timacdonald.me" } ], - "support": { - "issues": "https://github.com/timacdonald/has-parameters/issues", - "source": "https://github.com/timacdonald/has-parameters/releases/latest", - "docs": "https://github.com/timacdonald/has-parameters/blob/master/readme.md" - }, "require": { "php": "^8.1", - "illuminate/support": "^10.0 || ^11.0", - "illuminate/http": "^10.0 || ^11.0" + "illuminate/http": "^10.0 || ^11.0", + "illuminate/support": "^10.0 || ^11.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.6", - "infection/infection": "^0.28.1", "orchestra/testbench": "^9.0", - "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^11.0" }, - "minimum-stability": "stable", - "prefer-stable": true, "autoload": { "psr-4": { "TiMacDonald\\Middleware\\": "src" @@ -48,20 +38,9 @@ "preferred-install": "dist", "sort-packages": true, "allow-plugins": { - "infection/extension-installer": true + "infection/extension-installer": false } }, - "scripts": { - "fix": [ - "./vendor/bin/php-cs-fixer fix" - ], - "lint": [ - "./vendor/bin/php-cs-fixer fix --dry-run", - "./vendor/bin/phpstan analyse" - ], - "test": [ - "./vendor/bin/phpunit", - "./vendor/bin/infection --threads=8" - ] - } + "minimum-stability": "stable", + "prefer-stable": true } diff --git a/phpstan.neon b/phpstan.neon index 1ff472c..1494f51 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ parameters: - level: 8 + level: max paths: - src + - tests diff --git a/phpunit.xml b/phpunit.xml index 4f14a2e..faa846b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,22 @@ - - - - tests - - - - - src - - + + + + tests + + + + + + src + + diff --git a/src/HasParameters.php b/src/HasParameters.php index dc59d60..b55cf04 100644 --- a/src/HasParameters.php +++ b/src/HasParameters.php @@ -14,7 +14,7 @@ trait HasParameters { /** - * @param array $arguments + * @param array $arguments */ public static function with($arguments): string { @@ -49,7 +49,7 @@ public static function with($arguments): string } /** - * @param array $arguments + * @param array $arguments */ public static function in($arguments): string { @@ -91,7 +91,7 @@ private static function parseArgumentList(Collection $arguments): Collection { return $arguments->map( /** - * @param mixed $argument + * @param mixed $argument */ static function ($argument): string { return self::castToString($argument); @@ -133,7 +133,7 @@ private static function parseVariadicArgument(ReflectionParameter $parameter, Co return $values->map( /** - * @param mixed $value + * @param mixed $value */ static function ($value) { return self::castToString($value); @@ -162,7 +162,7 @@ private static function parameters(): Collection } /** - * @param mixed $value + * @param mixed $value */ private static function castToString($value): string { diff --git a/tests/HasParametersTest.php b/tests/HasParametersTest.php index 01b5f22..07b7e03 100644 --- a/tests/HasParametersTest.php +++ b/tests/HasParametersTest.php @@ -4,6 +4,8 @@ namespace Tests; +use const PHP_MAJOR_VERSION; + use Closure; use ErrorException; use Illuminate\Http\Request; @@ -19,11 +21,6 @@ use TiMacDonald\Middleware\HasParameters; use TypeError; -use const PHP_MAJOR_VERSION; - -/** - * @small - */ class HasParametersTest extends TestCase { public function testList(): void @@ -358,7 +355,8 @@ public function testParameterAliasesDontConflictWithOtherAliasNames(): void $this->expectException(TypeError::class); $this->expectExceptionMessage('Two provided aliases cannot point to the same parameter.'); - $middleware = new class () { + $middleware = new class() + { use HasParameters; public function handle(Request $request, Closure $next, string $original, string $anotherOne): void @@ -387,7 +385,8 @@ public function testAliasesReferenceActualParameters(): void $this->expectException(TypeError::class); $this->expectExceptionMessage('Aliases must reference existing parameters.'); - $middleware = new class () { + $middleware = new class() + { use HasParameters; public function handle(Request $request, Closure $next, string $original): void diff --git a/tests/Middleware/OptionalRequired.php b/tests/Middleware/OptionalRequired.php index a88d5cd..314632f 100644 --- a/tests/Middleware/OptionalRequired.php +++ b/tests/Middleware/OptionalRequired.php @@ -4,12 +4,12 @@ namespace Tests\Middleware; +use const PHP_MAJOR_VERSION; + use Closure; use Illuminate\Http\Request; use TiMacDonald\Middleware\HasParameters; -use const PHP_MAJOR_VERSION; - // Cannot have optional parameter before required parameter in PHP >=8.0. if (PHP_MAJOR_VERSION < 8) { class OptionalRequired