Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #49628, comment 23


Ignore:
Timestamp:
11/08/2021 05:44:57 AM (3 years ago)
Author:
Cybr
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #49628, comment 23

    v1 v2  
    32321. handle variables strictly when the type is implied (`'hello' ==== $user_var`);
    33331. handle variables weakly of boolean type (`$act = ! $user_var` or `if ( $user_var )`);
    34 1. cast when when makes sense (`42 === (int) $user_var`) (PHP can emit conversion warnings, good! Less work for us.);
    35 1. cast for filters `($thing = (string) apply_filters())` (PHP can emit conversion warnings, good! Less work for us.);
    36 1. cast for return types `return (bool) $user_var`.
    37 1. only emit deprecation notices when behavior changes from earlier WP versions.
     341. cast when it makes sense (`42 === (int) $user_var`) (PHP can emit conversion warnings, good! Less work for us.);
     351. cast filters `($thing = (string) apply_filters())` (PHP can emit conversion warnings, good! Less work for us.);
     361. cast return types `return (bool) $user_var`.
     371. only emit deprecation notices (doing it wrong) when behavior changes from earlier WP versions.
    3838
    3939I also believe that only if WordPress should ever become strictly typed should we check filters and functions' types strictly. We're already facing issues with `array` vs. `iterable`; let's not pile up.