Make WordPress Core


Ignore:
Timestamp:
09/08/2026 08:05:22 PM (5 days ago)
Author:
westonruter
Message:

Code Quality: Remove redundant boolean sub-expressions.

Each of three conditions re-tests something the surrounding expression has already established, so PHPStan reports the redundant operand as always true:

  1. In wp_render_typography_support(), ! empty() already requires the fitText attribute to be truthy, so a following truthiness check on the same value can never fail.
  2. In _get_block_templates_files(), the right operand of an || is only evaluated when ! $post_type was false, so a leading $post_type && there is always true.
  3. In Walker::display_element(), $newlevel is a local variable that is only ever assigned the literal true, so the truthiness test adds nothing to the isset().

All three are simplifications with no change in behavior. This resolves two booleanAnd.rightAlwaysTrue occurrences and one booleanAnd.leftAlwaysTrue occurrence, and the corresponding PHPStan baselines are regenerated.

Developed in https://github.com/WordPress/wordpress-develop/pull/13086.
Follow-up to r55687, r61246, r63023.

Props tstokes8040.
See #65817.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/typography.php

    r63382 r63542  
    305305 */
    306306function wp_render_typography_support( $block_content, $block ) {
    307         if ( ! empty( $block['attrs']['fitText'] ) && $block['attrs']['fitText'] && ! is_admin() ) {
     307        if ( ! empty( $block['attrs']['fitText'] ) && ! is_admin() ) {
    308308                wp_enqueue_script_module( '@wordpress/block-editor/utils/fit-text-frontend' );
    309309
Note: See TracChangeset for help on using the changeset viewer.