[wp-trac] [WordPress Trac] #57213: Coding standards : Use Strict Comparison except Loose Comparison wp-includes/class-wp-hook.php

WordPress Trac noreply at wordpress.org
Tue Jan 31 08:30:53 UTC 2023


#57213: Coding standards : Use Strict Comparison except Loose Comparison wp-
includes/class-wp-hook.php
-------------------------------------+-------------------------------
 Reporter:  rockonshajib             |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  6.2
Component:  General                  |     Version:  4.7
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  coding-standards
-------------------------------------+-------------------------------

Comment (by adeltahri):

 == Test Report:
 There were no PHP errors on the frontend or backend of the general test.

 Patch tested: 3878

 === Environment
 * OS: macOS  13.0.1
 * Web Server: Nginx
 * PHP: 7.4.33
 * WordPress: 6.2-alpha-54642
 * Browser: Chrome 109
 * Theme: Twenty Twenty-Two
 * Active Plugins:
   * Gutenberg

 === PHPUnit Test
 I have added a test unit to applyFilters.php:
 {{{
         public function test_apply_filters_with_integer_argument() {
                 $a             = new MockAction();
                 $callback      = array( $a, 'filter' );
                 $hook          = new WP_Hook();
                 $hook_name     = __FUNCTION__;
                 $priority      = 1;
                 $accepted_args = 2;
                 $arg           = 0;

                 $hook->add_filter( $hook_name, $callback, $priority,
 $accepted_args );

                 $returned = $hook->apply_filters( $arg, array( $arg ) );

                 $this->assertSame( $returned, $arg );
         }

         public function test_apply_filters_with_string_argument() {
                 $a             = new MockAction();
                 $callback      = array( $a, 'filter' );
                 $hook          = new WP_Hook();
                 $hook_name     = __FUNCTION__;
                 $priority      = 1;
                 $accepted_args = 2;
                 $arg           = '0';

                 $hook->add_filter( $hook_name, $callback, $priority,
 $accepted_args );

                 $returned = $hook->apply_filters( $arg, array( $arg ) );

                 $this->assertSame( $returned, $arg );
         }
 }}}


 - Test pass.

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


More information about the wp-trac mailing list