Skip to content

Commit 81bc030

Browse files
committed
Updated Rector to commit 4997962de1f53c449dadbef7025bffe5ca41e63c
rectorphp/rector-src@4997962 Bump PHPStan to 2.1.38 (#7879)
1 parent 417c0c0 commit 81bc030

9 files changed

Lines changed: 130 additions & 78 deletions

File tree

rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use PhpParser\Node;
77
use PhpParser\Node\Arg;
8-
use PhpParser\Node\Expr;
98
use PhpParser\Node\Expr\ConstFetch;
109
use PhpParser\Node\Expr\FuncCall;
1110
use PhpParser\Node\Identifier;
@@ -33,10 +32,6 @@ final class JsonThrowOnErrorRector extends AbstractRector implements MinPhpVersi
3332
*/
3433
private BetterNodeFinder $betterNodeFinder;
3534
private bool $hasChanged = \false;
36-
/**
37-
* @var mixed[]
38-
*/
39-
private const FLAGS = ['JSON_THROW_ON_ERROR'];
4035
public function __construct(ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder)
4136
{
4237
$this->valueResolver = $valueResolver;
@@ -61,6 +56,9 @@ public function getNodeTypes(): array
6156
{
6257
return NodeGroup::STMTS_AWARE;
6358
}
59+
/**
60+
* @param StmtsAware $node
61+
*/
6462
public function refactor(Node $node): ?Node
6563
{
6664
// if found, skip it :)
@@ -111,28 +109,19 @@ private function shouldSkipFuncCall(FuncCall $funcCall): bool
111109
}
112110
return $this->isFirstValueStringOrArray($funcCall);
113111
}
114-
private function processJsonEncode(FuncCall $funcCall): FuncCall
112+
private function processJsonEncode(FuncCall $funcCall): ?FuncCall
115113
{
116-
$flags = [];
117114
if (isset($funcCall->args[1])) {
118-
/** @var Arg $arg */
119-
$arg = $funcCall->args[1];
120-
$flags = $this->getFlags($arg);
121-
}
122-
$newArg = $this->getArgWithFlags($flags);
123-
if ($newArg instanceof Arg) {
124-
$this->hasChanged = \true;
125-
$funcCall->args[1] = $newArg;
115+
return null;
126116
}
117+
$this->hasChanged = \true;
118+
$funcCall->args[1] = new Arg($this->createConstFetch('JSON_THROW_ON_ERROR'));
127119
return $funcCall;
128120
}
129-
private function processJsonDecode(FuncCall $funcCall): FuncCall
121+
private function processJsonDecode(FuncCall $funcCall): ?FuncCall
130122
{
131-
$flags = [];
132123
if (isset($funcCall->args[3])) {
133-
/** @var Arg $arg */
134-
$arg = $funcCall->args[3];
135-
$flags = $this->getFlags($arg);
124+
return null;
136125
}
137126
// set default to inter-args
138127
if (!isset($funcCall->args[1])) {
@@ -141,11 +130,8 @@ private function processJsonDecode(FuncCall $funcCall): FuncCall
141130
if (!isset($funcCall->args[2])) {
142131
$funcCall->args[2] = new Arg(new Int_(512));
143132
}
144-
$newArg = $this->getArgWithFlags($flags);
145-
if ($newArg instanceof Arg) {
146-
$this->hasChanged = \true;
147-
$funcCall->args[3] = $newArg;
148-
}
133+
$this->hasChanged = \true;
134+
$funcCall->args[3] = new Arg($this->createConstFetch('JSON_THROW_ON_ERROR'));
149135
return $funcCall;
150136
}
151137
private function createConstFetch(string $name): ConstFetch
@@ -164,49 +150,4 @@ private function isFirstValueStringOrArray(FuncCall $funcCall): bool
164150
}
165151
return is_array($value);
166152
}
167-
/**
168-
* @param string[] $flags
169-
* @return string[]
170-
* @param \PhpParser\Node\Expr|\PhpParser\Node\Arg $arg
171-
*/
172-
private function getFlags($arg, array $flags = []): array
173-
{
174-
// Unwrap Arg
175-
if ($arg instanceof Arg) {
176-
$arg = $arg->value;
177-
}
178-
// Single flag: SOME_CONST
179-
if ($arg instanceof ConstFetch) {
180-
$flags[] = $arg->name->getFirst();
181-
return $flags;
182-
}
183-
// Multiple flags: FLAG_A | FLAG_B | FLAG_C
184-
if ($arg instanceof Node\Expr\BinaryOp\BitwiseOr) {
185-
$flags = $this->getFlags($arg->left, $flags);
186-
$flags = $this->getFlags($arg->right, $flags);
187-
}
188-
return array_values(array_unique($flags));
189-
// array_unique in case the same flag is written multiple times
190-
}
191-
/**
192-
* @param string[] $flags
193-
*/
194-
private function getArgWithFlags(array $flags): ?Arg
195-
{
196-
$originalCount = count($flags);
197-
$flags = array_values(array_unique(array_merge($flags, self::FLAGS)));
198-
if ($originalCount === count($flags)) {
199-
return null;
200-
}
201-
// Single flag
202-
if (count($flags) === 1) {
203-
return new Arg($this->createConstFetch($flags[0]));
204-
}
205-
// Build FLAG_A | FLAG_B | FLAG_C
206-
$expr = $this->createConstFetch(array_shift($flags));
207-
foreach ($flags as $flag) {
208-
$expr = new Node\Expr\BinaryOp\BitwiseOr($expr, $this->createConstFetch($flag));
209-
}
210-
return new Arg($expr);
211-
}
212153
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'eafa741300fbf80dcf6c1ae89b06984b6664f5d3';
22+
public const PACKAGE_VERSION = '4997962de1f53c449dadbef7025bffe5ca41e63c';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-02-05 05:13:28';
27+
public const RELEASE_DATE = '2026-02-03 23:37:44';
2828
/**
2929
* @var int
3030
*/

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,7 @@
19791979
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\YieldDataProviderRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php',
19801980
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\AssertArrayCastedObjectToAssertSameRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/AssertArrayCastedObjectToAssertSameRector.php',
19811981
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\ConfiguredMockEntityToSetterObjectRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/ConfiguredMockEntityToSetterObjectRector.php',
1982+
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\DecorateWillReturnMapWithExpectsMockRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/DecorateWillReturnMapWithExpectsMockRector.php',
19821983
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
19831984
'Rector\\PHPUnit\\CodeQuality\\Rector\\FuncCall\\AssertFuncCallToPHPUnitAssertRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/FuncCall/AssertFuncCallToPHPUnitAssertRector.php',
19841985
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertCompareOnCountableWithMethodToAssertCountRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertCompareOnCountableWithMethodToAssertCountRector.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,7 @@ class ComposerStaticInit6374fd21a3f525a40760d79e3596b56b
22392239
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\YieldDataProviderRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/YieldDataProviderRector.php',
22402240
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\AssertArrayCastedObjectToAssertSameRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/AssertArrayCastedObjectToAssertSameRector.php',
22412241
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\ConfiguredMockEntityToSetterObjectRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/ConfiguredMockEntityToSetterObjectRector.php',
2242+
'Rector\\PHPUnit\\CodeQuality\\Rector\\Expression\\DecorateWillReturnMapWithExpectsMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Expression/DecorateWillReturnMapWithExpectsMockRector.php',
22422243
'Rector\\PHPUnit\\CodeQuality\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
22432244
'Rector\\PHPUnit\\CodeQuality\\Rector\\FuncCall\\AssertFuncCallToPHPUnitAssertRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/FuncCall/AssertFuncCallToPHPUnitAssertRector.php',
22442245
'Rector\\PHPUnit\\CodeQuality\\Rector\\MethodCall\\AssertCompareOnCountableWithMethodToAssertCountRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/MethodCall/AssertCompareOnCountableWithMethodToAssertCountRector.php',

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,12 +1818,12 @@
18181818
"source": {
18191819
"type": "git",
18201820
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1821-
"reference": "5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2"
1821+
"reference": "a791fc9b0f653b5bb79d4f5f1df40eebecaad556"
18221822
},
18231823
"dist": {
18241824
"type": "zip",
1825-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2",
1826-
"reference": "5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2",
1825+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/a791fc9b0f653b5bb79d4f5f1df40eebecaad556",
1826+
"reference": "a791fc9b0f653b5bb79d4f5f1df40eebecaad556",
18271827
"shasum": ""
18281828
},
18291829
"require": {
@@ -1850,7 +1850,7 @@
18501850
"tomasvotruba\/unused-public": "^2.2",
18511851
"tracy\/tracy": "^2.11"
18521852
},
1853-
"time": "2026-02-04T21:49:54+00:00",
1853+
"time": "2026-02-04T23:04:08+00:00",
18541854
"default-branch": true,
18551855
"type": "rector-extension",
18561856
"extra": {

0 commit comments

Comments
 (0)