Re: Feedback for nullc Idea
| From: | Aimeos | Norbert Sendetzky | Date: | Mon, 24 Mar 2025 08:40:54 +0000 |
| Subject: | Re: Feedback for nullc Idea | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126919@lists.php.net to get a copy of this message | ||
On 23.03.25 19:37, Rowan Tommins [IMSoP] wrote:
I'm sympathetic to the problem you're trying to solve - the precedence of ?? isn't always helpful - but I'm not sure I like the proposed solution, for 3 reasons. 1) The name "nullc" is over-shortened and cryptic. The "c" looks almost like an accident, and it doesn't actually do anything if given a null.To me, a wider approach might be more helpful, i.e. using "get" with an optional default value: if(get($a['val'])) // equals if($a['val] ?? null) if(get($a['val'], true)) // equals if($a['val] ?? true) if(get($a['val], 'yes')) // equals if($a['val] ?? 'yes') Best, -- Norbert Sendetzky Aimeos GmbH Rennbahnstr. 32 DE-22111 Hamburg E-Mail: norbert@aimeos.com Phone: +49 40 8668 4492 Web: aimeos.com Trade register: District court Hamburg HRB 143090 Managing director: Norbert Sendetzky VAT ID: DE302287839