Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Rowan Tommins
On 30/03/2022 15:32, Guilliam Xavier wrote: On the other hand, I agree that `$undefined[] = $x` looks like a bug... are both cases the exact same opcode? Some very good points raised in this thread about how many different closely-related cases there are here. I shall have to think clearly a

Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Peter Bowyer
On Wed, 30 Mar 2022 at 15:33, Guilliam Xavier wrote: > Not really a "compelling reason why we should keep this inconsistency", but > I have occasionally relied on array autovivification *for sub-dimensions*, > I rely on this often when remapping data for analysis. These scripts are run a handful

Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Guilliam Xavier
Hi Rowan, Not really a "compelling reason why we should keep this inconsistency", but I have occasionally relied on array autovivification *for sub-dimensions*, e.g.: ``` function f(iterable $xs) { $map = []; // initialization! foreach ($xs as $x) { // $map[foo($x)] ??= []; not ne

Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Larry Garfield
On Wed, Mar 30, 2022, at 9:11 AM, Claude Pache wrote: >> Le 29 mars 2022 à 21:44, Rowan Tommins a écrit : >> >> Hi all, >> >> If $foo is not defined, statements such as $foo += 1 and $foo .= 'blah' >> raise "undefined variable" Warnings in PHP 8, and will throw Errors in PHP >> 9. However, the

Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Claude Pache
> Le 29 mars 2022 à 21:44, Rowan Tommins a écrit : > > Hi all, > > If $foo is not defined, statements such as $foo += 1 and $foo .= 'blah' raise > "undefined variable" Warnings in PHP 8, and will throw Errors in PHP 9. > However, the very similar looking $foo[] = 1 succeeds silently. > > T

Re: [PHP-DEV] Undefined variables and the array append operator

2022-03-30 Thread Robert Landers
On Tue, Mar 29, 2022 at 9:44 PM Rowan Tommins wrote: > > Hi all, > > If $foo is not defined, statements such as $foo += 1 and $foo .= 'blah' > raise "undefined variable" Warnings in PHP 8, and will throw Errors in > PHP 9. However, the very similar looking $foo[] = 1 succeeds silently. > > This se