User tests: Successful: Unsuccessful:
Bug fixed
JoomlaCode entry: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33624&start=0
Title |
|
Actually, you can not test it. It is more a coding standard problem. The Not operator (!) has a higher precedence then the Assignment operator (=). See the operator precedence list for more information: http://www.php.net/manual/en/language.operators.precedence.php
Viktor is right that it's not the best codestyle. However PHP makes it work neverthless
From the note on the page linked:
Although = has a lower precedence than most other operators, PHP will still allow expressions similar to the following: if (!$a = foo()), in which case the return value of foo() is put into $a.
Which means, it's valid code. But adding the brackets would improve readability and be "cleaner" code.
I'm not aware that we have a codestyle rule for that currently, so maybe we want to add that to our rules.
+1 for merge it.
Merged, thanks!
Title |
|
||||||
Status | New | ⇒ | Closed | ||||
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-04-17 11:44:46 | ||||
Labels |
Added:
?
?
|
Status | Closed | ⇒ | New |
Status | New | ⇒ | Closed |
Closed_Date | 2014-04-17 11:44:46 | ⇒ | 2014-04-17 11:50:04 |
Now for real...
This one should really have become 2 lines. It's just calling for future trouble. Assignments should not be made in ifs.
I also don't like assignments in if statements.
So why not fix it the right way and avoid those assignment in condition ?
@Kubik-Rubik
Is there a good way to test it? Or a case that show a error?
The Patch looks good for me
Here is a backport to 2.5: #3466