Skip to content

Commit b4775d0

Browse files
committed
Updated Rector to commit 9e4dc598b59992584b4c9c13822cb409cde0d2e9
rectorphp/rector-src@9e4dc59 [DeadCode] Skip (void) cast with #[NoDiscard] on target method call on RemoveDeadStmtRector (#8038)
1 parent fc13aff commit b4775d0

8 files changed

Lines changed: 86 additions & 8 deletions

File tree

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@
16681668
'Rector\\DowngradePhp80\\Rector\\Enum_\\DowngradeEnumToConstantListClassRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php',
16691669
'Rector\\DowngradePhp80\\Rector\\Expression\\DowngradeMatchToSwitchRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php',
16701670
'Rector\\DowngradePhp80\\Rector\\Expression\\DowngradeThrowExprRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php',
1671+
'Rector\\DowngradePhp80\\Rector\\Foreach_\\DowngradeDomNodeChildNodesForeachRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Foreach_/DowngradeDomNodeChildNodesForeachRector.php',
16711672
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeArrayFilterNullableCallbackRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php',
16721673
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeNumberFormatNoFourthArgRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php',
16731674
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeStrContainsRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ class ComposerStaticInit66a3c22cfbd40cb049dcb2d9e47672e9
19281928
'Rector\\DowngradePhp80\\Rector\\Enum_\\DowngradeEnumToConstantListClassRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Enum_/DowngradeEnumToConstantListClassRector.php',
19291929
'Rector\\DowngradePhp80\\Rector\\Expression\\DowngradeMatchToSwitchRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector.php',
19301930
'Rector\\DowngradePhp80\\Rector\\Expression\\DowngradeThrowExprRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Expression/DowngradeThrowExprRector.php',
1931+
'Rector\\DowngradePhp80\\Rector\\Foreach_\\DowngradeDomNodeChildNodesForeachRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/Foreach_/DowngradeDomNodeChildNodesForeachRector.php',
19311932
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeArrayFilterNullableCallbackRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php',
19321933
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeNumberFormatNoFourthArgRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeNumberFormatNoFourthArgRector.php',
19331934
'Rector\\DowngradePhp80\\Rector\\FuncCall\\DowngradeStrContainsRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp80/Rector/FuncCall/DowngradeStrContainsRector.php',

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,12 +1740,12 @@
17401740
"source": {
17411741
"type": "git",
17421742
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
1743-
"reference": "d0de6dc59159fed62aaa5d87626996071dcaeef7"
1743+
"reference": "391a44dd0e9e2f74978295e784ae341028c5faba"
17441744
},
17451745
"dist": {
17461746
"type": "zip",
1747-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/d0de6dc59159fed62aaa5d87626996071dcaeef7",
1748-
"reference": "d0de6dc59159fed62aaa5d87626996071dcaeef7",
1747+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/391a44dd0e9e2f74978295e784ae341028c5faba",
1748+
"reference": "391a44dd0e9e2f74978295e784ae341028c5faba",
17491749
"shasum": ""
17501750
},
17511751
"require": {
@@ -1770,7 +1770,7 @@
17701770
"tomasvotruba\/unused-public": "^2.2",
17711771
"tracy\/tracy": "^2.11"
17721772
},
1773-
"time": "2026-05-31T01:50:17+00:00",
1773+
"time": "2026-06-14T07:32:38+00:00",
17741774
"default-branch": true,
17751775
"type": "rector-extension",
17761776
"extra": {

vendor/composer/installed.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

vendor/rector/extension-installer/src/GeneratedConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class GeneratedConfig
1111
{
12-
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 10af23b'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main d0de6dc'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 0dbd58c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 30f4022'));
12+
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 10af23b'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 391a44d'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 0dbd58c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 30f4022'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-downgrade-php/config/set/downgrade-php80.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Rector\DowngradePhp80\Rector\Enum_\DowngradeEnumToConstantListClassRector;
2020
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
2121
use Rector\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector;
22+
use Rector\DowngradePhp80\Rector\Foreach_\DowngradeDomNodeChildNodesForeachRector;
2223
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector;
2324
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeNumberFormatNoFourthArgRector;
2425
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector;
@@ -54,5 +55,5 @@
5455
// Jetbrains\PhpStorm\Language under nette/utils
5556
new DowngradeAttributeToAnnotation('Jetbrains\PhpStorm\Language', 'language'),
5657
]);
57-
$rectorConfig->rules([DowngradeNamedArgumentRector::class, DowngradeDereferenceableOperationRector::class, DowngradeUnionTypeTypedPropertyRector::class, DowngradeUnionTypeDeclarationRector::class, DowngradeMixedTypeDeclarationRector::class, DowngradeStaticTypeDeclarationRector::class, DowngradeAbstractPrivateMethodInTraitRector::class, DowngradePropertyPromotionRector::class, DowngradeNonCapturingCatchesRector::class, DowngradeStrContainsRector::class, DowngradeMatchToSwitchRector::class, DowngradeClassOnObjectToGetClassRector::class, DowngradeArbitraryExpressionsSupportRector::class, DowngradeNullsafeToTernaryOperatorRector::class, DowngradeTrailingCommasInParamUseRector::class, DowngradeStrStartsWithRector::class, DowngradeStrEndsWithRector::class, DowngradePhpTokenRector::class, DowngradeThrowExprRector::class, DowngradePhp80ResourceReturnToObjectRector::class, DowngradeReflectionGetAttributesRector::class, DowngradeRecursiveDirectoryIteratorHasChildrenRector::class, DowngradeReflectionPropertyGetDefaultValueRector::class, DowngradeReflectionClassGetConstantsFilterRector::class, DowngradeArrayFilterNullableCallbackRector::class, DowngradeNumberFormatNoFourthArgRector::class, DowngradeStringReturnTypeOnToStringRector::class, DowngradeMixedTypeTypedPropertyRector::class, RemoveReturnTypeDeclarationFromCloneRector::class, DowngradeEnumToConstantListClassRector::class, DowngradeInstanceofStringableRector::class, DowngradeSubstrFalsyRector::class]);
58+
$rectorConfig->rules([DowngradeNamedArgumentRector::class, DowngradeDereferenceableOperationRector::class, DowngradeUnionTypeTypedPropertyRector::class, DowngradeUnionTypeDeclarationRector::class, DowngradeMixedTypeDeclarationRector::class, DowngradeStaticTypeDeclarationRector::class, DowngradeAbstractPrivateMethodInTraitRector::class, DowngradePropertyPromotionRector::class, DowngradeNonCapturingCatchesRector::class, DowngradeStrContainsRector::class, DowngradeMatchToSwitchRector::class, DowngradeClassOnObjectToGetClassRector::class, DowngradeArbitraryExpressionsSupportRector::class, DowngradeNullsafeToTernaryOperatorRector::class, DowngradeTrailingCommasInParamUseRector::class, DowngradeStrStartsWithRector::class, DowngradeStrEndsWithRector::class, DowngradePhpTokenRector::class, DowngradeThrowExprRector::class, DowngradeDomNodeChildNodesForeachRector::class, DowngradePhp80ResourceReturnToObjectRector::class, DowngradeReflectionGetAttributesRector::class, DowngradeRecursiveDirectoryIteratorHasChildrenRector::class, DowngradeReflectionPropertyGetDefaultValueRector::class, DowngradeReflectionClassGetConstantsFilterRector::class, DowngradeArrayFilterNullableCallbackRector::class, DowngradeNumberFormatNoFourthArgRector::class, DowngradeStringReturnTypeOnToStringRector::class, DowngradeMixedTypeTypedPropertyRector::class, RemoveReturnTypeDeclarationFromCloneRector::class, DowngradeEnumToConstantListClassRector::class, DowngradeInstanceofStringableRector::class, DowngradeSubstrFalsyRector::class]);
5859
};
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare (strict_types=1);
4+
namespace Rector\DowngradePhp80\Rector\Foreach_;
5+
6+
use PhpParser\Node;
7+
use PhpParser\Node\Expr\Array_;
8+
use PhpParser\Node\Expr\BinaryOp\Coalesce;
9+
use PhpParser\Node\Expr\PropertyFetch;
10+
use PhpParser\Node\Stmt\Foreach_;
11+
use PHPStan\Type\ObjectType;
12+
use Rector\Rector\AbstractRector;
13+
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
14+
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
15+
/**
16+
* @changelog https://github.com/php/php-src/pull/5180 https://bugs.php.net/bug.php?id=79271
17+
*
18+
* As of PHP 8.0 DOMNode::$childNodes always returns a DOMNodeList. On older
19+
* versions it returns null for nodes that cannot have children (e.g. DOMText),
20+
* which makes a foreach over it emit "Invalid argument supplied for foreach()".
21+
*
22+
* @see \Rector\Tests\DowngradePhp80\Rector\Foreach_\DowngradeDomNodeChildNodesForeachRector\DowngradeDomNodeChildNodesForeachRectorTest
23+
*/
24+
final class DowngradeDomNodeChildNodesForeachRector extends AbstractRector
25+
{
26+
public function getRuleDefinition(): RuleDefinition
27+
{
28+
return new RuleDefinition('Add null coalesce to a foreach over DOMNode::$childNodes, as it can be null before PHP 8.0', [new CodeSample(<<<'CODE_SAMPLE'
29+
function run(\DOMNode $node)
30+
{
31+
foreach ($node->childNodes as $childNode) {
32+
echo $childNode->nodeValue;
33+
}
34+
}
35+
CODE_SAMPLE
36+
, <<<'CODE_SAMPLE'
37+
function run(\DOMNode $node)
38+
{
39+
foreach ($node->childNodes ?? [] as $childNode) {
40+
echo $childNode->nodeValue;
41+
}
42+
}
43+
CODE_SAMPLE
44+
)]);
45+
}
46+
/**
47+
* @return array<class-string<Node>>
48+
*/
49+
public function getNodeTypes(): array
50+
{
51+
return [Foreach_::class];
52+
}
53+
/**
54+
* @param Foreach_ $node
55+
*/
56+
public function refactor(Node $node): ?Node
57+
{
58+
$iteratedExpr = $node->expr;
59+
if (!$iteratedExpr instanceof PropertyFetch) {
60+
return null;
61+
}
62+
if (!$this->isName($iteratedExpr->name, 'childNodes')) {
63+
return null;
64+
}
65+
$callerType = $this->nodeTypeResolver->getType($iteratedExpr->var);
66+
if (!$callerType instanceof ObjectType) {
67+
return null;
68+
}
69+
if (!$callerType->isInstanceOf('DOMNode')->yes()) {
70+
return null;
71+
}
72+
$node->expr = new Coalesce($iteratedExpr, new Array_([]));
73+
return $node;
74+
}
75+
}

vendor/symfony/console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function describeApplication(Application $application, array $options
120120
*/
121121
private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent): void
122122
{
123-
foreach ($importedParent->childNodes as $childNode) {
123+
foreach ($importedParent->childNodes ?? [] as $childNode) {
124124
$parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, \true));
125125
}
126126
}

0 commit comments

Comments
 (0)