Skip to content

Undefined variables in function calls are not detected #233

@GaryJones

Description

@GaryJones

Snippet:

<?php

if ( ! empty( $this->vars['video-id'] ) ) {
	echo $this->vars['video-id'];
}

With a default configuration (phpcs --standard=VariableAnalysis -s phpcs-test.php), then "Variable $this is undefined. (VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable)" is reported for line 4 (the echo line), but not for the $this in the empty().

Likewise:

<?php

if ( empty( $this->vars['video-id'] ) ) {
	return;
}

...doesn't give any violation at all.

If I remove the empty(), then the violation is reported.

<?php

if ( ! $this->vars['video-id'] ) {
	return;
}

Tested in VA 2.11.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions