[wp-trac] [WordPress Trac] #58139: Strict type comparison

WordPress Trac noreply at wordpress.org
Tue Apr 18 05:47:50 UTC 2023


#58139: Strict type comparison
--------------------------------+------------------------------
 Reporter:  mujuonly            |       Owner:  (none)
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Networks and Sites  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  has-patch           |     Focuses:  multisite
--------------------------------+------------------------------

Comment (by krupalpanchal):

 Replying to [comment:3 jankyz]:
 > Even if those are strings this condition checks if each has value '1' it
 means true
 >
 > cast to (string) won't change anything here
 >
 > {{{#!php
 > <?php
 > if ( '1' == $blog['deleted'] ) {}
 > }}}
 >
 > we can simply reverse the condition and use `===`
 >
 > {{{#!php
 > <?php
 > if ( $blog['deleted'] === '1' ) {}
 > }}}

 It is good to use the Yoda condition here according to standards.

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


More information about the wp-trac mailing list