Coding Standards for if with assignments
-
My question is about using the WordPress PHP Coding Standards.
I often use(d) statements like this
if ( $from = any_function() ) { // any code }
But this throws an error:
Assignments must be the first block of code on a lineThe following 2 variations would both validate, but especially variation A is ugly
Variation A
if ( $from = any_function() ) { // any code }
Variation B
$from = any_function() if ( $from ) { // any code }
So the question is, which way is the suggested way to handle it? Or is it maybe an error that this error is thrown?
If this is the wrong place to ask, please notify and I will ask on the Git Repo again
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Coding Standards for if with assignments’ is closed to new replies.