Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-21 Thread Mark Randall
On 21/02/2022 10:29, Nicolas BADIA wrote: and I don’t find the code more readable. Here are some examples of changes: The example changes you provide are what many people here would recommend as good practice to improve the context and safety your code provides. Anyone looking at that code

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Larry Garfield
On Tue, Feb 15, 2022, at 6:54 AM, Andreas Leathley wrote: > On 15.02.22 13:31, Nicolas BADIA wrote: >> As it is explained in this ticket https://bugs.php.net/bug.php?id=81417 we >> use to check if a property exists by accessing it directly like we do in >> JavaScript. >> >> Personally, I subscrib

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Rowan Tommins
On 15/02/2022 15:12, Guilliam Xavier wrote: On Tue, Feb 15, 2022 at 3:07 PM Rowan Tommins wrote: if ( array_key_exists('key', $array) && $array['key'] !== null && $array['key'] !== false && $array['key'] !== 0 && $array['key'] !== 0.0 && $array['key'] !== '' && $array['key'] !== [] ) Agreed,

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Guilliam Xavier
On Tue, Feb 15, 2022 at 3:07 PM Rowan Tommins wrote: > On 15/02/2022 12:54, Andreas Leathley wrote: > > The problem with your way of writing code is that it is ambiguous in > > meaning, which is why this is a warning. > > > I think that's a good way of looking at it. There's actually quite a lot

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Rowan Tommins
On 15/02/2022 12:54, Andreas Leathley wrote: The problem with your way of writing code is that it is ambiguous in meaning, which is why this is a warning. I think that's a good way of looking at it. There's actually quite a lot of code hiding a check like "if ($array['key'])"; roughly speakin

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Pierre
Le 15/02/2022 à 13:46, Thomas Nunninger a écrit : Hi Nicolas, as far as I understand, adding new ini settings is not the way to go as this would mean that your code behaves differently on different environments. Two suggestions: * Write your own error handler that ignores those errors. * T

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Andreas Leathley
On 15.02.22 13:31, Nicolas BADIA wrote: As it is explained in this ticket https://bugs.php.net/bug.php?id=81417 we use to check if a property exists by accessing it directly like we do in JavaScript. Personally, I subscribe to this coding style and we use it all over our codebase (more than 13

Re: [PHP-DEV] Setting to disable the "Undefined array index" warning

2022-02-15 Thread Thomas Nunninger
Hi Nicolas, as far as I understand, adding new ini settings is not the way to go as this would mean that your code behaves differently on different environments. Two suggestions: * Write your own error handler that ignores those errors. * Try some tool like Rector to rewrite your code. Bes