Skip to content

Improve ArgumentFunctionsReportCurrentValue to avoid false positive? #1207

@GaryJones

Description

@GaryJones

With a minimum example code like:

function foo ( $stuff ) {
	if ( true === SOME_CONSTANT ) {
		return $stuff;
	}

	foreach ( func_get_args() as $arg ) {
		...
	}
}

and a testVersion that includes 7.0 or later, I get a Warning of:

Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "$stuff" was used, and possibly changed (by reference), on line 5.
(PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection)

...against the line containing the func_get_args().

It seems like it would be possible to look at the use of the variable in line 5, and to see if has been assigned to in some way, before giving the violation?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions