Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103242 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75228 invoked from network); 24 Sep 2018 00:47:43 -0000 Received: from unknown (HELO mail-wm1-f51.google.com) (209.85.128.51) by pb1.pair.com with SMTP; 24 Sep 2018 00:47:43 -0000 Received: by mail-wm1-f51.google.com with SMTP id y13-v6so3343351wmi.1 for ; Sun, 23 Sep 2018 13:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=JvCtnq2onym0lrBIyy8TAPMAsq7GztXA2sh6xwAfJcw=; b=hmV+XNCg5sebIpktakzEVNbp5Z1cea+SdDcHrQImi+lVHTKYOZVRG+wryUAiJBdjEn dl+YzKyuwxb1MRIO4UlG5vTfWC/21uK74SQZNCjwJx00AUYBlM2yIfeC5tIK8OlBPHUg wcFG3wgFKESaT3SOsxsWaGMB4NN56/G+pC/mAqBshiURqcRCug1CDBN1VcaL7AecwxsM 3BEKTcmkZgVnm0BVwaP/kl3hoOuRG4/WAhCPjJ4N7pioXCmqYbC+Vsdnnk/htciL/yyQ Mclc5squbLi2k6Yz9BlH/Ii8XKk+VUKcpsE3Y2OcBrNCHLKMG4AeQEryMSEePN85bDAu mumA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=JvCtnq2onym0lrBIyy8TAPMAsq7GztXA2sh6xwAfJcw=; b=XKOLYof9UifiaYvIjNthzzVlt9c4d1W8Lt095myZyAYjTvP++52bsFSvoLAA7iBD+N Icm07wlh3gEpPZdidaFl/5vsZMVocbxRxKX2Ltm2n/vWTMUGVKl2r2Ev6lzmaJrjBXuR eQbU3vUXMj4zxC0SZMvx+C8uSHUZ0GIIajJxYWG6//Z0ISE/175G2fwREQpV6KR2vLDR wKd4/hJn1HbnOtYz96/AI4v2psYDqUCGy5QPM/U8cJG4yYltoYUr8I7MdEc4ruLq3hU4 OvTTOJrfOpQTWpMbtd+h5YOtoQlXDsco8DqmGFM6H0Waj/yTyv/YQwvg6DNGEn0FgzLl Uesw== X-Gm-Message-State: ABuFfogLkk15CBKUjLALQflSXN1g0hXNaThqmeNv/OJcyZ3htUcPDSNO n97CtdCUOFIqsrgjrm8drQQMH03/ X-Google-Smtp-Source: ACcGV634RvmImwftWmCdOHlqK2+cxEWH9KeUF3taUyb4wdJJ4vwkXG6n523IDr5AguizAe9Z8mSSng== X-Received: by 2002:a1c:14c3:: with SMTP id 186-v6mr4909785wmu.21.1537736109988; Sun, 23 Sep 2018 13:55:09 -0700 (PDT) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id b144-v6sm16088512wmd.23.2018.09.23.13.55.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Sep 2018 13:55:09 -0700 (PDT) To: internals@lists.php.net References: <1681263.Ri4PIu1jiQ@vulcan> Message-ID: <8fe8577b-7118-2eaa-1d1c-4249e1daad6b@gmail.com> Date: Sun, 23 Sep 2018 21:55:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2 From: rowan.collins@gmail.com (Rowan Collins) On 23/09/2018 19:31, David Rodrigues wrote: > Em dom, 23 de set de 2018 às 13:09, Larry Garfield > escreveu: > >> 3) Object properties may be type hinted and the class author has until the >> end >> of the constructor to make sure they're fulfilled, otherwise TypeError on >> the >> spot (what I'm proposing). >> > Item 3 could not be enough, for instance: > > <<< > class Example { > public /* string */ $string; > public function __construct() { static:: stringParameter > ($this->string); } > public static function stringParameter(string $string) {} > } > > new Example; > > It will fail because __construct() uses an uninitialized non-nullable > property. Yes, there are various cases where checking at the end of the constructor is not enough. The general consensus is that we can't catch all of them without major changes to the language, but can catch some of the more common scenarios earlier than the current implementation does. > Maybe it should throw a new Exception like UninitializedPropertyException > when you try to read a uninitialized property like this case. That's exactly what the current implementation will do, and what Larry's proposed addition would continue doing in cases where it can't be spotted at a "checkpoint" like the end of the constructor. Regards, -- Rowan Collins [IMSoP]