From 32f193a606c6ddb00e32da26b4138be7be00272f Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:55:14 +0500 Subject: [PATCH 01/15] update deps --- .github/workflows/main.yml | 29 +++++++++++++++++++++++------ composer.json | 11 ++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d33ede7..ea121dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,12 +12,29 @@ jobs: php-versions: ['8.1', '8.2', '8.3'] steps: - - uses: actions/checkout@v2 + # Check-out repository under GitHub workspace + # https://github.com/actions/checkout + - uses: actions/checkout@v4 + # Step's name - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} - - - run: make install - - run: make lint - - run: make test + # Specify the PHP version + php-version: '8.2' + - name: Install + # Install project + run: make install + - name: Run linter + # Run Linter + run: make lint + # Publish code coverage on Code Climate + # https://github.com/paambaati/codeclimate-action + - name: Run test & publish code coverage + uses: paambaati/codeclimate-action@v2.6.0 + # Add Code Climate secret key + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageCommand: make test-coverage + coverageLocations: ${{github.workplace}}/build/logs/clover.xml:clover + debug: true diff --git a/composer.json b/composer.json index 8f3fd41..e357f70 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,12 @@ { "name": "hexlet/phpstan-fp", "description": "PHPStan rules for functional programming", + "version": "3.0.0", "type": "library", "require": { - "php": ">=8.1", - "phpstan/phpstan": "^1.10.24", - "illuminate/collections": "^10.14.1" + "php": ">=8.2", + "phpstan/phpstan": "^1", + "illuminate/collections": "^12" }, "license": "MIT", "autoload": { @@ -22,7 +23,7 @@ } }, "require-dev": { - "phpunit/phpunit": "^9.5.18", - "squizlabs/php_codesniffer": "^3.6.2" + "phpunit/phpunit": "^11.0", + "squizlabs/php_codesniffer": "^3.9" } } From 39963ebe41d9ecff99a3952281f0bb4bb252f99f Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Wed, 5 Mar 2025 16:14:12 +0500 Subject: [PATCH 02/15] update config --- phpcs.xml | 2 +- phpstan.neon | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 05b845c..28ac9a5 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -5,7 +5,7 @@ - + vendor/* tests/*/data/* diff --git a/phpstan.neon b/phpstan.neon index c844d27..78fea21 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,9 +3,8 @@ parameters: paths: - src - tests - excludePaths: - tests/*/data/* - - checkGenericClassInNonGenericObjectType: false - reportUnmatchedIgnoredErrors: false + ignoreErrors: + - identifier: missingType.generics + - identifier: argument.templateType From a96e933f53e925a8dd8a9d1ebfff201ca4b376d4 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:55:58 +0500 Subject: [PATCH 03/15] update --- .github/workflows/main.yml | 16 +++++----------- Makefile | 6 ++++-- composer.json | 6 +++--- phpcs.xml | 5 ++++- phpunit.xml | 17 ++++++++--------- src/Rules/Classes/DisallowClassesRule.php | 17 +++++++++-------- src/Rules/Exceptions/DisallowThrowRule.php | 17 +++++++++-------- .../DisallowUnusedExpressionRule.php | 9 ++++++--- .../DisallowMutatingFunctionsRule.php | 11 ++++++++--- src/Rules/Loops/DisallowLoopsRule.php | 7 +++++-- src/Rules/Variables/DisallowMutationRule.php | 18 +++++++++++------- tests/Rules/Classes/data/classes.php | 6 ++---- tests/Rules/Exceptions/data/exceptions.php | 3 ++- tests/Rules/Expression/data/expressions.php | 4 ++-- tests/Rules/Loops/data/loops.php | 1 - tests/Rules/Variables/data/assign.php | 3 ++- 16 files changed, 80 insertions(+), 66 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea121dd..b01ec38 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,26 +12,20 @@ jobs: php-versions: ['8.1', '8.2', '8.3'] steps: - # Check-out repository under GitHub workspace - # https://github.com/actions/checkout - uses: actions/checkout@v4 - # Step's name - name: Setup PHP uses: shivammathur/setup-php@v2 with: - # Specify the PHP version - php-version: '8.2' + php-version: ${{ matrix.version }} + - name: Install - # Install project run: make install + - name: Run linter - # Run Linter run: make lint - # Publish code coverage on Code Climate - # https://github.com/paambaati/codeclimate-action + - name: Run test & publish code coverage - uses: paambaati/codeclimate-action@v2.6.0 - # Add Code Climate secret key + uses: paambaati/codeclimate-action@v9.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: diff --git a/Makefile b/Makefile index 60879a0..c531292 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,13 @@ test: composer exec -v phpunit tests lint: - composer exec -v phpcs src tests + composer exec -v phpcs + +analyse: composer exec -v phpstan -- analyse -c phpstan.neon lint-fix: - composer exec phpcbf -- --standard=PSR12 -v src tests + composer exec -v phpcbf test-coverage: composer exec --verbose phpunit tests -- --coverage-clover build/logs/clover.xml diff --git a/composer.json b/composer.json index e357f70..b487d6e 100644 --- a/composer.json +++ b/composer.json @@ -5,14 +5,14 @@ "type": "library", "require": { "php": ">=8.2", - "phpstan/phpstan": "^1", + "phpstan/phpstan": "^2.0", "illuminate/collections": "^12" }, "license": "MIT", "autoload": { "psr-4": { - "Hexlet\\PHPStanFp\\": "src/", - "Hexlet\\PHPStanFp\\Tests\\": "tests/" + "Hexlet\\PHPStanFp\\": "src/", + "Hexlet\\PHPStanFp\\Tests\\": "tests/" } }, "extra": { diff --git a/phpcs.xml b/phpcs.xml index 28ac9a5..a54e710 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,11 +1,14 @@ PSR12 - + + + src + tests vendor/* tests/*/data/* diff --git a/phpunit.xml b/phpunit.xml index 550fb89..889129d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,12 @@ - diff --git a/src/Rules/Classes/DisallowClassesRule.php b/src/Rules/Classes/DisallowClassesRule.php index 4e5d59a..3998ea6 100644 --- a/src/Rules/Classes/DisallowClassesRule.php +++ b/src/Rules/Classes/DisallowClassesRule.php @@ -2,10 +2,11 @@ namespace Hexlet\PHPStanFp\Rules\Classes; -use PHPStan\Rules\Rule; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PhpParser\Node\Stmt\Class_; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; class DisallowClassesRule implements Rule { @@ -21,16 +22,16 @@ public function getNodeType(): string return Class_::class; } - /** - * @param \PhpParser\Node\Stmt\Class_ $node - * @param \PHPStan\Analyser\Scope $scope - * @return string[] - */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowClasses) { return []; } - return ['Should not use classes']; + + $errorMessage = 'Should not use classes'; + + return [ + RuleErrorBuilder::message($errorMessage)->build() + ]; } } diff --git a/src/Rules/Exceptions/DisallowThrowRule.php b/src/Rules/Exceptions/DisallowThrowRule.php index d37ace5..b4d4f59 100644 --- a/src/Rules/Exceptions/DisallowThrowRule.php +++ b/src/Rules/Exceptions/DisallowThrowRule.php @@ -2,10 +2,11 @@ namespace Hexlet\PHPStanFp\Rules\Exceptions; -use PHPStan\Rules\Rule; use PhpParser\Node; +use PhpParser\Node\Expr\Throw_; use PHPStan\Analyser\Scope; -use PhpParser\Node\Stmt\Throw_; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; class DisallowThrowRule implements Rule { @@ -21,16 +22,16 @@ public function getNodeType(): string return Throw_::class; } - /** - * @param \PhpParser\Node\Stmt\Throw_ $node - * @param \PHPStan\Analyser\Scope $scope - * @return string[] - */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowThrow) { return []; } - return ['Should not use throw']; + + $errorMessage = 'Should not use throw'; + + return [ + RuleErrorBuilder::message($errorMessage)->build() + ]; } } diff --git a/src/Rules/Expression/DisallowUnusedExpressionRule.php b/src/Rules/Expression/DisallowUnusedExpressionRule.php index 0c9a398..a811e86 100644 --- a/src/Rules/Expression/DisallowUnusedExpressionRule.php +++ b/src/Rules/Expression/DisallowUnusedExpressionRule.php @@ -2,10 +2,11 @@ namespace Hexlet\PHPStanFp\Rules\Expression; -use PHPStan\Rules\Rule; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PhpParser\Node\Stmt\Expression; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; class DisallowUnusedExpressionRule implements Rule { @@ -36,6 +37,8 @@ public function processNode(Node $node, Scope $scope): array return []; } - return ['Enforce that an expression gets used']; + return [ + RuleErrorBuilder::message('Enforce that an expression gets used')->build() + ]; } } diff --git a/src/Rules/Functions/DisallowMutatingFunctionsRule.php b/src/Rules/Functions/DisallowMutatingFunctionsRule.php index e9e0483..7642520 100644 --- a/src/Rules/Functions/DisallowMutatingFunctionsRule.php +++ b/src/Rules/Functions/DisallowMutatingFunctionsRule.php @@ -2,10 +2,11 @@ namespace Hexlet\PHPStanFp\Rules\Functions; -use PHPStan\Rules\Rule; use PhpParser\Node; -use PHPStan\Analyser\Scope; use PhpParser\Node\Expr\FuncCall; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; class DisallowMutatingFunctionsRule implements Rule { @@ -65,6 +66,10 @@ public function processNode(Node $node, Scope $scope): array return []; } - return ["The use of function '{$name}' is not allowed as it might be a mutating function"]; + $errorMessage = "The use of function '{$name}' is not allowed as it might be a mutating function"; + + return [ + RuleErrorBuilder::message($errorMessage)->build() + ]; } } diff --git a/src/Rules/Loops/DisallowLoopsRule.php b/src/Rules/Loops/DisallowLoopsRule.php index ec92e6a..d643a7f 100644 --- a/src/Rules/Loops/DisallowLoopsRule.php +++ b/src/Rules/Loops/DisallowLoopsRule.php @@ -2,9 +2,10 @@ namespace Hexlet\PHPStanFp\Rules\Loops; -use PHPStan\Rules\Rule; use PhpParser\Node; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; abstract class DisallowLoopsRule implements Rule { @@ -21,7 +22,9 @@ public function processNode(Node $node, Scope $scope): array return []; } - return ["Should not use loop {$this->getLoopType()}"]; + return [ + RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}")->build() + ]; } abstract protected function getLoopType(): string; diff --git a/src/Rules/Variables/DisallowMutationRule.php b/src/Rules/Variables/DisallowMutationRule.php index a7f6681..7e10d16 100644 --- a/src/Rules/Variables/DisallowMutationRule.php +++ b/src/Rules/Variables/DisallowMutationRule.php @@ -2,9 +2,10 @@ namespace Hexlet\PHPStanFp\Rules\Variables; -use PHPStan\Rules\Rule; use PhpParser\Node; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; abstract class DisallowMutationRule implements Rule { @@ -34,18 +35,21 @@ public function processNode(Node $node, Scope $scope): array switch ($node->var->getType()) { case 'Expr_ArrayDimFetch': - return [$errorMessage]; - - case 'Expr_Array': + return [ + RuleErrorBuilder::message($errorMessage)->build() + ]; + case 'Expr_List': $containsTypedItems = collect($node->var->items) ->map(fn($item) => $item->value->name) ->filter(fn($name) => !is_null($name)) ->contains(fn($name) => $scope->hasVariableType($name)->yes()); - return $containsTypedItems ? [$errorMessage] : []; - case 'Expr_Variable': - return $scope->hasVariableType($node->var->name)->yes() ? [$errorMessage] : []; + return $containsTypedItems ? [RuleErrorBuilder::message($errorMessage)->build()] : []; + case 'Expr_Variable': + return $scope->hasVariableType($node->var->name)->yes() + ? [RuleErrorBuilder::message($errorMessage)->build()] + : []; default: return []; } diff --git a/tests/Rules/Classes/data/classes.php b/tests/Rules/Classes/data/classes.php index 16c3132..6cc4804 100644 --- a/tests/Rules/Classes/data/classes.php +++ b/tests/Rules/Classes/data/classes.php @@ -2,17 +2,14 @@ class ExampleClass { - } abstract class ExampleAbstractClass { - } final class ExampleFinalClass { - } function example() @@ -20,7 +17,8 @@ function example() // do not cause an error $someVar = 'class'; - $anonymous = new class {}; + $anonymous = new class { + }; } // do not cause an error diff --git a/tests/Rules/Exceptions/data/exceptions.php b/tests/Rules/Exceptions/data/exceptions.php index bd3b4b1..bc17ff3 100644 --- a/tests/Rules/Exceptions/data/exceptions.php +++ b/tests/Rules/Exceptions/data/exceptions.php @@ -7,7 +7,8 @@ function example() // do not cause an error $someVar = 'throw'; - $anonymous = new class {}; + $anonymous = new class { + }; } // do not cause an error diff --git a/tests/Rules/Expression/data/expressions.php b/tests/Rules/Expression/data/expressions.php index f001d9c..c3c632d 100644 --- a/tests/Rules/Expression/data/expressions.php +++ b/tests/Rules/Expression/data/expressions.php @@ -17,7 +17,8 @@ function ds() $a++; -function example() { +function example() +{ 9 + 7; print_r(); @@ -30,5 +31,4 @@ function example() { print_r('some text'); for ($i = 0; 2 + 5; $i++) { - } diff --git a/tests/Rules/Loops/data/loops.php b/tests/Rules/Loops/data/loops.php index 8c295f0..af39580 100644 --- a/tests/Rules/Loops/data/loops.php +++ b/tests/Rules/Loops/data/loops.php @@ -12,7 +12,6 @@ } while ($a < 3); for ($i = 0; $i < 2; $i++) { - } $arr = array(1, 2, 3, 4); diff --git a/tests/Rules/Variables/data/assign.php b/tests/Rules/Variables/data/assign.php index 9dffd85..8508e4c 100644 --- a/tests/Rules/Variables/data/assign.php +++ b/tests/Rules/Variables/data/assign.php @@ -13,7 +13,8 @@ $a = 15; -function ds($arg1, &$arg2) { +function ds($arg1, &$arg2) +{ $arg1 = 2; $arg2 = 'text'; From 8bd279d4a0152f8fb4a1d0ebc9629fb1c714b807 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:28:29 +0500 Subject: [PATCH 04/15] update --- .github/workflows/main.yml | 2 +- phpunit.xml | 8 ++++--- src/Rules/Classes/DisallowClassesRule.php | 4 +++- src/Rules/Exceptions/DisallowThrowRule.php | 2 +- .../DisallowUnusedExpressionRule.php | 2 +- .../DisallowMutatingFunctionsRule.php | 8 ++----- src/Rules/Loops/DisallowLoopsRule.php | 2 +- src/Rules/Variables/DisallowMutationRule.php | 24 +++++++++++-------- .../Rules/Classes/DisallowClassesRuleTest.php | 6 ++--- .../DisallowUnusedExpressionRuleTest.php | 8 +++---- tests/Rules/Loops/ForeachRuleTest.php | 2 +- tests/Rules/Variables/data/assign.php | 3 +-- 12 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b01ec38..23facc2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: run: make install - name: Run linter - run: make lint + run: make lint analyse - name: Run test & publish code coverage uses: paambaati/codeclimate-action@v9.0.0 diff --git a/phpunit.xml b/phpunit.xml index 889129d..868c0f0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,11 +1,13 @@ diff --git a/src/Rules/Classes/DisallowClassesRule.php b/src/Rules/Classes/DisallowClassesRule.php index 3998ea6..e7dc632 100644 --- a/src/Rules/Classes/DisallowClassesRule.php +++ b/src/Rules/Classes/DisallowClassesRule.php @@ -31,7 +31,9 @@ public function processNode(Node $node, Scope $scope): array $errorMessage = 'Should not use classes'; return [ - RuleErrorBuilder::message($errorMessage)->build() + RuleErrorBuilder::message($errorMessage) + ->identifier('PHPStanFp.disallowClasses') + ->build() ]; } } diff --git a/src/Rules/Exceptions/DisallowThrowRule.php b/src/Rules/Exceptions/DisallowThrowRule.php index b4d4f59..b2784d6 100644 --- a/src/Rules/Exceptions/DisallowThrowRule.php +++ b/src/Rules/Exceptions/DisallowThrowRule.php @@ -31,7 +31,7 @@ public function processNode(Node $node, Scope $scope): array $errorMessage = 'Should not use throw'; return [ - RuleErrorBuilder::message($errorMessage)->build() + RuleErrorBuilder::message($errorMessage)->identifier('PHPStanFp.disallowThrow')->build() ]; } } diff --git a/src/Rules/Expression/DisallowUnusedExpressionRule.php b/src/Rules/Expression/DisallowUnusedExpressionRule.php index a811e86..62826e5 100644 --- a/src/Rules/Expression/DisallowUnusedExpressionRule.php +++ b/src/Rules/Expression/DisallowUnusedExpressionRule.php @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array } return [ - RuleErrorBuilder::message('Enforce that an expression gets used')->build() + RuleErrorBuilder::message('Enforce that an expression gets used')->identifier('PHPStanFp.disallowUnusedExpression')->build() ]; } } diff --git a/src/Rules/Functions/DisallowMutatingFunctionsRule.php b/src/Rules/Functions/DisallowMutatingFunctionsRule.php index 7642520..bdfa13b 100644 --- a/src/Rules/Functions/DisallowMutatingFunctionsRule.php +++ b/src/Rules/Functions/DisallowMutatingFunctionsRule.php @@ -46,11 +46,6 @@ public function getNodeType(): string return FuncCall::class; } - /** - * @param \PhpParser\Node\Expr\FuncCall $node - * @param \PHPStan\Analyser\Scope $scope - * @return string[] - */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowMutatingFunctions) { @@ -62,6 +57,7 @@ public function processNode(Node $node, Scope $scope): array } $name = $node->name->getFirst(); + if (!in_array($name, $this->mutatingFunctionsNames)) { return []; } @@ -69,7 +65,7 @@ public function processNode(Node $node, Scope $scope): array $errorMessage = "The use of function '{$name}' is not allowed as it might be a mutating function"; return [ - RuleErrorBuilder::message($errorMessage)->build() + RuleErrorBuilder::message($errorMessage)->identifier('PHPStanFp.disallowMutatingFunctions')->build() ]; } } diff --git a/src/Rules/Loops/DisallowLoopsRule.php b/src/Rules/Loops/DisallowLoopsRule.php index d643a7f..f0b561c 100644 --- a/src/Rules/Loops/DisallowLoopsRule.php +++ b/src/Rules/Loops/DisallowLoopsRule.php @@ -23,7 +23,7 @@ public function processNode(Node $node, Scope $scope): array } return [ - RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}")->build() + RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}")->identifier('PHPStanFp.disallowLoops')->build() ]; } diff --git a/src/Rules/Variables/DisallowMutationRule.php b/src/Rules/Variables/DisallowMutationRule.php index 7e10d16..08d9be3 100644 --- a/src/Rules/Variables/DisallowMutationRule.php +++ b/src/Rules/Variables/DisallowMutationRule.php @@ -6,6 +6,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; abstract class DisallowMutationRule implements Rule { @@ -16,11 +17,6 @@ public function __construct(bool $disallowVariablesMutation) $this->disallowVariablesMutation = $disallowVariablesMutation; } - /** - * @param \PhpParser\Node\Expr $node - * @param \PHPStan\Analyser\Scope $scope - * @return string[] - */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowVariablesMutation) { @@ -31,12 +27,10 @@ public function processNode(Node $node, Scope $scope): array return []; } - $errorMessage = 'Should not use of mutating operators'; - switch ($node->var->getType()) { case 'Expr_ArrayDimFetch': return [ - RuleErrorBuilder::message($errorMessage)->build() + $this->buildError() ]; case 'Expr_List': $containsTypedItems = collect($node->var->items) @@ -44,14 +38,24 @@ public function processNode(Node $node, Scope $scope): array ->filter(fn($name) => !is_null($name)) ->contains(fn($name) => $scope->hasVariableType($name)->yes()); - return $containsTypedItems ? [RuleErrorBuilder::message($errorMessage)->build()] : []; + return $containsTypedItems + ? [$this->buildError()] + : []; case 'Expr_Variable': return $scope->hasVariableType($node->var->name)->yes() - ? [RuleErrorBuilder::message($errorMessage)->build()] + ? [$this->buildError()] : []; default: return []; } } + private function buildError(): IdentifierRuleError + { + $errorMessage = 'Should not use of mutating operators'; + + return RuleErrorBuilder::message($errorMessage) + ->identifier('PHPStanFp.disallowVariablesMutation') + ->build(); + } } diff --git a/tests/Rules/Classes/DisallowClassesRuleTest.php b/tests/Rules/Classes/DisallowClassesRuleTest.php index bc02b6a..a94280d 100644 --- a/tests/Rules/Classes/DisallowClassesRuleTest.php +++ b/tests/Rules/Classes/DisallowClassesRuleTest.php @@ -25,15 +25,15 @@ public function testWithEnabledRule(): void ], [ 'Should not use classes', - 8, + 7, ], [ 'Should not use classes', - 13, + 11, ], [ 'Should not use classes', - 23, + 20, ], ]); } diff --git a/tests/Rules/Expression/DisallowUnusedExpressionRuleTest.php b/tests/Rules/Expression/DisallowUnusedExpressionRuleTest.php index f244504..d4572ea 100644 --- a/tests/Rules/Expression/DisallowUnusedExpressionRuleTest.php +++ b/tests/Rules/Expression/DisallowUnusedExpressionRuleTest.php @@ -33,19 +33,19 @@ public function testWithEnabledRule(): void ], [ 'Enforce that an expression gets used', - 21, + 22, ], [ 'Enforce that an expression gets used', - 23, + 24, ], [ 'Enforce that an expression gets used', - 27, + 28, ], [ 'Enforce that an expression gets used', - 30, + 31, ], ]); } diff --git a/tests/Rules/Loops/ForeachRuleTest.php b/tests/Rules/Loops/ForeachRuleTest.php index e2ca9d6..bbbdb20 100644 --- a/tests/Rules/Loops/ForeachRuleTest.php +++ b/tests/Rules/Loops/ForeachRuleTest.php @@ -21,7 +21,7 @@ public function testWithEnabledRule(): void $this->analyse([__DIR__ . '/data/loops.php'], [ [ 'Should not use loop foreach', - 19, + 18, ], ]); } diff --git a/tests/Rules/Variables/data/assign.php b/tests/Rules/Variables/data/assign.php index 8508e4c..9dffd85 100644 --- a/tests/Rules/Variables/data/assign.php +++ b/tests/Rules/Variables/data/assign.php @@ -13,8 +13,7 @@ $a = 15; -function ds($arg1, &$arg2) -{ +function ds($arg1, &$arg2) { $arg1 = 2; $arg2 = 'text'; From ca49fe2cf16ddc85f681e5e0593a23b5568daa3f Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:34:51 +0500 Subject: [PATCH 05/15] fix lint --- src/Rules/Classes/DisallowClassesRule.php | 5 +++++ src/Rules/Expression/DisallowUnusedExpressionRule.php | 6 ++++-- src/Rules/Functions/DisallowMutatingFunctionsRule.php | 9 ++++++++- src/Rules/Loops/DisallowLoopsRule.php | 4 +++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Rules/Classes/DisallowClassesRule.php b/src/Rules/Classes/DisallowClassesRule.php index e7dc632..19daf35 100644 --- a/src/Rules/Classes/DisallowClassesRule.php +++ b/src/Rules/Classes/DisallowClassesRule.php @@ -22,6 +22,11 @@ public function getNodeType(): string return Class_::class; } + /** + * @param \PhpParser\Node\Stmt\Class_ $node + * @param \PHPStan\Analyser\Scope $scope + * @return \PHPStan\Rules\IdentifierRuleError[] + */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowClasses) { diff --git a/src/Rules/Expression/DisallowUnusedExpressionRule.php b/src/Rules/Expression/DisallowUnusedExpressionRule.php index 62826e5..5f78f86 100644 --- a/src/Rules/Expression/DisallowUnusedExpressionRule.php +++ b/src/Rules/Expression/DisallowUnusedExpressionRule.php @@ -25,7 +25,7 @@ public function getNodeType(): string /** * @param \PhpParser\Node\Stmt\Expression $node * @param \PHPStan\Analyser\Scope $scope - * @return string[] + * @return \PHPStan\Rules\IdentifierRuleError[] */ public function processNode(Node $node, Scope $scope): array { @@ -38,7 +38,9 @@ public function processNode(Node $node, Scope $scope): array } return [ - RuleErrorBuilder::message('Enforce that an expression gets used')->identifier('PHPStanFp.disallowUnusedExpression')->build() + RuleErrorBuilder::message('Enforce that an expression gets used') + ->identifier('PHPStanFp.disallowUnusedExpression') + ->build() ]; } } diff --git a/src/Rules/Functions/DisallowMutatingFunctionsRule.php b/src/Rules/Functions/DisallowMutatingFunctionsRule.php index bdfa13b..2452001 100644 --- a/src/Rules/Functions/DisallowMutatingFunctionsRule.php +++ b/src/Rules/Functions/DisallowMutatingFunctionsRule.php @@ -46,6 +46,11 @@ public function getNodeType(): string return FuncCall::class; } + /** + * @param \PhpParser\Node\Expr\FuncCall $node + * @param \PHPStan\Analyser\Scope $scope + * @return \PHPStan\Rules\IdentifierRuleError[] + */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowMutatingFunctions) { @@ -65,7 +70,9 @@ public function processNode(Node $node, Scope $scope): array $errorMessage = "The use of function '{$name}' is not allowed as it might be a mutating function"; return [ - RuleErrorBuilder::message($errorMessage)->identifier('PHPStanFp.disallowMutatingFunctions')->build() + RuleErrorBuilder::message($errorMessage) + ->identifier('PHPStanFp.disallowMutatingFunctions') + ->build() ]; } } diff --git a/src/Rules/Loops/DisallowLoopsRule.php b/src/Rules/Loops/DisallowLoopsRule.php index f0b561c..d59c275 100644 --- a/src/Rules/Loops/DisallowLoopsRule.php +++ b/src/Rules/Loops/DisallowLoopsRule.php @@ -23,7 +23,9 @@ public function processNode(Node $node, Scope $scope): array } return [ - RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}")->identifier('PHPStanFp.disallowLoops')->build() + RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}") + ->identifier('PHPStanFp.disallowLoops') + ->build() ]; } From 0909d956efe22512389b6cc92f9d6bb5f6771891 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:40:26 +0500 Subject: [PATCH 06/15] updat phpdoc --- src/Rules/Classes/DisallowClassesRule.php | 7 ++++--- src/Rules/Exceptions/DisallowThrowRule.php | 10 +++++++++- src/Rules/Expression/DisallowUnusedExpressionRule.php | 7 ++++--- src/Rules/Functions/DisallowMutatingFunctionsRule.php | 7 ++++--- src/Rules/Loops/DisallowLoopsRule.php | 6 ++++++ src/Rules/Variables/DisallowMutationRule.php | 5 +++++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/Rules/Classes/DisallowClassesRule.php b/src/Rules/Classes/DisallowClassesRule.php index 19daf35..03dca98 100644 --- a/src/Rules/Classes/DisallowClassesRule.php +++ b/src/Rules/Classes/DisallowClassesRule.php @@ -7,6 +7,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; class DisallowClassesRule implements Rule { @@ -23,9 +24,9 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Stmt\Class_ $node - * @param \PHPStan\Analyser\Scope $scope - * @return \PHPStan\Rules\IdentifierRuleError[] + * @param Class_ $node + * @param Scope $scope + * @return IdentifierRuleError[] */ public function processNode(Node $node, Scope $scope): array { diff --git a/src/Rules/Exceptions/DisallowThrowRule.php b/src/Rules/Exceptions/DisallowThrowRule.php index b2784d6..3982ecc 100644 --- a/src/Rules/Exceptions/DisallowThrowRule.php +++ b/src/Rules/Exceptions/DisallowThrowRule.php @@ -7,6 +7,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; class DisallowThrowRule implements Rule { @@ -22,6 +23,11 @@ public function getNodeType(): string return Throw_::class; } + /** + * @param Throw_ $node + * @param Scope $scope + * @return IdentifierRuleError[] + */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowThrow) { @@ -31,7 +37,9 @@ public function processNode(Node $node, Scope $scope): array $errorMessage = 'Should not use throw'; return [ - RuleErrorBuilder::message($errorMessage)->identifier('PHPStanFp.disallowThrow')->build() + RuleErrorBuilder::message($errorMessage) + ->identifier('PHPStanFp.disallowThrow') + ->build() ]; } } diff --git a/src/Rules/Expression/DisallowUnusedExpressionRule.php b/src/Rules/Expression/DisallowUnusedExpressionRule.php index 5f78f86..b3aa9da 100644 --- a/src/Rules/Expression/DisallowUnusedExpressionRule.php +++ b/src/Rules/Expression/DisallowUnusedExpressionRule.php @@ -7,6 +7,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; class DisallowUnusedExpressionRule implements Rule { @@ -23,9 +24,9 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Stmt\Expression $node - * @param \PHPStan\Analyser\Scope $scope - * @return \PHPStan\Rules\IdentifierRuleError[] + * @param Expression $node + * @param Scope $scope + * @return IdentifierRuleError[] */ public function processNode(Node $node, Scope $scope): array { diff --git a/src/Rules/Functions/DisallowMutatingFunctionsRule.php b/src/Rules/Functions/DisallowMutatingFunctionsRule.php index 2452001..61110ce 100644 --- a/src/Rules/Functions/DisallowMutatingFunctionsRule.php +++ b/src/Rules/Functions/DisallowMutatingFunctionsRule.php @@ -7,6 +7,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; class DisallowMutatingFunctionsRule implements Rule { @@ -47,9 +48,9 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\FuncCall $node - * @param \PHPStan\Analyser\Scope $scope - * @return \PHPStan\Rules\IdentifierRuleError[] + * @param FuncCall $node + * @param Scope $scope + * @return IdentifierRuleError[] */ public function processNode(Node $node, Scope $scope): array { diff --git a/src/Rules/Loops/DisallowLoopsRule.php b/src/Rules/Loops/DisallowLoopsRule.php index d59c275..1762a0b 100644 --- a/src/Rules/Loops/DisallowLoopsRule.php +++ b/src/Rules/Loops/DisallowLoopsRule.php @@ -6,6 +6,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\Rules\IdentifierRuleError; abstract class DisallowLoopsRule implements Rule { @@ -16,6 +17,11 @@ public function __construct(bool $disallowLoops) $this->disallowLoops = $disallowLoops; } + /** + * @param Node $node + * @param Scope $scope + * @return IdentifierRuleError[] + */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowLoops) { diff --git a/src/Rules/Variables/DisallowMutationRule.php b/src/Rules/Variables/DisallowMutationRule.php index 08d9be3..72bc296 100644 --- a/src/Rules/Variables/DisallowMutationRule.php +++ b/src/Rules/Variables/DisallowMutationRule.php @@ -17,6 +17,11 @@ public function __construct(bool $disallowVariablesMutation) $this->disallowVariablesMutation = $disallowVariablesMutation; } + /** + * @param Node $node + * @param Scope $scope + * @return IdentifierRuleError[] + */ public function processNode(Node $node, Scope $scope): array { if (!$this->disallowVariablesMutation) { From 9cee46845fb722b495f7bc869d1bab81362af53e Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:41:13 +0500 Subject: [PATCH 07/15] updat phpdoc --- phpunit.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpunit.xml b/phpunit.xml index 868c0f0..9f8ae1d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,6 +9,11 @@ processIsolation="false" stopOnFailure="false" bootstrap="vendor/autoload.php" + displayDetailsOnTestsThatTriggerDeprecations="true" + displayDetailsOnTestsThatTriggerErrors="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerWarnings="true" + displayDetailsOnPhpunitDeprecations="true" > From d62b16811f34a16a4baa1b306a918b170980d4f3 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:49:35 +0500 Subject: [PATCH 08/15] update --- composer.json | 2 +- phpunit.xml | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b487d6e..6e3284d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } }, "require-dev": { - "phpunit/phpunit": "^11.0", + "phpunit/phpunit": "^11.5", "squizlabs/php_codesniffer": "^3.9" } } diff --git a/phpunit.xml b/phpunit.xml index 9f8ae1d..6f2b698 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,11 +1,10 @@ Date: Tue, 8 Apr 2025 01:57:10 +0500 Subject: [PATCH 09/15] update --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 23facc2..280f469 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.1', '8.2', '8.3'] + php-versions: ['8.2', '8.3'] steps: - uses: actions/checkout@v4 From 10cc452b7807c1a1f67f13e8f8d2a91e29c8b2b0 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 01:57:56 +0500 Subject: [PATCH 10/15] fix lint --- phpstan.neon | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 78fea21..7cc36b6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,6 +5,3 @@ parameters: - tests excludePaths: - tests/*/data/* - ignoreErrors: - - identifier: missingType.generics - - identifier: argument.templateType From d13ff77b0936f14444be66147a0783a5ace9b992 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 02:01:01 +0500 Subject: [PATCH 11/15] use consistent name in config --- src/Rules/Classes/DisallowClassesRule.php | 2 +- src/Rules/Exceptions/DisallowThrowRule.php | 2 +- src/Rules/Expression/DisallowUnusedExpressionRule.php | 2 +- src/Rules/Functions/DisallowMutatingFunctionsRule.php | 2 +- src/Rules/Loops/DisallowLoopsRule.php | 2 +- src/Rules/Variables/DisallowMutationRule.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Rules/Classes/DisallowClassesRule.php b/src/Rules/Classes/DisallowClassesRule.php index 03dca98..f2ba3da 100644 --- a/src/Rules/Classes/DisallowClassesRule.php +++ b/src/Rules/Classes/DisallowClassesRule.php @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message($errorMessage) - ->identifier('PHPStanFp.disallowClasses') + ->identifier('phpstanFunctionalProgramming.disallowClasses') ->build() ]; } diff --git a/src/Rules/Exceptions/DisallowThrowRule.php b/src/Rules/Exceptions/DisallowThrowRule.php index 3982ecc..4ac36d2 100644 --- a/src/Rules/Exceptions/DisallowThrowRule.php +++ b/src/Rules/Exceptions/DisallowThrowRule.php @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message($errorMessage) - ->identifier('PHPStanFp.disallowThrow') + ->identifier('phpstanFunctionalProgramming.disallowThrow') ->build() ]; } diff --git a/src/Rules/Expression/DisallowUnusedExpressionRule.php b/src/Rules/Expression/DisallowUnusedExpressionRule.php index b3aa9da..59b289a 100644 --- a/src/Rules/Expression/DisallowUnusedExpressionRule.php +++ b/src/Rules/Expression/DisallowUnusedExpressionRule.php @@ -40,7 +40,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message('Enforce that an expression gets used') - ->identifier('PHPStanFp.disallowUnusedExpression') + ->identifier('phpstanFunctionalProgramming.disallowUnusedExpression') ->build() ]; } diff --git a/src/Rules/Functions/DisallowMutatingFunctionsRule.php b/src/Rules/Functions/DisallowMutatingFunctionsRule.php index 61110ce..29083c7 100644 --- a/src/Rules/Functions/DisallowMutatingFunctionsRule.php +++ b/src/Rules/Functions/DisallowMutatingFunctionsRule.php @@ -72,7 +72,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message($errorMessage) - ->identifier('PHPStanFp.disallowMutatingFunctions') + ->identifier('phpstanFunctionalProgramming.disallowMutatingFunctions') ->build() ]; } diff --git a/src/Rules/Loops/DisallowLoopsRule.php b/src/Rules/Loops/DisallowLoopsRule.php index 1762a0b..c1c603f 100644 --- a/src/Rules/Loops/DisallowLoopsRule.php +++ b/src/Rules/Loops/DisallowLoopsRule.php @@ -30,7 +30,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message("Should not use loop {$this->getLoopType()}") - ->identifier('PHPStanFp.disallowLoops') + ->identifier('phpstanFunctionalProgramming.disallowLoops') ->build() ]; } diff --git a/src/Rules/Variables/DisallowMutationRule.php b/src/Rules/Variables/DisallowMutationRule.php index 72bc296..01cd0c9 100644 --- a/src/Rules/Variables/DisallowMutationRule.php +++ b/src/Rules/Variables/DisallowMutationRule.php @@ -60,7 +60,7 @@ private function buildError(): IdentifierRuleError $errorMessage = 'Should not use of mutating operators'; return RuleErrorBuilder::message($errorMessage) - ->identifier('PHPStanFp.disallowVariablesMutation') + ->identifier('phpstanFunctionalProgramming.disallowVariablesMutation') ->build(); } } From 1f8e3fc72b1af45d8f08fe17eee0652a17e1abb4 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 02:49:32 +0500 Subject: [PATCH 12/15] update coverage --- .github/workflows/main.yml | 1 + .gitignore | 2 ++ Makefile | 8 +++++++- phpunit.xml | 6 ++++++ tests/Rules/Functions/data/functions.php | 18 +++++++++++++++--- tests/Rules/Variables/AssignRuleTest.php | 4 ++++ tests/Rules/Variables/data/assign.php | 2 ++ 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 280f469..7988994 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.version }} + coverage: xdebug - name: Install run: make install diff --git a/.gitignore b/.gitignore index e2a3893..9adc4b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /vendor/ composer.lock *.cache +build +html-coverage diff --git a/Makefile b/Makefile index c531292..386c471 100644 --- a/Makefile +++ b/Makefile @@ -14,4 +14,10 @@ lint-fix: composer exec -v phpcbf test-coverage: - composer exec --verbose phpunit tests -- --coverage-clover build/logs/clover.xml + XDEBUG_MODE=coverage composer exec --verbose phpunit tests -- --coverage-clover=build/logs/clover.xml + +test-coverage-text: + XDEBUG_MODE=coverage composer exec --verbose phpunit tests -- --coverage-text + +test-coverage-html: + XDEBUG_MODE=coverage composer exec --verbose phpunit tests -- --coverage-html=html-coverage diff --git a/phpunit.xml b/phpunit.xml index 6f2b698..c373a75 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,4 +19,10 @@ ./tests/ + + + + src + + diff --git a/tests/Rules/Functions/data/functions.php b/tests/Rules/Functions/data/functions.php index 2ab498e..ffca6ab 100644 --- a/tests/Rules/Functions/data/functions.php +++ b/tests/Rules/Functions/data/functions.php @@ -32,8 +32,20 @@ sort($ar2); -uasort($ar2); +uasort($ar2, fn($a, $b) => $a <=> $b); -uksort($ar2); +uksort($ar2, fn($a, $b) => $a <=> $b); -usort($ar2); +usort($ar2, fn($a, $b) => $a <=> $b); + +// no error +array_filter($ar1, fn($a) => $a); + +// no error +// but maybe should +$fn = 'print_r'; +$fn('hello'); + +// no error but should +$fn2 = 'array_push'; +$fn2($ar2, 6); diff --git a/tests/Rules/Variables/AssignRuleTest.php b/tests/Rules/Variables/AssignRuleTest.php index 6d0bc16..3ab356a 100644 --- a/tests/Rules/Variables/AssignRuleTest.php +++ b/tests/Rules/Variables/AssignRuleTest.php @@ -75,6 +75,10 @@ public function testWithEnabledRule(): void 'Should not use of mutating operators', 52, ], + [ + 'Should not use of mutating operators', + 54, + ], ]); } diff --git a/tests/Rules/Variables/data/assign.php b/tests/Rules/Variables/data/assign.php index 9dffd85..01a9a71 100644 --- a/tests/Rules/Variables/data/assign.php +++ b/tests/Rules/Variables/data/assign.php @@ -50,3 +50,5 @@ function ds($arg1, &$arg2) { [$a] = $arr; [$newVar, $a] = [5, 6, 7]; + +fn($a) => $a = 3; From cfd02b43b1ab9d2398bd5348cc5a0b46a6475213 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 02:50:03 +0500 Subject: [PATCH 13/15] update minimal php --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6e3284d..6a4d1e6 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "version": "3.0.0", "type": "library", "require": { - "php": ">=8.2", - "phpstan/phpstan": "^2.0", + "php": ">=8.3", + "phpstan/phpstan": "^2.1", "illuminate/collections": "^12" }, "license": "MIT", From 6ae48dcc063c79731bdab984e41947ab357b23b7 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 02:50:41 +0500 Subject: [PATCH 14/15] add support phpunit 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6a4d1e6..0e52258 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } }, "require-dev": { - "phpunit/phpunit": "^11.5", + "phpunit/phpunit": "^11.5 | ^12.0", "squizlabs/php_codesniffer": "^3.9" } } From 588925f492f4e99a533b08529ee37b5855ff6168 Mon Sep 17 00:00:00 2001 From: Nikolay Gagarinov Date: Tue, 8 Apr 2025 02:52:13 +0500 Subject: [PATCH 15/15] fix min php version --- .github/workflows/main.yml | 18 ++++++++++-------- composer.json | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7988994..a3638c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,11 +25,13 @@ jobs: - name: Run linter run: make lint analyse - - name: Run test & publish code coverage - uses: paambaati/codeclimate-action@v9.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - with: - coverageCommand: make test-coverage - coverageLocations: ${{github.workplace}}/build/logs/clover.xml:clover - debug: true + - run: make test + + # - name: Run test & publish code coverage + # uses: paambaati/codeclimate-action@v9.0.0 + # env: + # CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + # with: + # coverageCommand: make test-coverage + # coverageLocations: ${{github.workplace}}/build/logs/clover.xml:clover + # debug: true diff --git a/composer.json b/composer.json index 0e52258..b4d5186 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "version": "3.0.0", "type": "library", "require": { - "php": ">=8.3", + "php": ">=8.2", "phpstan/phpstan": "^2.1", "illuminate/collections": "^12" },