Replace Updater.php intval() functions with their relevant type casting operators

Created on 28 January 2023, almost 2 years ago
Updated 17 March 2023, over 1 year ago

Problem/Motivation

Follow-up to issue 📌 Replace intval(), strval(), .. *val() functions with their relevant type casting operators Postponed .

There are remaining usages of PHP 4-style type casting intval() in core/lib/Drupal/Core/Updater/Updater.php. We should consider converting those and remove the PHPCS ignore:
The use of function intval() is discouraged (Generic.PHP.ForbiddenFunctions.Discouraged)

Steps to reproduce

Grep for remaining usages:

[ayrton:drupal | Wed 04:38:58] $ grep -r "intval" * | grep -v "vendor" | grep -v "node_modules"
core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:      $ids = array_map('intval', $ids);
core/lib/Drupal/Core/Updater/Updater.php:            $filetransfer->chmod($parent_dir, intval($old_perms, 8));
core/lib/Drupal/Core/Updater/Updater.php:      $filetransfer->chmod($path, intval($new_perms, 8), $recursive);
core/phpcs.xml.dist:        <element key="intval" value="null"/>
core/modules/language/src/LanguageNegotiator.php:    $enabled_methods = array_map('intval', $enabled_methods);
core/modules/views/src/Plugin/views/HandlerBase.php:      $value = array_map('intval', $value);

Remaining tasks

- Convert them with their relevant type casting operators
- Review

📌 Task
Status

Fixed

Version

10.1 ✨

Component
Base  →

Last updated about 5 hours ago

Created by

🇧🇷Brazil lucassc Rio de Janeiro

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024