Problem/Motivation

There are a number of places in core that call reset() or end() on an array in order to then call key(). Since PHP 7.3 we can use array_key_first() and array_key_last()

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3422539

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

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
dpi’s picture

Status: Needs review » Reviewed & tested by the community

nice simple batch, replacing the end() + key() combo is an especially good use of array_key_last().

Looks like this is the output of Rector \Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector, which signals to me the changes encompass all changes required in core.

  • catch committed 9358fca0 on 10.3.x
    Issue #3422539 by mstrelan, dpi: Make use of array_key_first and...

  • catch committed d493af8c on 11.x
    Issue #3422539 by mstrelan, dpi: Make use of array_key_first and...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

Status: Fixed » Closed (fixed)

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