Unused variable detection doesn't work

General discussion on Zend Studio

Unused variable detection doesn't work

Postby freeman8 on Thu Apr 12, 2012 3:39 pm

Code: Select all
if( $this->url->isConsoleMode() || $consoleMode ) {
         $indexName = $this->tableConsole;
      }else{
         $indexName = $this->table;
      }

When you have this code, ZS doesn't report when $indexName is unused
freeman8
 
Posts: 41
Joined: Thu Sep 24, 2009 7:38 pm

Re: Unused variable detection doesn't work

Postby diemuzi on Thu Apr 12, 2012 7:55 pm

Looks to me that $indexName is set... Regardless if $this->tableConsole or $this->table has any data in it.

It would be a different story if you did something like:

echo $foo;

And $foo was never found anywhere before that statement.
MSF RiderCoach at http://bikertraining.net
diemuzi
 
Posts: 124
Joined: Mon Oct 04, 2010 3:12 pm
Location: Pensacola, Florida

Re: Unused variable detection doesn't work

Postby freeman8 on Thu Apr 12, 2012 8:41 pm

it is defined
i got is confused with unused variable detection
I thought it should warn when variable is set but not used
freeman8
 
Posts: 41
Joined: Thu Sep 24, 2009 7:38 pm

Re: Unused variable detection doesn't work

Postby diemuzi on Thu Apr 12, 2012 8:49 pm

aha! =)

Yeah ZS will only report when a variable is not set but will not report if it's not used
MSF RiderCoach at http://bikertraining.net
diemuzi
 
Posts: 124
Joined: Mon Oct 04, 2010 3:12 pm
Location: Pensacola, Florida

Re: Unused variable detection doesn't work

Postby freeman8 on Fri Apr 13, 2012 9:00 am

But it should
I've seen that somewhere :)
freeman8
 
Posts: 41
Joined: Thu Sep 24, 2009 7:38 pm


Return to Zend Studio

Who is online

Users browsing this forum: No registered users and 4 guests