This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 155847 - Unexpected 'variable not sued in scope' warning tip
Summary: Unexpected 'variable not sued in scope' warning tip
Status: RESOLVED DUPLICATE of bug 157390
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All Linux
: P3 blocker (vote)
Assignee: Tomasz Slota
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-19 14:41 UTC by peteford
Modified: 2009-04-10 14:44 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description peteford 2008-12-19 14:41:57 UTC
The following code fragment illustrates the problem:

<?php
class Test
{
    public $foo = 'foo';

    public static function getFoo()
    {
        $test = new Test();
        return $test->foo;
    }
}
?>

The first use of $test gets underlined in yellow, and the warning is 'Variable does not seem to be used in its scope'.
Now, I might be wrong, but the line reading 'return $test->foo;' looks like it is using the $test variable, and in the
same scope...

This is the absolute minimum bit of code I can find to demonstrate this bug, but there are plenty of occurrences of the
same spurious warning in my current project.

For example, if I add the following:

<?php
$arr = Array(new Test());
foreach ($arr as $test)
{
    $details = $test;
    echo "<p>{$details->foo}</p>";
}
?>

I get the first instance of $details underlined yellow with the same warning.
Comment 1 Mikhail Matveev 2008-12-19 14:59:50 UTC
Reproducible, as well as in the following code:

<?php
class Test
{
    public $foo = 'foo';

}

function getFoo()
{
    $test = new Test();
    echo $test->foo;
}
?>

Not reproducible in the code:

<?php
class Test
{
    public $foo = 'foo';

}

$test = new Test();
echo $test->foo;
?>
Comment 2 Tomasz Slota 2009-04-10 14:44:19 UTC

*** This issue has been marked as a duplicate of 157390 ***