On 20/10/2022 17:48, David Rodrigues wrote:
Regarding this, in case you're literally saying that internally "fn()"
turns into a common "function", and getting back to the main topic,
would it be possible to do the same with compact()?
fn() => compact('dummy')
turns into:
fn() => [ 'dummy' => $
> $foo = fn() => [$a, compact('a', 'b')];
> is essentially compiled to:
> $foo = function (use $a) { return [$a, compact('a', 'b')] };
Regarding this, in case you're literally saying that internally "fn()"
turns into a common "function", and getting back to the main topic, would
it be possible to
On 19/10/2022 18:04, David Rodrigues wrote:
It seems to me to be a reasonable problem and one that needs attention, as
the message is not that "compact cannot be used here", but that "the
variable does not exist".
I'd just like to point out that the error message here is 100% correct:
there is
>
> How would you like it to work, if you pass a variable name variable to
> compact then?
> $x = 123;
> $name = 'x';
> (fn () => compact($name))();
>
Although it is difficult to make it work in general (of course), there is the
specific case of names given as literal strings, as in the exampl
śr., 19 paź 2022 o 19:18 David Rodrigues
napisał(a):
> > I'd rather hope for `compact()` to finally be deprecated and targeted for
> removal 😛
>
> I think compact() is a good function for transferring variables from one
> point to another, but I would think about making improvements as it is
> co
> I'd rather hope for `compact()` to finally be deprecated and targeted for
removal 😛
I think compact() is a good function for transferring variables from one
point to another, but I would think about making improvements as it is
confusing (uses the variable name, rather than the variable itself).
On Wed, 19 Oct 2022, 19:04 David Rodrigues, wrote:
> Hello!
>
> I'm converting my code to use short closures where possible, and I ran into
> a problem using compact().
>
> Basically, the names used in compact() cannot be accessed due to a bug,
> reported in 2019 still in PHP 7.4 (ID 78970).
>
>