-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7398Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/ea865936-8c1a-4759-92f7-6cf4fa4a94b8
<?php
class Test {
function method() {
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {
if ($file === __FILE__) {
throw $signalingException;
}
return $prevErrorHandler !== null ? $prevErrorHandler($type, $msg, $file, $line, $context) : false;
});
}
}Responsible rules
RemoveUnusedVariableAssignRector
Expected Behavior
As you can see, the variable $prevErrorHandler is used by reference inside the closure.
This is supported by PHP.
The variable should not be removed.
/cc @samsonasik