Re: Array spread append

From: Date: Thu, 06 Apr 2023 08:10:08 +0000
Subject: Re: Array spread append
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-119822@lists.php.net to get a copy of this message
Hi Mick czw., 6 kwi 2023 o 10:00 mickmackusa <mickmackusa@gmail.com> napisał(a): > Call me sentimental, but are we just trying to choke out the few remaining > reasons to keep array_push() in the language? > > Okay, yeah, sometimes at is a drag that the first parameter has to be > declared in advance and is modified by reference (which means you can't > enjoy null coalescing or short ternary syntax directly in the first > parameter) but... > > The whole purpose of array_push() is to append one or more elements to an > array. Spreading the second parameter makes this task simple/clean. > https://3v4l.org/RcKRD If a parameter of array_push is a dictionary it fails with: Fatal error: Uncaught ArgumentCountError: array_push() does not accept unknown named parameters See https://3v4l.org/BHPSt Best regards, Michał Marcin Brzuchalski

« previous php.internals (#119822) next »