Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100959 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37468 invoked from network); 27 Oct 2017 10:54:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2017 10:54:55 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.219 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.219 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.219] ([81.169.146.219:21047] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/AB-28573-D7013F95 for ; Fri, 27 Oct 2017 06:54:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1509101691; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=WLSOc8CmyLSWaW6lzc7/P/jJo3jto/7Y1VIZqirCixQ=; b=PNTRLpTHEwpFzhwn9qU7TcMuZA39y7UL57dsC+AHImS1d0x4bn6FDB/Qe5Ud49UlBR vGuAqpdRa+pg41Je+aoWpEWQZKOGpm18DqbA9D9tVKhO8udrPPNjZBnXyrlCeeJtMq7A PGQ62RfG+xEEuKSjZq+6Nd+5jz+7KaHkMwu8Q= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mlsGbEv0XHBzMIJSS+jKTzde5mDb8Db2nURiu2cA== X-RZG-CLASS-ID: mo00 Received: by mail-yw0-f171.google.com with SMTP id j4so5380469ywb.2 for ; Fri, 27 Oct 2017 03:54:50 -0700 (PDT) X-Gm-Message-State: AMCzsaX9CB/QmHsQ683UW7dJZnfEFQssAYGIcIW/Fg/UJMRJhV9uvaCb VXodzGFsjt4W05Mcxn35rM2IXiBXLwj7ABrkuEQ= X-Google-Smtp-Source: ABhQp+SV5jrC1fU83U1OKzgGDvfqSupxzFb/iE6b1ZJiuYPh/gsiyLPCLFkGNvDqJwn7alQ7CzNSle3OWd6ViUlZOT8= X-Received: by 10.129.118.17 with SMTP id r17mr19338ywc.497.1509101690047; Fri, 27 Oct 2017 03:54:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.212.203 with HTTP; Fri, 27 Oct 2017 03:54:49 -0700 (PDT) In-Reply-To: <45daf06e-e448-f3c9-5cbf-4f947c4db13f@rhsoft.net> References: <7639e065-451b-0f2e-1985-5e3d31ec1b68@gmail.com> <45daf06e-e448-f3c9-5cbf-4f947c4db13f@rhsoft.net> Date: Fri, 27 Oct 2017 12:54:49 +0200 X-Gmail-Original-Message-ID: Message-ID: To: "lists@rhsoft.net" Cc: PHP Internals Content-Type: multipart/alternative; boundary="f403045ef0da2a5ac9055c851e83" Subject: Re: [PHP-DEV] Raise E_NOTICE for null castings From: me@kelunik.com (Niklas Keller) --f403045ef0da2a5ac9055c851e83 Content-Type: text/plain; charset="UTF-8" > > Hi, I would like to propose an RFC to raise an E_NOTICE when a variable >> "initialized" to null is casted to other types: >> >> $foo = null; >> var_dump($foo['bar']); >> var_dump($foo . 'bar'); >> var_dump($foo + 2); >> var_dump($foo & 2); >> // At the time being, this code produces no errors >> >> The eventual vote may be split one for each case. >> >> What do you think? >> > > pleae don't break code like this which is a useful case for access > directly a array field returned from a function and so makes this to a > one-liner without check the result > > public function GetMaxSort(): int > { > return (int)mysqli_fetch_row($this->cl_api->db->query("select > SQL_NO_CACHE max(hsort) from {$this->cl_api->sql_prefix}main", 1))[0]; > > } > Just use return (int) mysqli_fetch_row($this->cl_api->db->query("select SQL_NO_CACHE max(hsort) from {$this->cl_api->sql_prefix}main", 1))[0] ?? 0; Regards, Niklas --f403045ef0da2a5ac9055c851e83--