Skip to content

Unsetting undefined variable is not an issue #174

@jrfnl

Description

@jrfnl

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions