Skip to content

Commit

Permalink
Simplify repository
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed May 18, 2024
1 parent 0d2ca1b commit 450b313
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 84 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/vendor
/composer.lock
/.phpunit.result.cache
/.phpunit.cache
/.php_cs.cache
/infection.log
/.php-cs-fixer.cache
26 changes: 0 additions & 26 deletions .php-cs-fixer.dist

This file was deleted.

35 changes: 7 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
{
"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",
"email": "hello@timacdonald.me",
"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"
Expand All @@ -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
}
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
level: 8
level: max
paths:
- src
- tests
31 changes: 20 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
failOnNotice="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
10 changes: 5 additions & 5 deletions src/HasParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
trait HasParameters
{
/**
* @param array $arguments
* @param array $arguments
*/
public static function with($arguments): string
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public static function with($arguments): string
}

/**
* @param array $arguments
* @param array $arguments
*/
public static function in($arguments): string
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -162,7 +162,7 @@ private static function parameters(): Collection
}

/**
* @param mixed $value
* @param mixed $value
*/
private static function castToString($value): string
{
Expand Down
13 changes: 6 additions & 7 deletions tests/HasParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Tests;

use const PHP_MAJOR_VERSION;

use Closure;
use ErrorException;
use Illuminate\Http\Request;
Expand All @@ -19,11 +21,6 @@
use TiMacDonald\Middleware\HasParameters;
use TypeError;

use const PHP_MAJOR_VERSION;

/**
* @small
*/
class HasParametersTest extends TestCase
{
public function testList(): void
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/Middleware/OptionalRequired.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 450b313

Please sign in to comment.