php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80040 Null coalescing operator ignores notices and warnings
Submitted: 2020-08-31 13:20 UTC Modified: 2020-08-31 14:11 UTC
From: skeeman at inbox dot ru Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.9 OS: Ubuntu 18.04
Private report: No CVE-ID: None
 [2020-08-31 13:20 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-31 13:25 UTC] skeeman at inbox dot ru
PHP Notice:  Undefined offset: 0 in /directory/file on line 14*
 [2020-08-31 13:47 UTC] skeeman at inbox dot ru
-Status: Open +Status: Closed
 [2020-08-31 13:47 UTC] skeeman at inbox dot ru
figured out
 [2020-08-31 14:11 UTC] requinix@php.net
-Status: Closed +Status: Not a bug -Package: Compile Warning +Package: *General Issues
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 22:01:33 2024 UTC