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 209311 - Uninitialized variable hint doesn't work propery in a foreach loop
Summary: Uninitialized variable hint doesn't work propery in a foreach loop
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.1.1
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2012-03-08 11:04 UTC by jvenderb
Modified: 2012-03-27 08: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 jvenderb 2012-03-08 11:04:00 UTC
Product Version = NetBeans IDE 7.1.1 (Build 201202271535)
Operating System = Mac OS X version 10.7.3 running on x86_64
Java; VM; Vendor = 1.6.0_29
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.4-b02-402
Comment 1 jvenderb 2012-03-08 11:08:32 UTC
The hints for php where shown in 7.1.0. To test I disabled the hints for html but this has no effect. Still the next warning is displayed: 'Warning HTML error checking for this file is disabled, you can.... The hints for php are not displayed. Is there something I can test or could it help to clean some e.g. caching?
Comment 2 Ondrej Brejla 2012-03-08 11:13:56 UTC
That warning is there because PHP is embedded language of HTML, so it's HTML warning. Hints for PHP have nothing to do with this HTML warning. And are shown properly in dev build. So it works for me.

If you have a file, where hints are not shown, just attach it here so I can try it and reopen this issue.

But I think that the problem will be elsewhere. If there is some.
Comment 3 jvenderb 2012-03-08 12:36:25 UTC
I played a little around and found that is somehow working but not as I expected:

function foo()
{
  $myArray = array();
	
  foreach ( $myArray as $value   ) {
     $value = true;
     bar( $myVar );
  }
}

function bar()
{
  return;
}

I would expect to get a hint on bar( $myVar ) as $myVar is not initialized.

If I do:

function foo()
{
    if ( true ){
      bar( $myVar );	}
}

function bar()
{
   return;
}

Now I get a warning that $myVar is not initialized.

In case I do:
function foo()
{
   $value = array();
   while ( true ){
      $value = $myVar;
      bar( $myVar );
   }
}

function bar()
{
   return;
}

I get a hint on  bar( $myVar ); but not on  $value = $myVar;
It seems that the hints do not work properly within an e.g.foreach/while loop.
Please correct me if I am wrong.
Comment 4 Ondrej Brejla 2012-03-08 13:28:21 UTC
First case is a bug.

Second works properly (for me and for you too).

And the third works properly for me too because I get "uninitialized" hint on the line with: $value = $myVar; (not on the line with bar($myVar))

I'm testing in on todays dev build. So reopening for a fix of the firt case. Thanks.
Comment 5 Ondrej Brejla 2012-03-26 14:09:41 UTC
Fixed in web-main: http://hg.netbeans.org/web-main/rev/c9bd33337d51