Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93559 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26774 invoked from network); 26 May 2016 11:41:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 11:41:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:37256] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/B1-17600-AD0E6475 for ; Thu, 26 May 2016 07:41:15 -0400 Received: (qmail 1232 invoked by uid 89); 26 May 2016 11:41:12 -0000 Received: by simscan 1.3.1 ppid: 1226, pid: 1229, t: 0.0927s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 26 May 2016 11:41:12 -0000 To: internals@lists.php.net References: <7B.12.14311.F79C5475@pb1.pair.com> <1b12b09f-f190-dca0-51d9-468e9c571268@fleshgrinder.com> <4ec823c6-b039-fc91-7c78-60d67719cd81@gmail.com> <00482771-3a07-06cf-ee8d-cd83a301c7e7@fleshgrinder.com> <1ac579b7-6bf3-f362-c045-0261abcfa17c@fleshgrinder.com> <2f058fee-f230-739f-4ed5-ff7d0cabe924@fleshgrinder.com> <7c3f6b51-f93b-c69f-a592-7bb0a00586e6@gmail.com> <528dd5dc-0e17-d766-a83f-02e2429277fa@fleshgrinder.com> Message-ID: <5746E0D7.6020806@lsces.co.uk> Date: Thu, 26 May 2016 12:41:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <528dd5dc-0e17-d766-a83f-02e2429277fa@fleshgrinder.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: lester@lsces.co.uk (Lester Caine) Bare with me ... just trying to fill in a few of the gaps in the current documentation. On 26/05/16 11:49, Fleshgrinder wrote: > $g = new class { public $x; }; > > var_dump(isset($g->x)); // false isset manual entry does not say what happens if $g->x does not exist but the false here could equally be 'does not exist' if unset has been called somewhere? > var_dump(property_exists($g, 'x')); // true or array_key_exists('x', $g) in our consistent style but as has been pointed out we do not have a simple 'exists' ... $g->exists('x') ? along with $g->isinit('x') > var_dump($g->x); // null + E_NOTICE Uninitialized > var_dump(is_null($g->x)); // true + E_NOTICE Uninitialized > var_dump($g->x == null); // true + E_NOTICE Uninitialized > var_dump($g->x === null); // true + E_NOTICE Uninitialized Unless null IS the required initial value? Why should we have to initialize a nullable typed property explicitly? I'm still stuck in the simple model of things where 'x' is expandable so we have the simple generic variable of old (PHP4 days) which now has additional attributes such as accessibility (public etc) and a few special cases of type filtering but is lacking a tidy way of adding the more useful filtering attributes such as constraints and yes typing. properties and associative arrays are simply managed list of these simple variables so why do we need different functions to access them. Within a class isset($x) should mirror isset($this->x) and exists($x) makes sense along with other 'object' related functions, but is there no way to get back to a lot simpler consistent handling of variables ... and a more constructive way to add flexible type constraints. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk