[wp-trac] [WordPress Trac] #62032: Fixing the non yoda conditions in ms-functions.php

WordPress Trac noreply at wordpress.org
Tue Sep 10 22:50:58 UTC 2024


#62032: Fixing the non yoda conditions in ms-functions.php
--------------------------------+------------------------------------------
 Reporter:  debarghyabanerjee   |       Owner:  audrasjb
     Type:  enhancement         |      Status:  reviewing
 Priority:  normal              |   Milestone:  6.7
Component:  Networks and Sites  |     Version:
 Severity:  minor               |  Resolution:
 Keywords:  has-patch           |     Focuses:  multisite, coding-standards
--------------------------------+------------------------------------------

Comment (by jrf):

 Note: neither of these conditions would need yoda conditions as there is
 no comparison with a variable.

 And while I would much prefer to change this to a strict `=== false`, I
 agree that considering the return type of `is_email()` is `string|false`
 AND that the return value of the function is filterable, changing this to
 the loosy `! ...` is the more WordPressy thing to do.

 Having said that, it would be better to improve the condition to safeguard
 the code after it more properly and change it to something like:
 {{{#!php
 <?php
 $is_email = is_email( $email );
 if ( ! is_string( $is_email ) || empty ( $is_email)  ) {
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62032#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list