Doc #80040 [Opn]: Null coalescing operator ignores notices and warnings

From: Date: Mon, 31 Aug 2020 13:25:32 +0000
Subject: Doc #80040 [Opn]: Null coalescing operator ignores notices and warnings
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17843@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80040&edit=1 ID: 80040 User updated by: skeeman at inbox dot ru Reported by: skeeman at inbox dot ru Summary: Null coalescing operator ignores notices and warnings Status: Open Type: Documentation Problem Package: Compile Warning Operating System: Ubuntu 18.04 PHP Version: 7.4.9 Block user comment: N Private report: N New Comment: PHP Notice: Undefined offset: 0 in /directory/file on line 14* Previous Comments: ------------------------------------------------------------------------ [2020-08-31 13:20:05] skeeman at inbox dot ru Description: ------------ --- From manual page: https://php.net/migration70.new-features --- I really don't know - is this a bug or a feature? Is this a safe behavior? Can I count on this behavior and use it in the future? Thank you for your answer! Test script: --------------- <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); class A { public function test() { return []; } } $obj = new A(); $result = $obj->test()[0] ?? null; var_dump($result); Expected result: ---------------- PHP Notice: Undefined offset: 0 in /directory/file on line 15 Actual result: -------------- NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80040&edit=1

« previous php.doc.bugs (#17843) next »