Skip to content

Commit 09a0a96

Browse files
committed
Updated Rector to commit 310fbc6b6deb990ba89e2fcc8c43d22243fd824c
rectorphp/rector-src@310fbc6 [TypeDeclaration] Skip maybe object items on AddArrowFunctionParamArrayWhereDimFetchRector (#9073)
1 parent 880dbaa commit 09a0a96

10 files changed

Lines changed: 228 additions & 150 deletions

File tree

‎rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
use PhpParser\Node\Expr\Instanceof_;
1212
use PhpParser\Node\Expr\Variable;
1313
use PhpParser\Node\Identifier;
14-
use PHPStan\Type\ArrayType;
14+
use PHPStan\Type\MixedType;
15+
use PHPStan\Type\Type;
1516
use Rector\PhpParser\Node\BetterNodeFinder;
1617
use Rector\Rector\AbstractRector;
1718
use Rector\RuleDoc\CodeSample\CodeSample;
@@ -82,7 +83,7 @@ public function refactor(Node $node): ?Node
8283
$dimFetchVariableNames = $this->resolveDimFetchVariableNames($closureExpr);
8384
// the items type does not change per closure param, resolve it once
8485
$type = $this->getType($closureItems);
85-
if ($type instanceof ArrayType && $type->getItemType()->isObject()->yes()) {
86+
if ($this->hasMaybeObjectItems($type)) {
8687
continue;
8788
}
8889
foreach ($closureExpr->getParams() as $closureParam) {
@@ -171,4 +172,18 @@ private function resolveInstanceofVariables($closureExpr): array
171172
}
172173
return $variableNames;
173174
}
175+
/**
176+
* Items that can be objects, e.g. ArrayAccess, must not be typed as array
177+
*/
178+
private function hasMaybeObjectItems(Type $type): bool
179+
{
180+
if (!$type->isArray()->yes()) {
181+
return \false;
182+
}
183+
$itemType = $type->getIterableValueType();
184+
if ($itemType instanceof MixedType) {
185+
return \false;
186+
}
187+
return !$itemType->isObject()->no();
188+
}
174189
}

‎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 = '985db83ebfd086aa9ff1df2ce82700b4e4d35920';
22+
public const PACKAGE_VERSION = '310fbc6b6deb990ba89e2fcc8c43d22243fd824c';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-11-25 17:50:27';
27+
public const RELEASE_DATE = '2026-11-26 11:27:41';
2828
/**
2929
* @var int
3030
*/

‎vendor/composer/installed.json‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,17 @@
231231
},
232232
{
233233
"name": "composer\/xdebug-handler",
234-
"version": "3.0.5",
235-
"version_normalized": "3.0.5.0",
234+
"version": "3.1.0",
235+
"version_normalized": "3.1.0.0",
236236
"source": {
237237
"type": "git",
238238
"url": "https:\/\/github.com\/composer\/xdebug-handler.git",
239-
"reference": "6c1925561632e83d60a44492e0b344cf48ab85ef"
239+
"reference": "9ade436e94b5a869a88b8306d993c25538d3b478"
240240
},
241241
"dist": {
242242
"type": "zip",
243-
"url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/6c1925561632e83d60a44492e0b344cf48ab85ef",
244-
"reference": "6c1925561632e83d60a44492e0b344cf48ab85ef",
243+
"url": "https:\/\/api.github.com\/repos\/composer\/xdebug-handler\/zipball\/9ade436e94b5a869a88b8306d993c25538d3b478",
244+
"reference": "9ade436e94b5a869a88b8306d993c25538d3b478",
245245
"shasum": ""
246246
},
247247
"require": {
@@ -250,12 +250,12 @@
250250
"psr\/log": "^1 || ^2 || ^3"
251251
},
252252
"require-dev": {
253-
"phpstan\/phpstan": "^1.0",
254-
"phpstan\/phpstan-strict-rules": "^1.1",
253+
"phpstan\/phpstan": "^1.11 || ^2.0",
254+
"phpstan\/phpstan-strict-rules": "^1.1 || ^2.0",
255255
"phpunit\/phpunit": "^8.5 || ^9.6 || ^10.5"
256256
},
257-
"time": "2024-05-06T16:37:16+00:00",
258-
"published-time": "2024-05-06T17:01:42+00:00",
257+
"time": "2026-11-25T19:20:28+00:00",
258+
"published-time": "2026-11-25T19:31:20+00:00",
259259
"type": "library",
260260
"installation-source": "dist",
261261
"autoload": {
@@ -281,7 +281,7 @@
281281
"support": {
282282
"irc": "ircs:\/\/irc.libera.chat:6697\/composer",
283283
"issues": "https:\/\/github.com\/composer\/xdebug-handler\/issues",
284-
"source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/3.0.5"
284+
"source": "https:\/\/github.com\/composer\/xdebug-handler\/tree\/3.1.0"
285285
},
286286
"funding": [
287287
{
@@ -291,10 +291,6 @@
291291
{
292292
"url": "https:\/\/github.com\/composer",
293293
"type": "github"
294-
},
295-
{
296-
"url": "https:\/\/tidelift.com\/funding\/github\/packagist\/composer\/composer",
297-
"type": "tidelift"
298294
}
299295
],
300296
"install-path": ".\/xdebug-handler"

‎vendor/composer/installed.php‎

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

‎vendor/composer/xdebug-handler/CHANGELOG.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
## [3.1.0] - 2026-11-25
4+
* Added: protected methods `outputError` and `outputInfo` for extending classes.
5+
* Added: the extending class name to logger/debug output, if applicable.
6+
37
## [3.0.5] - 2024-05-06
48
* Fixed: fail restart if PHP_BINARY is not available
59

@@ -89,7 +93,7 @@
8993
* Added: debug information using `XDEBUG_HANDLER_DEBUG`.
9094
* Added: fluent interface for setters.
9195
* Added: `PhpConfig` helper class for calling PHP sub-processes.
92-
* Added: `PHPRC` original value to restart stettings, for use in a restarted process.
96+
* Added: `PHPRC` original value to restart settings, for use in a restarted process.
9397
* Changed: internal procedure to disable ini-scanning, using `-n` command-line option.
9498
* Fixed: replaced `escapeshellarg` usage to avoid locale problems.
9599
* Fixed: improved color-option handling to respect double-dash delimiter.
@@ -115,7 +119,8 @@
115119
* Break: the following class was renamed:
116120
- `Composer\XdebugHandler` -> `Composer\XdebugHandler\XdebugHandler`
117121

118-
[Unreleased]: https://github.com/composer/xdebug-handler/compare/3.0.5...HEAD
122+
[Unreleased]: https://github.com/composer/xdebug-handler/compare/3.1.0...HEAD
123+
[3.1.0]: https://github.com/composer/xdebug-handler/compare/3.0.5...3.1.0
119124
[3.0.5]: https://github.com/composer/xdebug-handler/compare/3.0.4...3.0.5
120125
[3.0.4]: https://github.com/composer/xdebug-handler/compare/3.0.3...3.0.4
121126
[3.0.3]: https://github.com/composer/xdebug-handler/compare/3.0.2...3.0.3

‎vendor/composer/xdebug-handler/README.md‎

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ The constructor takes a single parameter, `$envPrefix`, which is upper-cased and
4242
- `MYAPP_ALLOW_XDEBUG=1` to override automatic restart and allow Xdebug
4343
- `MYAPP_ORIGINAL_INIS` to obtain ini file locations in a restarted process
4444

45+
>If the application restarts in a new PHP process, it starts from the beginning, so any code that ran before `$xdebug->check()` runs again. Call this method as early as possible to avoid repeating unnecessary work.
46+
4547
## Advanced Usage
4648

4749
* [How it works](#how-it-works)
@@ -91,13 +93,15 @@ use Composer\XdebugHandler\XdebugHandler;
9193

9294
$files = XdebugHandler::getAllIniFiles();
9395

94-
# $files[0] always exists, it could be an empty string
96+
// $files[0] always exists, it could be an empty string
9597
$loadedIni = array_shift($files);
9698
$scannedInis = $files;
9799
```
98100

99101
These locations are also available in the `MYAPP_ORIGINAL_INIS` environment variable. This is a path-separated string comprising the location returned from `php_ini_loaded_file`, which could be empty, followed by locations parsed from calling `php_ini_scanned_files`.
100102

103+
---
104+
101105
#### _getRestartSettings(): ?array_
102106
Returns an array of settings that can be used with PHP [sub-processes](#sub-processes), or null if the process was not restarted.
103107

@@ -117,6 +121,7 @@ $settings = XdebugHandler::getRestartSettings();
117121
* 'skipped' => the skipped version from getSkippedVersion (string)
118122
*/
119123
```
124+
---
120125

121126
#### _getSkippedVersion(): string_
122127
Returns the Xdebug version string that was skipped by the restart, or an empty string if there was no restart (or Xdebug is still loaded, perhaps by an extending class restarting for a reason other than removing Xdebug).
@@ -125,8 +130,9 @@ Returns the Xdebug version string that was skipped by the restart, or an empty s
125130
use Composer\XdebugHandler\XdebugHandler;
126131

127132
$version = XdebugHandler::getSkippedVersion();
128-
# $version: '3.1.1' (for example), or an empty string
133+
// $version: '3.1.1' (for example), or an empty string
129134
```
135+
---
130136

131137
#### _isXdebugActive(): bool_
132138
Returns true if Xdebug is loaded and is running in an active mode (if it supports modes). Returns false if Xdebug is not loaded, or it is running with `xdebug.mode=off`.
@@ -156,9 +162,13 @@ WARNING No restart (Unable to create temp ini file at: ...)
156162

157163
Status messages can also be output with `XDEBUG_HANDLER_DEBUG`. See [Troubleshooting](#troubleshooting).
158164

165+
---
166+
159167
#### _setMainScript(string $script): self_
160168
Sets the location of the main script to run in the restart. This is only needed in more esoteric use-cases, or if the `argv[0]` location is inaccessible. The script name `--` is supported for standard input.
161169

170+
---
171+
162172
#### _setPersistent(): self_
163173
Configures the restart using [persistent settings](#persistent-settings), so that Xdebug is not loaded in any sub-process.
164174

@@ -171,16 +181,17 @@ function SubProcessWithXdebug()
171181
{
172182
$phpConfig = new Composer\XdebugHandler\PhpConfig();
173183

174-
# Set the environment to the original configuration
184+
// Set the environment to the original configuration
175185
$phpConfig->useOriginal();
176186

177-
# run the process with Xdebug loaded
187+
// Run the process with Xdebug loaded
178188
...
179189

180-
# Restore Xdebug-free environment
190+
// Restore Xdebug-free environment
181191
$phpConfig->usePersistent();
182192
}
183193
```
194+
---
184195

185196
### Process configuration
186197
The library offers two strategies to invoke a new PHP process without loading Xdebug, using either _standard_ or _persistent_ settings. Note that this is only important if the application calls a PHP sub-process.
@@ -222,41 +233,55 @@ use Composer\XdebugHandler\PhpConfig;
222233
$config = new PhpConfig;
223234

224235
$options = $config->useOriginal();
225-
# $options: empty array
226-
# environment: PHPRC and PHP_INI_SCAN_DIR set to original values
236+
// $options: empty array
237+
// environment: PHPRC and PHP_INI_SCAN_DIR set to original values
227238

228239
$options = $config->useStandard();
229-
# $options: [-n, -c, tmpIni]
230-
# environment: PHPRC and PHP_INI_SCAN_DIR set to original values
240+
// $options: [-n, -c, tmpIni]
241+
// environment: PHPRC and PHP_INI_SCAN_DIR set to original values
231242

232243
$options = $config->usePersistent();
233-
# $options: empty array
234-
# environment: PHPRC=tmpIni, PHP_INI_SCAN_DIR=''
244+
// $options: empty array
245+
// environment: PHPRC=tmpIni, PHP_INI_SCAN_DIR=''
235246
```
236247

237248
### Troubleshooting
238-
The following environment settings can be used to troubleshoot unexpected behavior:
249+
The following environment settings can be used to troubleshoot unexpected behaviour:
239250

240251
* `XDEBUG_HANDLER_DEBUG=1` Outputs status messages to `STDERR`, if it is defined, irrespective of any PSR3 logger. Each message is prefixed `xdebug-handler[pid]`, where pid is the process identifier.
241252

242253
* `XDEBUG_HANDLER_DEBUG=2` As above, but additionally saves the temporary ini file and reports its location in a status message.
243254

244255
### Extending the library
245-
The API is defined by classes and their accessible elements that are not annotated as @internal. The main class has two protected methods that can be overridden to provide additional functionality:
256+
The API is defined by classes and their accessible elements that are not annotated as @internal. The main class has four protected methods, two of which can be overridden to provide additional functionality:
246257

247258
#### _requiresRestart(bool $default): bool_
248259
By default the process will restart if Xdebug is loaded and not running with `xdebug.mode=off`. Extending this method allows an application to decide, by returning a boolean (or equivalent) value.
249260
It is only called if `MYAPP_ALLOW_XDEBUG` is empty, so it will not be called in the restarted process (where this variable contains internal data), or if the restart has been overridden.
250261

251262
Note that the [setMainScript()](#setmainscriptstring-script-self) and [setPersistent()](#setpersistent-self) setters can be used here, if required.
252263

264+
---
265+
253266
#### _restart(array $command): void_
254267
An application can extend this to modify the temporary ini file, its location given in the `tmpIni` property. New settings can be safely appended to the end of the data, which is `PHP_EOL` terminated.
255268

256269
The `$command` parameter is an array of unescaped command-line arguments that will be used for the new process.
257270

258271
Remember to finish with `parent::restart($command)`.
259272

273+
---
274+
275+
#### _outputError(string $message): void_
276+
Outputs an error status message. This will be logged at WARNING level and output to STDERR. See [setLogger](#setloggerloggerinterface-logger-self) and [Troubleshooting](#troubleshooting) for more information.
277+
278+
---
279+
280+
#### _outputInfo(string $message): void_
281+
Output an informational status message. This will be logged at DEBUG level and output to STDERR. See [setLogger](#setloggerloggerinterface-logger-self) and [Troubleshooting](#troubleshooting) for more information.
282+
283+
---
284+
260285
#### Example
261286
This example demonstrates two ways to extend basic functionality:
262287

@@ -275,21 +300,30 @@ class MyRestarter extends XdebugHandler
275300
protected function requiresRestart(bool $default): bool
276301
{
277302
if (Command::isHelp()) {
278-
# No need to disable Xdebug for this
303+
// No need to disable Xdebug for this
279304
return false;
280305
}
281306

282307
$this->required = (bool) ini_get('phar.readonly');
308+
309+
if ($this->required) {
310+
// Output a status message
311+
$this->outputInfo('phar.readonly=1 detected, restart required');
312+
}
313+
283314
return $this->required || $default;
284315
}
285316

286317
protected function restart(array $command): void
287318
{
288319
if ($this->required) {
289-
# Add required ini setting to tmpIni
320+
// Add required ini setting to tmpIni
290321
$content = file_get_contents($this->tmpIni);
291322
$content .= 'phar.readonly=0'.PHP_EOL;
292323
file_put_contents($this->tmpIni, $content);
324+
325+
// Output a status message
326+
$this->outputInfo('phar.readonly=0 added to temporary ini file');
293327
}
294328

295329
parent::restart($command);

‎vendor/composer/xdebug-handler/composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"composer\/pcre": "^1 || ^2 || ^3"
2424
},
2525
"require-dev": {
26-
"phpstan\/phpstan": "^1.0",
27-
"phpstan\/phpstan-strict-rules": "^1.1",
26+
"phpstan\/phpstan": "^1.11 || ^2.0",
27+
"phpstan\/phpstan-strict-rules": "^1.1 || ^2.0",
2828
"phpunit\/phpunit": "^8.5 || ^9.6 || ^10.5"
2929
},
3030
"autoload": {

0 commit comments

Comments
 (0)