Page MenuHomePhorge

Fix PHP 8.1 exception in Conduit: Make "array_fuse(array $list)" accept null as parameter

Authored by aklapper on Sat, May 13, 13:28.
Referenced Files
Unknown Object (File)
Wed, May 31, 20:28
Unknown Object (File)
Wed, May 31, 07:29
Unknown Object (File)
Wed, May 31, 06:45
Unknown Object (File)
Sat, May 27, 09:26
Unknown Object (File)
Sun, May 14, 20:33
"Yellow Medal" token, awarded by valerio.bozzolan.



array_fuse in Arcanist is a wrapper for calling array_combine($list, $list).
The latter doesn't accept passing null in PHP 8.2.
Going to /conduit/method/project.create/, entering a name but nothing as members (so we pass null), and calling this method, an exception is thrown.

Thus make array_fuse accept null and return an empty list in such cases.

Closes T15393

Test Plan

Applied this change; afterwards "Method Call Result" page at /api/project.create correctly displayed in the web browser.

Diff Detail

rARC Arcanist
Lint Not Applicable
Tests Not Applicable

Event Timeline


Nice shot, really!

If somebody here is wondering why this fixes the issue, and why this works as expected, here a related documentation:

.... One exception to this rule are arguments of the form Type $param = null, where the null default makes the type implicitly nullable. This usage remains allowed, though it is recommended to use an explicit nullable type instead.

Also this scarying warning deserves a note:

It is also possible to achieve nullable arguments by making null the default value. This is not recommended as if the default value is changed in a child class a type compatibility violation will be raised as the null type will need to be added to the type declaration.

So, premising we are aware of that concern, here we are vaxinated for that, since this is not a class method but a beautiful function, so the type violation thing is just nowhere a concern.

Probably in 2 years a random folk will propose an RFC to deprecate this null thing aaaand in that case we will just kill that person.

Tested also in very legacy stuff like PHP 5.1 aaaand it works.



This revision is now accepted and ready to land.Sat, May 20, 21:56