From cc9f05ed573b40221859638b00c783e8d50eaa34 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 18 Oct 2025 12:35:39 +0200 Subject: [PATCH 1/9] Utilize build-infection --- .github/workflows/build.yml | 3 ++ tests/Infection/TrinaryLogicMutator.php | 69 ------------------------- 2 files changed, 3 insertions(+), 69 deletions(-) delete mode 100644 tests/Infection/TrinaryLogicMutator.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 991d22ed..83f04407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,6 +178,9 @@ jobs: - name: "Install dependencies" run: "composer install --no-interaction --no-progress" + - name: "Install build-infection" + run: "composer require phpstan/build-infection --no-interaction --no-progress" + - uses: "actions/download-artifact@v4" with: name: "result-cache-${{ matrix.php-version }}" diff --git a/tests/Infection/TrinaryLogicMutator.php b/tests/Infection/TrinaryLogicMutator.php deleted file mode 100644 index 67e9b530..00000000 --- a/tests/Infection/TrinaryLogicMutator.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -final class TrinaryLogicMutator implements Mutator -{ - - public static function getDefinition(): Definition - { - return new Definition( - <<<'TXT' - Replaces TrinaryLogic->yes() with !TrinaryLogic->no() and vice versa. - TXT - , - MutatorCategory::ORTHOGONAL_REPLACEMENT, - null, - <<<'DIFF' - - $type->isBoolean()->yes(); - + !$type->isBoolean()->no(); - DIFF, - ); - } - - public function getName(): string - { - return 'TrinaryLogicMutator'; - } - - public function canMutate(Node $node): bool - { - if (!$node instanceof Node\Expr\MethodCall) { - return false; - } - - if (!$node->name instanceof Node\Identifier) { - return false; - } - - if (!in_array($node->name->name, ['yes', 'no'], true)) { - return false; - } - - return true; - } - - public function mutate(Node $node): iterable - { - if (!$node->name instanceof Node\Identifier) { - throw new LogicException(); - } - - if ($node->name->name === 'yes') { - yield new Node\Expr\BooleanNot(new Node\Expr\MethodCall($node->var, 'no')); - } else { - yield new Node\Expr\BooleanNot(new Node\Expr\MethodCall($node->var, 'yes')); - } - } - -} From 6e9daf17e84ff9830c679224fb486e1ebcc64343 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 18 Oct 2025 12:36:50 +0200 Subject: [PATCH 2/9] Update phpstan.neon --- phpstan.neon | 1 - 1 file changed, 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 385b9690..b5f35ecc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -25,7 +25,6 @@ parameters: - tests/*/data-attributes/* - tests/*/data-php-*/* - tests/Rules/Doctrine/ORM/entity-manager.php - - tests/Infection/ reportUnmatchedIgnoredErrors: false From 747ec2db8e0ee1c79e033837e0d9d60445b09ff7 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 19:56:33 +0200 Subject: [PATCH 3/9] checkout build-infection --- .github/workflows/build.yml | 12 ++++++++++-- infection.json5 | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83f04407..4a31e0e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,8 +178,16 @@ jobs: - name: "Install dependencies" run: "composer install --no-interaction --no-progress" - - name: "Install build-infection" - run: "composer require phpstan/build-infection --no-interaction --no-progress" + - name: "Checkout build-infection" + uses: actions/checkout@v5 + with: + repository: "phpstan/build-infection" + path: "build-infection" + ref: "1.x" + + - name: "Install build-infection dependencies" + working-directory: "build-infection" + run: "composer install --no-interaction --no-progress" - uses: "actions/download-artifact@v4" with: diff --git a/infection.json5 b/infection.json5 index 7afd7230..1c6c2ed0 100644 --- a/infection.json5 +++ b/infection.json5 @@ -10,6 +10,7 @@ "logs": { "text": "tmp/infection.log" }, + "bootstrap":"build-infection/vendor/autoload.php", "mutators": { "@default": false, "PHPStan\\Infection\\TrinaryLogicMutator": true From 9c591dd8b4f0bc3e09bcb490c32484a7eda953a3 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:01:00 +0200 Subject: [PATCH 4/9] trigger mutation testing --- src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php index 69f9791a..ad6df78d 100644 --- a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php +++ b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php @@ -69,6 +69,14 @@ public function processNode(Node $node, Scope $scope): array return []; } + // testing stuff + $obj = (new ObjectType('Doctrine\ORM\QueryBuilder'))->isSuperTypeOf($calledOnType); + if ($obj->yes()) { + $x = 1; + } else { + $x = 2; + } + try { $dqlType = $scope->getType(new MethodCall($node, new Node\Identifier('getDQL'), [])); } catch (Throwable $e) { From f4be5fe4c6c450bbcefbbf8d85c65122bb28bdff Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:04:12 +0200 Subject: [PATCH 5/9] Update QueryBuilderDqlRule.php --- src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php index ad6df78d..0c9e1d1a 100644 --- a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php +++ b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php @@ -74,7 +74,11 @@ public function processNode(Node $node, Scope $scope): array if ($obj->yes()) { $x = 1; } else { - $x = 2; + $x = 3; + } + + if ($x) { + echo ''; } try { From 9cc6c774e74048ea54506c587f887a58891aa6e9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:04:17 +0200 Subject: [PATCH 6/9] Update QueryBuilderDqlRule.php --- src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php index 0c9e1d1a..f16c1eb2 100644 --- a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php +++ b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php @@ -74,7 +74,7 @@ public function processNode(Node $node, Scope $scope): array if ($obj->yes()) { $x = 1; } else { - $x = 3; + $x = 0; } if ($x) { From b31655d6c31226ba33ce515b183be1297741f10c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:06:55 +0200 Subject: [PATCH 7/9] Update QueryBuilderDqlRule.php --- src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php index f16c1eb2..6685db2a 100644 --- a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php +++ b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php @@ -72,9 +72,9 @@ public function processNode(Node $node, Scope $scope): array // testing stuff $obj = (new ObjectType('Doctrine\ORM\QueryBuilder'))->isSuperTypeOf($calledOnType); if ($obj->yes()) { - $x = 1; + $x = true; } else { - $x = 0; + $x = false; } if ($x) { From 95851bd1e482199fdef195b29a3447f5746a23f0 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:16:19 +0200 Subject: [PATCH 8/9] Discard changes to src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php --- src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php index 6685db2a..69f9791a 100644 --- a/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php +++ b/src/Rules/Doctrine/ORM/QueryBuilderDqlRule.php @@ -69,18 +69,6 @@ public function processNode(Node $node, Scope $scope): array return []; } - // testing stuff - $obj = (new ObjectType('Doctrine\ORM\QueryBuilder'))->isSuperTypeOf($calledOnType); - if ($obj->yes()) { - $x = true; - } else { - $x = false; - } - - if ($x) { - echo ''; - } - try { $dqlType = $scope->getType(new MethodCall($node, new Node\Identifier('getDQL'), [])); } catch (Throwable $e) { From d4edda185b89e69bf54164c7de65d609efa52949 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 19 Oct 2025 20:25:11 +0200 Subject: [PATCH 9/9] Update infection.json5 --- infection.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infection.json5 b/infection.json5 index 1c6c2ed0..f6a55ac1 100644 --- a/infection.json5 +++ b/infection.json5 @@ -10,7 +10,7 @@ "logs": { "text": "tmp/infection.log" }, - "bootstrap":"build-infection/vendor/autoload.php", + "bootstrap": "build-infection/vendor/autoload.php", "mutators": { "@default": false, "PHPStan\\Infection\\TrinaryLogicMutator": true