NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

PHP Style (Editor warning) question

 
Post new topic   Reply to topic    NetBeans Forums -> PHP Users
View previous topic :: View next topic  
Author Message
areeda



Joined: 28 Aug 2008
Posts: 469
Location: Los Angeles

PostPosted: Sat Sep 13, 2008 10:18 pm    Post subject: PHP Style (Editor warning) question Reply with quote

My issue is with a statement like:

Code:
while($f = mysql_fetch_assoc($res))


It rightfully gives a warning about a possible accidental assignment.

In previous version of NB in PHP and Java this warning could be avoided by explicitly testing the result like

Code:
while (($f = mysql_fetch_assoc($res)) != NULL)


But no longer (I'm using fairly recent nightly builds).

I cannot think of a way to do this without duplicating the assignment statement and risk having them be different, sometimes they are a lot more complicated.

How are others dealing with this warning? I do know I can turn that off but it's saved me more than once from using A=B when I meant A==B.

Thanks,

Joe
Back to top
Mikhail Matveev
Posted via mailing list.





PostPosted: Mon Sep 15, 2008 11:32 am    Post subject: PHP Style (Editor warning) question Reply with quote

Hi Joe,

It seems reasonable to have such a feature. I filed an issue: http://www.netbeans.org/issues/show_bug.cgi?id=147259

Thanks for your feedback.

Misha


areeda wrote:
Quote:
My issue is with a statement like:




Code:
while($f = mysql_fetch_assoc($res))





It rightfully gives a warning about a possible accidental assignment.



In previous version of NB in PHP and Java this warning could be avoided by explicitly testing the result like




Code:
while (($f = mysql_fetch_assoc($res)) != NULL)





But no longer (I'm using fairly recent nightly builds).



I cannot think of a way to do this without duplicating the assignment statement and risk having them be different, sometimes they are a lot more complicated.



How are others dealing with this warning. I do know I can turn that off but it's saved me more than once from using A=B when I meant A==B.



Thanks,



Joe
Back to top
areeda



Joined: 28 Aug 2008
Posts: 469
Location: Los Angeles

PostPosted: Mon Sep 15, 2008 1:43 pm    Post subject: Reply with quote

Thanks Misha!
Back to top
nvarun



Joined: 27 Aug 2008
Posts: 170
Location: India

PostPosted: Mon Sep 15, 2008 2:26 pm    Post subject: PHP Style (Editor warning) question Reply with quote

On Mon, Sep 15, 2008 at 7:13 PM, areeda <address-removed ([email]address-removed[/email])> wrote:
Quote:
Thanks Misha!





I have voted for this issue as well.


--
Varun Nischal
http://nbguru.wordpress.com/
http://dzone.com/mvbs

"You must do the things you think you cannot do."
Back to top
areeda



Joined: 28 Aug 2008
Posts: 469
Location: Los Angeles

PostPosted: Mon Sep 15, 2008 6:25 pm    Post subject: Re: PHP Style (Editor warning) question Reply with quote

nvarun wrote:
On Mon, Sep 15, 2008 at 7:13 PM,
I have voted for this issue as well.
Varun Nischal


Wow this works.!?! Who've thought? Maybe, I have too much experience with Microsoft products?

How about another PHP Editor issue?

I think formatting for a single statement if-statement (no curly braces) should be formatted with an indent like:
Code:
if (a==b)
    print "<b>cool<b>";

whereas the editor thinks it should be formatted
Code:
if (a==b)
print "not as cool";

I do not see an option in formatting for this.

This one is not a big deal as it doesn't seem like we can put a break point at the success statement without the curly braces anyway.

Joe
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> PHP Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo