note 124579 added to migration70.new-features
| From: | ricasianoatgmaildotcom@php.net | Date: | Wed, 08 Jan 2020 12:53:17 +0000 |
| Subject: | note 124579 added to migration70.new-features | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213810@lists.php.net to get a copy of this message | ||
Be careful on performing null coalesce on typecasted properties. Enclose them in parenthesis
<?php
$foo = new StdClass;
//(int) 23
$bar = $foo->bas ?? 23;
var_dump($bar);
$foo = new StdClass;
//(int) 23
$bar = (int) ($foo->bas ?? 23);
var_dump($bar);
$foo = new StdClass;
$bar = (int) $foo->bas ?? 23;
//Notice: Undefined property: stdClass::$bas
var_dump($bar);
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.168 (proxied: 112.199.74.154)
----
Manual Page -- http://php.net/manual/en/migration70.new-features.php
Edit -- https://master.php.net/note/edit/124579
Del: integrated -- https://master.php.net/note/delete/124579/integrated
Del: useless -- https://master.php.net/note/delete/124579/useless
Del: bad code -- https://master.php.net/note/delete/124579/bad+code
Del: spam -- https://master.php.net/note/delete/124579/spam
Del: non-english -- https://master.php.net/note/delete/124579/non-english
Del: in docs -- https://master.php.net/note/delete/124579/in+docs
Del: other reasons-- https://master.php.net/note/delete/124579
Reject -- https://master.php.net/note/reject/124579
Search -- https://master.php.net/manage/user-notes.php