From 854a280a02d6c0d4a20e81c6ba6dff1360e446d3 Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Wed, 19 Aug 2026 17:13:25 +0200 Subject: [PATCH] [TASK] allow and test PHP 8.5 + drop 8.1 --- .github/workflows/main.yml | 2 +- composer.json | 5 ++- fractor.php | 18 ++++++++ grumphp.yml | 4 ++ psalm.xml | 11 ++--- rector.php | 8 ++-- src/Conditional/ArithmeticExpression.php | 18 -------- src/Conditional/ShellExpression.php | 9 ---- src/Conditional/StringExpression.php | 21 --------- src/ShellBuilder.php | 12 ----- src/ShellCommand.php | 5 --- tests/ShellBuilderTest.php | 6 +-- tests/ShellCommandTest.php | 2 +- tests/phpunit.xml | 56 ++++++++++-------------- 14 files changed, 60 insertions(+), 117 deletions(-) create mode 100644 fractor.php diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27959b4..426523c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.1', '8.2', '8.3', '8.4'] + php: ['8.2', '8.3', '8.4', '8.5'] name: 'PHP ${{ matrix.php }}' steps: - run: git config --global --add safe.directory /__w/ShellCommandBuilder/ShellCommandBuilder diff --git a/composer.json b/composer.json index 45e495b..30faf0c 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ } ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "ext-json": "*" }, "require-dev": { "infection/infection": "^0.28.1 || ^0.29.14", "phpunit/phpunit": "^10.0 || ^12.0", - "pluswerk/grumphp-config": "^7 || ^10", + "pluswerk/grumphp-config": "^11", "spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf" }, "minimum-stability": "stable", @@ -32,6 +32,7 @@ }, "config": { "allow-plugins": { + "a9f/fractor-extension-installer": true, "ergebnis/composer-normalize": true, "infection/extension-installer": true, "phpro/grumphp": true, diff --git a/fractor.php b/fractor.php new file mode 100644 index 0000000..00d33d1 --- /dev/null +++ b/fractor.php @@ -0,0 +1,18 @@ +withPaths(array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null")))) + ->withSets([ + ...FractorSettings::sets(true), + ]) + ->withRules([ + ...FractorSettings::rules(), + ]) + ->withOptions([ + ...FractorSettings::options(), + ]); diff --git a/grumphp.yml b/grumphp.yml index 3a60a5a..0ba0180 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -14,3 +14,7 @@ parameters: convention.rector_config: rector.php convention.rector_clear-cache: false convention.phpstan_level: null + convention.fractor_ignore_pattern: { } + convention.fractor_enable: true + convention.fractor_config: fractor.php + convention.fractor_clear-cache: false diff --git a/psalm.xml b/psalm.xml index 617f63d..5673445 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,16 +1,11 @@ + xmlns="https://getpsalm.org/schema/config" totallyTyped="true" errorLevel="1" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"> - + - + diff --git a/rector.php b/rector.php index 0f267f7..1dd8470 100644 --- a/rector.php +++ b/rector.php @@ -3,8 +3,8 @@ declare(strict_types=1); use PLUS\GrumPHPConfig\RectorSettings; -use Rector\Config\RectorConfig; use Rector\Caching\ValueObject\Storage\FileCacheStorage; +use Rector\Config\RectorConfig; return static function (RectorConfig $rectorConfig): void { $rectorConfig->parallel(); @@ -21,8 +21,7 @@ $rectorConfig->sets( [ ...RectorSettings::sets(true), - ...RectorSettings::setsTypo3(false), - ] + ], ); // remove some rules @@ -30,13 +29,12 @@ $rectorConfig->skip( [ ...RectorSettings::skip(), - ...RectorSettings::skipTypo3(), /** * rector should not touch these files */ //__DIR__ . '/src/Example', //__DIR__ . '/src/Example.php', - ] + ], ); }; diff --git a/src/Conditional/ArithmeticExpression.php b/src/Conditional/ArithmeticExpression.php index 4e619cf..ee2268b 100644 --- a/src/Conditional/ArithmeticExpression.php +++ b/src/Conditional/ArithmeticExpression.php @@ -14,9 +14,6 @@ public static function create(bool $useBashBrackets = true, bool $negateExpressi return new self($useBashBrackets, $negateExpression); } - /** - * @return $this - */ public function equal(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_EQUAL; @@ -25,9 +22,6 @@ public function equal(ShellInterface|string $arg1, ShellInterface|string $arg2): return $this; } - /** - * @return $this - */ public function notEqual(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_NOT_EQUAL; @@ -36,9 +30,6 @@ public function notEqual(ShellInterface|string $arg1, ShellInterface|string $arg return $this; } - /** - * @return $this - */ public function less(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_LESS_THAN; @@ -47,9 +38,6 @@ public function less(ShellInterface|string $arg1, ShellInterface|string $arg2): return $this; } - /** - * @return $this - */ public function greater(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_GREATER_THAN; @@ -58,9 +46,6 @@ public function greater(ShellInterface|string $arg1, ShellInterface|string $arg2 return $this; } - /** - * @return $this - */ public function lessEqual(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_LESS_EQUAL; @@ -69,9 +54,6 @@ public function lessEqual(ShellInterface|string $arg1, ShellInterface|string $ar return $this; } - /** - * @return $this - */ public function greaterEqual(ShellInterface|string $arg1, ShellInterface|string $arg2): self { $this->operator = ConditionalOperator::ARTITH_GREATER_EQUAL; diff --git a/src/Conditional/ShellExpression.php b/src/Conditional/ShellExpression.php index c84499f..1ed86c4 100644 --- a/src/Conditional/ShellExpression.php +++ b/src/Conditional/ShellExpression.php @@ -16,9 +16,6 @@ public static function create(bool $useBashBrackets = true, bool $negateExpressi return new self($useBashBrackets, $negateExpression); } - /** - * @return $this - */ public function isOptnameEnabled(ShellInterface|string $optname): self { $this->operator = ConditionalOperator::SHELL_OPTNAME_ENABLED; @@ -26,9 +23,6 @@ public function isOptnameEnabled(ShellInterface|string $optname): self return $this; } - /** - * @return $this - */ public function isVariableSet(ShellInterface|string $variable): self { $this->operator = ConditionalOperator::SHELL_VARNAME_SET; @@ -36,9 +30,6 @@ public function isVariableSet(ShellInterface|string $variable): self return $this; } - /** - * @return $this - */ public function isVariableSetWithNamedReference(ShellInterface|string $variable): self { $this->operator = ConditionalOperator::SHELL_VARNAME_SET_NAMED_REFERENCE; diff --git a/src/Conditional/StringExpression.php b/src/Conditional/StringExpression.php index 557e806..05df2f8 100644 --- a/src/Conditional/StringExpression.php +++ b/src/Conditional/StringExpression.php @@ -16,9 +16,6 @@ public static function create(bool $useBashBrackets = true, bool $negateExpressi return new self($useBashBrackets, $negateExpression); } - /** - * @return $this - */ public function lenghtZero(ShellInterface|string $string): self { $this->operator = ConditionalOperator::STRING_LENGHT_ZERO; @@ -26,9 +23,6 @@ public function lenghtZero(ShellInterface|string $string): self return $this; } - /** - * @return $this - */ public function lengthNotZero(ShellInterface|string $string): self { $this->operator = ConditionalOperator::STRING_LENGHT_NOT_ZERO; @@ -36,9 +30,6 @@ public function lengthNotZero(ShellInterface|string $string): self return $this; } - /** - * @return $this - */ public function eq(ShellInterface|string $stringA, ShellInterface|string $stringB): self { $this->operator = ConditionalOperator::STRING_EQUAL; @@ -47,9 +38,6 @@ public function eq(ShellInterface|string $stringA, ShellInterface|string $string return $this; } - /** - * @return $this - */ public function equal(ShellInterface|string $stringA, ShellInterface|string $stringB): self { $this->operator = ConditionalOperator::STRING_EQUAL_BASH; @@ -59,9 +47,6 @@ public function equal(ShellInterface|string $stringA, ShellInterface|string $str return $this; } - /** - * @return $this - */ public function notEqual(ShellInterface|string $stringA, ShellInterface|string $stringB): self { $this->operator = ConditionalOperator::STRING_NOT_EQUAL; @@ -70,9 +55,6 @@ public function notEqual(ShellInterface|string $stringA, ShellInterface|string $ return $this; } - /** - * @return $this - */ public function sortsBefore(ShellInterface|string $stringA, ShellInterface|string $stringB): self { $this->operator = ConditionalOperator::STRING_SORTS_BEFORE; @@ -81,9 +63,6 @@ public function sortsBefore(ShellInterface|string $stringA, ShellInterface|strin return $this; } - /** - * @return $this - */ public function sortsAfter(ShellInterface|string $stringA, ShellInterface|string $stringB): self { $this->operator = ConditionalOperator::STRING_SORTS_AFTER; diff --git a/src/ShellBuilder.php b/src/ShellBuilder.php index 1cb89ed..c9d5e3a 100644 --- a/src/ShellBuilder.php +++ b/src/ShellBuilder.php @@ -68,7 +68,6 @@ public function runAsynchronously(bool $isAsync = true, string $name = ''): self /** * @param bool $escape is the value instance of ShellInterface, then this variable is automatically false - * @return $this * @throws ShellBuilderException */ public function addVariable(string $variable, ShellInterface|string $value, bool $useBackticks = false, bool $escape = true, bool $noSemicolon = false): self @@ -95,7 +94,6 @@ public function removeVariable(string $variable): self } /** - * @return $this * @throws ShellBuilderException */ public function add(ShellInterface|string ...$commands): self @@ -108,7 +106,6 @@ public function add(ShellInterface|string ...$commands): self } /** - * @return $this * @throws ShellBuilderException */ public function addSingle(ShellInterface|string $command, bool $raw = false): self @@ -124,7 +121,6 @@ public function addSingle(ShellInterface|string $command, bool $raw = false): se } /** - * @return $this * @throws ShellBuilderException */ public function and(ShellInterface|string $command): self @@ -134,7 +130,6 @@ public function and(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function or(ShellInterface|string $command): self @@ -144,7 +139,6 @@ public function or(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function async(ShellInterface|string $command = ''): self @@ -154,7 +148,6 @@ public function async(ShellInterface|string $command = ''): self } /** - * @return $this * @throws ShellBuilderException */ public function pipe(ShellInterface|string $command): self @@ -164,7 +157,6 @@ public function pipe(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function pipeWithForward(ShellInterface|string $command): self @@ -174,7 +166,6 @@ public function pipeWithForward(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function redirectOutput(ShellInterface|string $command, bool $append = false): self @@ -185,7 +176,6 @@ public function redirectOutput(ShellInterface|string $command, bool $append = fa } /** - * @return $this * @throws ShellBuilderException */ public function redirectInput(ShellInterface|string $command): self @@ -196,7 +186,6 @@ public function redirectInput(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function redirectError(ShellInterface|string $command): self @@ -207,7 +196,6 @@ public function redirectError(ShellInterface|string $command): self } /** - * @return $this * @throws ShellBuilderException */ public function redirect(ShellInterface|string $command, bool $toLeft = true): self diff --git a/src/ShellCommand.php b/src/ShellCommand.php index 322ec73..e9ba48e 100644 --- a/src/ShellCommand.php +++ b/src/ShellCommand.php @@ -90,7 +90,6 @@ public function addOption(string $option, ShellInterface|string $value = '', boo /** * @throws ShellBuilderException - * @return $this */ public function addArgument(ShellInterface|string $argument, bool $escapeArgument = true): self { @@ -102,7 +101,6 @@ public function addArgument(ShellInterface|string $argument, bool $escapeArgumen * This is an alias for argument, that automatically escapes the argument. * It does in the end does not provide any additional functionality * - * @return $this * @throws ShellBuilderException */ public function addSubCommand(ShellInterface $argument): self @@ -120,9 +118,6 @@ public function addNoSpaceArgument(ShellInterface|string $argument): self return $this->add($word, false); } - /** - * @return $this - */ private function add(ShellWord $word, bool $escapeArgument, bool $withAssignOperator = false): self { $word->setEscape($escapeArgument); diff --git a/tests/ShellBuilderTest.php b/tests/ShellBuilderTest.php index d3a8bf8..17401f1 100644 --- a/tests/ShellBuilderTest.php +++ b/tests/ShellBuilderTest.php @@ -688,13 +688,13 @@ public function testCondiditionalArguments(): void $builder = ShellBuilder::new() ->if(false, static fn(ShellBuilder $builder): ShellBuilder => $builder->add('echo')) ->ifThis(static fn(ShellBuilder $builder): bool => $builder->hasCommands() === false, static fn(ShellBuilder $builder): ShellBuilder => $builder->add('print')); - static::assertEquals('print', (string)$builder); + self::assertEquals('print', (string)$builder); // if true $builder = ShellBuilder::new() ->if(true, static fn(ShellBuilder $builder): ShellBuilder => $builder->add('echo')) ->ifThis(static fn(ShellBuilder $builder): bool => $builder->hasCommands() === false, static fn(ShellBuilder $builder): ShellBuilder => $builder->add('print')); - static::assertEquals('echo', (string)$builder); + self::assertEquals('echo', (string)$builder); } public function testComplexCondiditionalArguments(): void @@ -706,7 +706,7 @@ public function testComplexCondiditionalArguments(): void static fn(ShellBuilder $builder): ShellBuilder => $builder->add('awk') ) ->ifThis(static fn(ShellBuilder $builder): bool => $builder->hasCommands() === false, static fn(ShellBuilder $builder): ShellBuilder => $builder->add('print'), static fn(ShellBuilder $builder): ShellBuilder => $builder->and('print')); - static::assertEquals('awk && print', (string)$builder); + self::assertEquals('awk && print', (string)$builder); } public function testComplexCondiditionalArgumentsWithWrongArguments(): void diff --git a/tests/ShellCommandTest.php b/tests/ShellCommandTest.php index 69f4523..358027c 100644 --- a/tests/ShellCommandTest.php +++ b/tests/ShellCommandTest.php @@ -178,7 +178,7 @@ public function testConditionalArguments(): void $command = ShellBuilder::command('test') ->if(false, static fn(ShellCommand $command): ShellCommand => $command->addOption('f', 'false')) ->if(true, static fn(ShellCommand $command): ShellCommand => $command->addOption('t', 'true')); - static::assertEquals((string)$command, "test --t 'true'"); + self::assertEquals((string)$command, "test --t 'true'"); } public function testUnEscapedOption(): void diff --git a/tests/phpunit.xml b/tests/phpunit.xml index efe4936..00d7b10 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,34 +1,26 @@ - - - - ../src - - - - - - - - - - - - ../tests/ - - - - - - - + + + + ../src + + + + + + + + + + + + ../tests/ + + + + + + +