-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
Description
Trying to unset an undefined variable is not an issue in PHP and will not result in any warnings/notices: https://3v4l.org/XsK20
The following code snippet:
function foo($array) {
foreach ($array as $value) {
}
unset($key, $value);
}... currently results in the following warning for using $key in unset():
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
6 | WARNING | Variable $key is undefined.
----------------------------------------------------------------------
I'd like to propose to either not throw an error for undefined variables being used in unset() or to give this a separate error code so those kind of warnings can be silenced.