Problem/Motivation

Function empty() checks the variable emptiness but not the value provided by the function result.
https://www.php.net/manual/en/function.empty.php
For example: #3080034: Remove array_filter from FieldInstanceSettings
the value passed into the trim() function can be unexpected and not safely handled compared to the empty() function.

Steps to reproduce

Find usage by using the following command.
grep -rEe "[^\w\.\>]empty\([^\$\)]" ./core/modules
grep -rEe "[^\w\.\>]empty\([^\$\)]" ./core/themes

Proposed resolution

Replace the expression with more appropriate checks or move the checked value into a variable before usage in the expression.
Nice to have: updated Drupal standard coding rule.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3331945

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

voleger created an issue. See original summary.

Aditya Pandey made their first commit to this issue’s fork.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.