From 1ab03168cccd143354f3bed3173a49652666c21c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:32:12 +0700 Subject: [PATCH 01/16] [PHPStan 2.1.x-dev] Handle next unreachable statement via UnreachableStatementNode->getNextUnreachableStatements() --- .../Scope/PHPStanNodeScopeResolver.php | 12 +--- .../UnreachableStatementNodeVisitor.php | 64 ------------------- 2 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 8e5390ce4ec..a50b4554a28 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -161,11 +161,9 @@ public function processNodes( $scope = $formerMutatingScope ?? $this->scopeFactory->createFromFile($filePath); - $hasUnreachableStatementNode = false; $nodeCallback = function (Node $node, MutatingScope $mutatingScope) use ( &$nodeCallback, $filePath, - &$hasUnreachableStatementNode ): void { // the class reflection is resolved AFTER entering to class node // so we need to get it from the first after this one @@ -188,7 +186,6 @@ public function processNodes( // so node to be checked inside if ($node instanceof UnreachableStatementNode) { $this->processUnreachableStatementNode($node, $filePath, $mutatingScope); - $hasUnreachableStatementNode = true; return; } @@ -410,12 +407,7 @@ public function processNodes( RectorNodeScopeResolver::processNodes($stmts, $scope); } - if (! $hasUnreachableStatementNode) { - return $stmts; - } - - $nodeTraverser = new NodeTraverser(new UnreachableStatementNodeVisitor($this, $filePath, $scope)); - return $nodeTraverser->traverse($stmts); + return $stmts; } private function processYield(Yield_ $yield, MutatingScope $mutatingScope): void @@ -591,7 +583,7 @@ private function processUnreachableStatementNode( $originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); $originalStmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); - $this->processNodes([$originalStmt], $filePath, $mutatingScope); + $this->processNodes(array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()), $filePath, $mutatingScope); } /** diff --git a/src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php b/src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php deleted file mode 100644 index 42ec531ed9f..00000000000 --- a/src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php +++ /dev/null @@ -1,64 +0,0 @@ -stmts === null) { - return null; - } - - $isPassedUnreachableStmt = false; - $mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE)); - - foreach ($node->stmts as $stmt) { - $hasMutatingScope = $stmt->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope; - if (! $hasMutatingScope) { - $stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); - $this->phpStanNodeScopeResolver->processNodes([$stmt], $this->filePath, $mutatingScope); - } - - if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === true) { - $isPassedUnreachableStmt = true; - continue; - } - - if ($isPassedUnreachableStmt) { - $stmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); - } - } - - return null; - } - - private function resolveScope(?Scope $mutatingScope): MutatingScope - { - return $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->mutatingScope; - } -} From 1461a4b3bb6a336911cf94b428fed3c5f81d293c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:32:24 +0700 Subject: [PATCH 02/16] [PHPStan 2.1.x-dev] Handle next unreachable statement via UnreachableStatementNode->getNextUnreachableStatements() --- src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index a50b4554a28..6abab160047 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -105,7 +105,6 @@ use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface; use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace; -use Rector\PHPStan\NodeVisitor\UnreachableStatementNodeVisitor; use Rector\Util\Reflection\PrivatesAccessor; use Webmozart\Assert\Assert; From 5002863537c7602daaa49a6f41af48bd135eed8a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:37:25 +0700 Subject: [PATCH 03/16] temporary use composer update on packages_tests --- .github/workflows/packages_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index 10b45db2e83..735acde09c9 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -52,7 +52,7 @@ jobs: # test with current commit in a pull-request - - run: composer require rector/rector-src dev-main#${{github.event.pull_request.head.sha}} --no-update + run: composer update rector/rector-src dev-main#${{github.event.pull_request.head.sha}} if: ${{ github.event_name == 'pull_request' }} - run: composer install --ansi From 772ee9c5ac09ec1edd16a3e628fbbd84c185bae2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:38:13 +0700 Subject: [PATCH 04/16] temporary use composer update on packages_tests --- .github/workflows/packages_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index 735acde09c9..ca2fc35cff0 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -52,7 +52,7 @@ jobs: # test with current commit in a pull-request - - run: composer update rector/rector-src dev-main#${{github.event.pull_request.head.sha}} + run: composer update rector/rector-src:dev-use-phpstan-21xdev dev-main#${{github.event.pull_request.head.sha}} if: ${{ github.event_name == 'pull_request' }} - run: composer install --ansi From b89f796222f2de3831b8dd999cfe58f69f8a3f40 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:39:47 +0700 Subject: [PATCH 05/16] temporary use composer update on packages_tests --- .github/workflows/packages_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index ca2fc35cff0..735acde09c9 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -52,7 +52,7 @@ jobs: # test with current commit in a pull-request - - run: composer update rector/rector-src:dev-use-phpstan-21xdev dev-main#${{github.event.pull_request.head.sha}} + run: composer update rector/rector-src dev-main#${{github.event.pull_request.head.sha}} if: ${{ github.event_name == 'pull_request' }} - run: composer install --ansi From 012d6b0b88c396d1df1e1dc3fcd959a3b6cfeaf9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 18:41:28 +0700 Subject: [PATCH 06/16] rollback --- .github/workflows/packages_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages_tests.yaml b/.github/workflows/packages_tests.yaml index 735acde09c9..10b45db2e83 100644 --- a/.github/workflows/packages_tests.yaml +++ b/.github/workflows/packages_tests.yaml @@ -52,7 +52,7 @@ jobs: # test with current commit in a pull-request - - run: composer update rector/rector-src dev-main#${{github.event.pull_request.head.sha}} + run: composer require rector/rector-src dev-main#${{github.event.pull_request.head.sha}} --no-update if: ${{ github.event_name == 'pull_request' }} - run: composer install --ansi From 4dbe962d1ea7daaeaaacbb484c23874c2b70ad65 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:06:11 +0700 Subject: [PATCH 07/16] fix test --- .../FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc index ca773fdd9d9..7bdc91de5ee 100644 --- a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc +++ b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc @@ -44,7 +44,7 @@ class Fixture } $output = []; - echo(json_encode($output, JSON_THROW_ON_ERROR)); + echo(json_encode($output)); } } From 09c48345eb9a1f7cd33f74300d1481e1b617658a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:08:32 +0700 Subject: [PATCH 08/16] fix --- .../FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc index 7bdc91de5ee..69fc0964e6d 100644 --- a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc +++ b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/fixture.php.inc @@ -8,16 +8,19 @@ class Fixture { $user = $_REQUEST['param']; + // add JSON_THROW_ON_ERROR on NON-exact value $user = json_decode($user); $condition = true; if ($condition) { $output = []; + // skip add JSON_THROW_ON_ERROR on exact value echo(json_encode($output)); exit; } $output = []; + // skip add JSON_THROW_ON_ERROR on exact value echo(json_encode($output)); } } @@ -34,16 +37,19 @@ class Fixture { $user = $_REQUEST['param']; + // add JSON_THROW_ON_ERROR on NON-exact value $user = json_decode($user, null, 512, JSON_THROW_ON_ERROR); $condition = true; if ($condition) { $output = []; + // skip add JSON_THROW_ON_ERROR on exact value echo(json_encode($output)); exit; } $output = []; + // skip add JSON_THROW_ON_ERROR on exact value echo(json_encode($output)); } } From a97e6a2610b1bca36c1b405a86f01a4b4410e48f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:11:23 +0700 Subject: [PATCH 09/16] add more fixture --- ...xact_value_after_unreachable_stmts.php.inc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts.php.inc diff --git a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts.php.inc b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts.php.inc new file mode 100644 index 00000000000..f3ccd3a5aae --- /dev/null +++ b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts.php.inc @@ -0,0 +1,45 @@ + +----- + From 01e2cd87e49eec24c10e530e37084e7ef2fefc23 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:15:29 +0700 Subject: [PATCH 10/16] more fixture --- ...act_value_after_unreachable_stmts2.php.inc | 51 +++++++++++++++++++ ...ter_unreachable_stmts_on_top_level.php.inc | 33 ++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts2.php.inc create mode 100644 tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts_on_top_level.php.inc diff --git a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts2.php.inc b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts2.php.inc new file mode 100644 index 00000000000..1ead7870b06 --- /dev/null +++ b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts2.php.inc @@ -0,0 +1,51 @@ + +----- + diff --git a/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts_on_top_level.php.inc b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts_on_top_level.php.inc new file mode 100644 index 00000000000..400ae26a00e --- /dev/null +++ b/tests/Issues/ScopeNotAvailable/FixtureJsonThrowCaseSensitiveConstFetch/non_exact_value_after_unreachable_stmts_on_top_level.php.inc @@ -0,0 +1,33 @@ + +----- + From 86b0a62232f0742bf6982528e35577d911641a89 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:20:03 +0700 Subject: [PATCH 11/16] fix --- .../Scope/PHPStanNodeScopeResolver.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 6abab160047..9d87fbc1702 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -184,7 +184,7 @@ public function processNodes( // early check here as UnreachableStatementNode is special VirtualNode // so node to be checked inside if ($node instanceof UnreachableStatementNode) { - $this->processUnreachableStatementNode($node, $filePath, $mutatingScope); + $this->processUnreachableStatementNode($node, $mutatingScope, $nodeCallback); return; } @@ -573,16 +573,26 @@ private function processTryCatch(TryCatch $tryCatch, MutatingScope $mutatingScop } } + /** + * @param callable(Node $node, MutatingScope $scope): void $nodeCallback + */ private function processUnreachableStatementNode( UnreachableStatementNode $unreachableStatementNode, - string $filePath, - MutatingScope $mutatingScope + MutatingScope $mutatingScope, + callable $nodeCallback ): void { $originalStmt = $unreachableStatementNode->getOriginalStatement(); $originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); - $originalStmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); - $this->processNodes(array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()), $filePath, $mutatingScope); + foreach ($unreachableStatementNode->getNextStatements() as $nextStatement) { + $nextStatement->setAttribute(AttributeKey::IS_UNREACHABLE, true); + } + + $this->nodeScopeResolverProcessNodes( + array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()), + $mutatingScope, + $nodeCallback + ); } /** From 12369f7d4b2e5f3db65756b0e6da80594bd5d117 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 2 Jan 2025 13:21:49 +0000 Subject: [PATCH 12/16] [ci-review] Rector Rectify --- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 9d87fbc1702..30d74c71a1b 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -584,8 +584,8 @@ private function processUnreachableStatementNode( $originalStmt = $unreachableStatementNode->getOriginalStatement(); $originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); - foreach ($unreachableStatementNode->getNextStatements() as $nextStatement) { - $nextStatement->setAttribute(AttributeKey::IS_UNREACHABLE, true); + foreach ($unreachableStatementNode->getNextStatements() as $stmt) { + $stmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); } $this->nodeScopeResolverProcessNodes( From e0f2c7ddb439f9a333c7f86db4d7ed2c89c6b248 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:29:22 +0700 Subject: [PATCH 13/16] remove unused flag IS_UNREACHABLE attribute --- .phpstorm.meta.php | 2 -- src/NodeTypeResolver/Node/AttributeKey.php | 5 ----- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 5 ----- 3 files changed, 12 deletions(-) diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index c677c8cad5c..72d8b1498c8 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -49,7 +49,6 @@ \Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, \Rector\NodeTypeResolver\Node\AttributeKey::REPRINT_RAW_VALUE, \Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, - \Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE, \Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, \Rector\NodeTypeResolver\Node\AttributeKey::KIND, \Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, @@ -64,7 +63,6 @@ \Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, \Rector\NodeTypeResolver\Node\AttributeKey::REPRINT_RAW_VALUE, \Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, - \Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE, \Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, \Rector\NodeTypeResolver\Node\AttributeKey::KIND, \Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index 0d0a1ac034a..ab79c476571 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -71,11 +71,6 @@ final class AttributeKey */ public const KIND = 'kind'; - /** - * @var string - */ - public const IS_UNREACHABLE = 'isUnreachable'; - /** * @var string */ diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 30d74c71a1b..05f1adbdb68 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -582,11 +582,6 @@ private function processUnreachableStatementNode( callable $nodeCallback ): void { $originalStmt = $unreachableStatementNode->getOriginalStatement(); - $originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); - - foreach ($unreachableStatementNode->getNextStatements() as $stmt) { - $stmt->setAttribute(AttributeKey::IS_UNREACHABLE, true); - } $this->nodeScopeResolverProcessNodes( array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()), From b01e81c74d98009d513d95131139d5b82b7215c3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:38:17 +0700 Subject: [PATCH 14/16] add unreachable statement test on UnnecessaryTernaryExpressionRector --- .../Fixture/fixture_unreachable.php.inc | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc diff --git a/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc new file mode 100644 index 00000000000..766cbbac2ec --- /dev/null +++ b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc @@ -0,0 +1,55 @@ + +----- + From b2fba0bc1bbaebe8d93d76e92544b7687effd175 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:38:52 +0700 Subject: [PATCH 15/16] add unreachable statement test on UnnecessaryTernaryExpressionRector --- .../Fixture/fixture_unreachable.php.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc index 766cbbac2ec..bb5a330b660 100644 --- a/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc +++ b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc @@ -24,6 +24,8 @@ class B } } +$order || $oldOrder ? true : false; + ?> ----- From c465525a12efc6adf63800edeaa5af83f946f17c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 2 Jan 2025 20:43:28 +0700 Subject: [PATCH 16/16] fixture name conflict fix --- .../Fixture/fixture_unreachable.php.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc index bb5a330b660..e97d513cefd 100644 --- a/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc +++ b/rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture_unreachable.php.inc @@ -6,7 +6,7 @@ if (true) { echo 'test'; -class A +class FixtureUnreachableA { public function run($order, $oldOrder) { @@ -16,7 +16,7 @@ class A $order || $oldOrder ? true : false; -class B +class FixtureUnreachableB { public function run($order, $oldOrder) { @@ -36,7 +36,7 @@ if (true) { echo 'test'; -class A +class FixtureUnreachableA { public function run($order, $oldOrder) { @@ -46,7 +46,7 @@ class A $order || $oldOrder; -class B +class FixtureUnreachableB { public function run($order, $oldOrder) {