On account of the backwards-incompatible changes made in PHP 7.0, it's helpful to move any calls to func_get_arg() and func_get_args() to the start of the function (even when the original location was safe in practice), in order to reduce cognitive load for the reader.

Making this change can also eliminate warnings (sometimes false-positive) from certain code linters. e.g. "[Warning] Function argument(s) returned by "func_get_args" might have been modified."

Refer to https://secure.php.net/manual/en/migration70.incompatible.php#migration7...

CommentFileSizeAuthor
#2 redirect-func_get_args-3016519-2.patch974 bytesjweowu

Comments

jweowu created an issue. See original summary.

jweowu’s picture

Status: Active » Needs review
StatusFileSize
new974 bytes

In addition, using array_splice() for its return value only (ignoring its side-effects), seemed unnecessarily confusing, so I've replaced that with array_slice() which does not have side-effects.

vijaycs85’s picture

Status: Needs review » Reviewed & tested by the community

Fixes PHPCS warning.

pifagor’s picture

Dear jweowu
Haw the reason use array_slice instead of array_splice?

jweowu’s picture

I explained the reason for that change in comment #2.

pifagor’s picture

  • pifagor committed 8ced447 on 7.x-1.x authored by jweowu
    Issue #3016519 by jweowu, pifagor, vijaycs85: Refactor...

  • pifagor committed c4a2db6 on 7.x-2.x
    Issue #3016519 by jweowu, pifagor, vijaycs85: Refactor...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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