Skip to content

Commit 8268aba

Browse files
committed
Updated Rector to commit a6b5203bd0e91d73d38e4036a9cf1d20301bae01
rectorphp/rector-src@a6b5203 [Php81] Handle crash on normal array with variadic inside class on ArrayToFirstClassCallableRector (#7966)
1 parent 5db5afc commit 8268aba

8 files changed

Lines changed: 130 additions & 45 deletions

File tree

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 = '4273c1667357ac77e4d6ebf63846cff2b17c4879';
22+
public const PACKAGE_VERSION = 'a6b5203bd0e91d73d38e4036a9cf1d20301bae01';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-04-09 11:35:23';
27+
public const RELEASE_DATE = '2026-04-11 00:24:53';
2828
/**
2929
* @var int
3030
*/

src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php

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

66
use Error;
77
use PhpParser\Node;
8-
use PhpParser\Node\Arg;
98
use PhpParser\Node\ArrayItem;
109
use PhpParser\Node\Expr;
1110
use PhpParser\Node\Expr\Array_;
@@ -245,10 +244,6 @@ public function processNodes(array $stmts, string $filePath, ?MutatingScope $for
245244
$this->processBinaryOp($node, $mutatingScope);
246245
return;
247246
}
248-
if ($node instanceof Arg) {
249-
$node->value->setAttribute(AttributeKey::SCOPE, $mutatingScope);
250-
return;
251-
}
252247
if ($node instanceof Foreach_) {
253248
// decorate value as well
254249
$node->valueVar->setAttribute(AttributeKey::SCOPE, $mutatingScope);
@@ -423,6 +418,12 @@ private function processCallLike(CallLike $callLike, MutatingScope $mutatingScop
423418
} elseif ($callLike instanceof New_ && !$callLike->class instanceof Class_) {
424419
$callLike->class->setAttribute(AttributeKey::SCOPE, $mutatingScope);
425420
}
421+
if ($callLike->isFirstClassCallable()) {
422+
return;
423+
}
424+
foreach ($callLike->getArgs() as $arg) {
425+
$arg->value->setAttribute(AttributeKey::SCOPE, $mutatingScope);
426+
}
426427
}
427428
/**
428429
* @param \PhpParser\Node\Expr\Assign|\PhpParser\Node\Expr\AssignOp|\PhpParser\Node\Expr\AssignRef $assign

vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,17 +3301,17 @@
33013301
},
33023302
{
33033303
"name": "webmozart\/assert",
3304-
"version": "2.1.6",
3305-
"version_normalized": "2.1.6.0",
3304+
"version": "2.2.0",
3305+
"version_normalized": "2.2.0.0",
33063306
"source": {
33073307
"type": "git",
33083308
"url": "https:\/\/github.com\/webmozarts\/assert.git",
3309-
"reference": "ff31ad6efc62e66e518fbab1cde3453d389bcdc8"
3309+
"reference": "1b99650e7ffcad232624a260bc7fbdec2ffc407c"
33103310
},
33113311
"dist": {
33123312
"type": "zip",
3313-
"url": "https:\/\/api.github.com\/repos\/webmozarts\/assert\/zipball\/ff31ad6efc62e66e518fbab1cde3453d389bcdc8",
3314-
"reference": "ff31ad6efc62e66e518fbab1cde3453d389bcdc8",
3313+
"url": "https:\/\/api.github.com\/repos\/webmozarts\/assert\/zipball\/1b99650e7ffcad232624a260bc7fbdec2ffc407c",
3314+
"reference": "1b99650e7ffcad232624a260bc7fbdec2ffc407c",
33153315
"shasum": ""
33163316
},
33173317
"require": {
@@ -3325,7 +3325,7 @@
33253325
"ext-simplexml": "",
33263326
"ext-spl": ""
33273327
},
3328-
"time": "2026-02-27T10:28:38+00:00",
3328+
"time": "2026-04-09T16:54:47+00:00",
33293329
"type": "library",
33303330
"extra": {
33313331
"branch-alias": {
@@ -3360,7 +3360,7 @@
33603360
],
33613361
"support": {
33623362
"issues": "https:\/\/github.com\/webmozarts\/assert\/issues",
3363-
"source": "https:\/\/github.com\/webmozarts\/assert\/tree\/2.1.6"
3363+
"source": "https:\/\/github.com\/webmozarts\/assert\/tree\/2.2.0"
33643364
},
33653365
"install-path": "..\/webmozart\/assert"
33663366
}

vendor/composer/installed.php

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

vendor/webmozart/assert/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
## 2.2.0
5+
6+
### Added
7+
8+
- Added `isNotInstanceOfAny` assertion.
9+
410
## 2.1.6
511

612
### Fixed

vendor/webmozart/assert/README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,37 @@ The [`Assert`] class provides the following assertions:
8282

8383
### Type Assertions
8484

85-
Method | Description
86-
-------------------------------------------------------- | --------------------------------------------------
87-
`string($value, $message = '')` | Check that a value is a string
88-
`stringNotEmpty($value, $message = '')` | Check that a value is a non-empty string
89-
`integer($value, $message = '')` | Check that a value is an integer
90-
`integerish($value, $message = '')` | Check that a value casts to an integer
91-
`positiveInteger($value, $message = '')` | Check that a value is a positive (non-zero) integer
92-
`negativeInteger($value, $message = '')` | Check that a value is a negative integer
93-
`notNegativeInteger($value, $message = '')` | Check that a value is a non-negative integer
94-
`float($value, $message = '')` | Check that a value is a float
95-
`numeric($value, $message = '')` | Check that a value is numeric
96-
`natural($value, $message = '')` | Check that a value is a non-negative integer
97-
`boolean($value, $message = '')` | Check that a value is a boolean
98-
`scalar($value, $message = '')` | Check that a value is a scalar
99-
`object($value, $message = '')` | Check that a value is an object
100-
`objectish($value, $message = '')` | Check that a value is an object or a string of a class that exists
101-
`resource($value, $type = null, $message = '')` | Check that a value is a resource
102-
`isInitialized($value, $property, $message = '')` | Check that a value has an initialized property
103-
`isCallable($value, $message = '')` | Check that a value is a callable
104-
`isArray($value, $message = '')` | Check that a value is an array
105-
`isIterable($value, $message = '')` | Check that a value is an array or a `\Traversable`
106-
`isCountable($value, $message = '')` | Check that a value is an array or a `\Countable`
107-
`isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class
108-
`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` at least one class on the array of classes
109-
`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class
110-
`isAOf($value, $class, $message = '')` | Check that a value is of the class or has one of its parents
111-
`isAnyOf($value, array $classes, $message = '')` | Check that a value is of at least one of the classes or has one of its parents
112-
`isNotA($value, $class, $message = '')` | Check that a value is not of the class or has not one of its parents
113-
`isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array
114-
`uniqueValues($values, $message = '')` | Check that the given array contains unique values
85+
Method | Description
86+
----------------------------------------------------------- | --------------------------------------------------
87+
`string($value, $message = '')` | Check that a value is a string
88+
`stringNotEmpty($value, $message = '')` | Check that a value is a non-empty string
89+
`integer($value, $message = '')` | Check that a value is an integer
90+
`integerish($value, $message = '')` | Check that a value casts to an integer
91+
`positiveInteger($value, $message = '')` | Check that a value is a positive (non-zero) integer
92+
`negativeInteger($value, $message = '')` | Check that a value is a negative integer
93+
`notNegativeInteger($value, $message = '')` | Check that a value is a non-negative integer
94+
`float($value, $message = '')` | Check that a value is a float
95+
`numeric($value, $message = '')` | Check that a value is numeric
96+
`natural($value, $message = '')` | Check that a value is a non-negative integer
97+
`boolean($value, $message = '')` | Check that a value is a boolean
98+
`scalar($value, $message = '')` | Check that a value is a scalar
99+
`object($value, $message = '')` | Check that a value is an object
100+
`objectish($value, $message = '')` | Check that a value is an object or a string of a class that exists
101+
`resource($value, $type = null, $message = '')` | Check that a value is a resource
102+
`isInitialized($value, $property, $message = '')` | Check that a value has an initialized property
103+
`isCallable($value, $message = '')` | Check that a value is a callable
104+
`isArray($value, $message = '')` | Check that a value is an array
105+
`isIterable($value, $message = '')` | Check that a value is an array or a `\Traversable`
106+
`isCountable($value, $message = '')` | Check that a value is an array or a `\Countable`
107+
`isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class
108+
`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` at least one class on the array of classes
109+
`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class
110+
`isNotInstanceOfAny($value, array $classes, $message = '')` | Check that a value is not an `instanceof` at least one class on the array of classes
111+
`isAOf($value, $class, $message = '')` | Check that a value is of the class or has one of its parents
112+
`isAnyOf($value, array $classes, $message = '')` | Check that a value is of at least one of the classes or has one of its parents
113+
`isNotA($value, $class, $message = '')` | Check that a value is not of the class or has not one of its parents
114+
`isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array
115+
`uniqueValues($values, $message = '')` | Check that the given array contains unique values
115116

116117
### Comparison Assertions
117118

vendor/webmozart/assert/src/Assert.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,29 @@ public static function isInstanceOfAny($value, $classes, string $message = ''):
445445
}
446446
static::reportInvalidArgument(\sprintf($message ?: 'Expected an instance of any of %2$s. Got: %s', static::typeToString($value), \implode(', ', \array_map(\Closure::fromCallable([static::class, 'valueToString']), \iterator_to_array(is_array($classes) ? new \ArrayIterator($classes) : $classes)))));
447447
}
448+
/**
449+
* @template T
450+
*
451+
* @psalm-assert T $value
452+
*
453+
* @param mixed $value
454+
*
455+
* @return T
456+
*
457+
* @throws InvalidArgumentException
458+
* @param mixed $classes
459+
*/
460+
public static function isNotInstanceOfAny($value, $classes, string $message = '')
461+
{
462+
static::isIterable($classes);
463+
foreach ($classes as $class) {
464+
static::string($class, 'Expected class as a string. Got: %s');
465+
if ($value instanceof $class) {
466+
static::reportInvalidArgument(\sprintf($message ?: 'Expected not an instance of %2$s. Got: %s', static::typeToString($value), \implode(', ', \array_map(\Closure::fromCallable([static::class, 'valueToString']), \iterator_to_array(is_array($classes) ? new \ArrayIterator($classes) : $classes)))));
467+
}
468+
}
469+
return $value;
470+
}
448471
/**
449472
* @psalm-pure
450473
*

vendor/webmozart/assert/src/Mixin.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,60 @@ public static function allNullOrIsInstanceOfAny($value, $classes, string $messag
12021202
}
12031203
return $value;
12041204
}
1205+
/**
1206+
* @template T
1207+
* @psalm-assert T|null $value
1208+
*
1209+
* @param mixed $value
1210+
*
1211+
* @return T|null
1212+
*
1213+
* @throws InvalidArgumentException
1214+
* @param mixed $classes
1215+
*/
1216+
public static function nullOrIsNotInstanceOfAny($value, $classes, string $message = '')
1217+
{
1218+
null === $value || static::isNotInstanceOfAny($value, $classes, $message);
1219+
return $value;
1220+
}
1221+
/**
1222+
* @template T
1223+
* @psalm-assert iterable<T> $value
1224+
*
1225+
* @param mixed $value
1226+
*
1227+
* @return iterable<T>
1228+
*
1229+
* @throws InvalidArgumentException
1230+
* @param mixed $classes
1231+
*/
1232+
public static function allIsNotInstanceOfAny($value, $classes, string $message = ''): iterable
1233+
{
1234+
static::isIterable($value);
1235+
foreach ($value as $entry) {
1236+
static::isNotInstanceOfAny($entry, $classes, $message);
1237+
}
1238+
return $value;
1239+
}
1240+
/**
1241+
* @template T
1242+
* @psalm-assert iterable<T|null> $value
1243+
*
1244+
* @param mixed $value
1245+
*
1246+
* @return iterable<T|null>
1247+
*
1248+
* @throws InvalidArgumentException
1249+
* @param mixed $classes
1250+
*/
1251+
public static function allNullOrIsNotInstanceOfAny($value, $classes, string $message = ''): iterable
1252+
{
1253+
static::isIterable($value);
1254+
foreach ($value as $entry) {
1255+
null === $entry || static::isNotInstanceOfAny($entry, $classes, $message);
1256+
}
1257+
return $value;
1258+
}
12051259
/**
12061260
* @psalm-pure
12071261
*

0 commit comments

Comments
 (0)