Error message

You need to log in or create an account to access this page.

Problem/Motivation

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

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

Issue fork drupal-3337254

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

lucassc created an issue. See original summary.

lucassc’s picture

Issue summary: View changes
prabuela’s picture

Assigned: Unassigned » prabuela
prabuela’s picture

Hi lucassc,
As the intval function is supported by php 8. Is there any particular reason to change the typecast methods.

prabuela’s picture

Assigned: prabuela » Unassigned
lucassc’s picture

Hi, @PrabuEla!

Thanks for reply. You're right, it's optional to replace it nowadays but I think it's good to unify the way in core - as it was said in the parent issue.

I'm not sure about the performance improvement matter, but I think it might still be relevant?

harivansh made their first commit to this issue’s fork.

harivansh’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

If it's just targeting that one file don't see an issue.

  • catch committed f9e91a89 on 10.1.x
    Issue #3337254 by harivansh, lucassc: Replace Updater.php intval()...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed f9e91a8 and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.