Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103190 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95377 invoked from network); 20 Sep 2018 01:40:23 -0000 Received: from unknown (HELO mail-wr1-f41.google.com) (209.85.221.41) by pb1.pair.com with SMTP; 20 Sep 2018 01:40:23 -0000 Received: by mail-wr1-f41.google.com with SMTP id j8-v6so3550586wrw.5 for ; Wed, 19 Sep 2018 14:46:51 -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=LvL5DXAlLHq7CR9fO8qH+sSvQ6c2dJkVVD01o1ArDUA=; b=DGlQ14h44J0JNQgR7O4IvUz+9q+zg6iGtGWDebwTeM6/Jx6msJl8hMmLF0pyc8Y0Jf +W13P49IHOnH/tLy6INulzikuTwIw32qlYvrZjsLS9lGgcScgP2SKCgUjUIi2r9aBRWR 8htFzDn3wcP9PjDH5YmQi/H17jX4eCO7MoPbJy8qaeuWQB4YAmtW7TUgVzbFlTmY9+tg K1gZYUxoTEqNhqhUmDtH+thZXvxU3icD4C9Z/oBisPfYKR7pgBJWBaXfAC3P5N+S4jlG 9LPZFxX/sPJAXrOI4Hm4o6pLIi9ino+t0WxSMneg18m/pzCQ7+TQ0GI6VR+NFkTXb79a n42g== 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=LvL5DXAlLHq7CR9fO8qH+sSvQ6c2dJkVVD01o1ArDUA=; b=PMgvYrXW4tzt36nxSHn4//JEA/FKYane7/irJAfRpVQ46lR5c0q0lYF3CA6FjMqOCv hJTEHPBkFFL4r7gUXHDER5mKif+lkS5ejK+o1lhzbkmz9vTYv228JZAKJAkK8LTMfFUu GrMSdPTz/s6NDo04kzzaSLP2aLH/h4qC341lTJK/ZfhppkQFp1BjTwre/7jHQsb9jZtz qZcOuV382dREL7+CrKIbR+jqGzxdWYlKMviBpeOfSn9sEvwaZ8/UFKNiA1PjwVl6BGO8 +SbWHZC5c3EkLKHFbeLuDtuJlhucJLtcXZALnIZ8pX+7SGhp63vNbPuJboH3N6bCvSrl 7AIA== X-Gm-Message-State: APzg51CzEJCHUK5xoroTtszgv41KgU6SGvqA1/XezbVPeecjFjSjzxVu ifgBtymE4w9Ezy55lsMqZCLDWwn1 X-Google-Smtp-Source: ANB0Vdb7VXA1iyrER05HFrEqY8pe0t4cQvfmOzOo3uUpdP4NvnVCJh71AkuEp/qHi9jMXrC6ELC28Q== X-Received: by 2002:a5d:45cb:: with SMTP id b11-v6mr30363577wrs.122.1537393610674; Wed, 19 Sep 2018 14:46:50 -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 a6-v6sm6146755wmf.22.2018.09.19.14.46.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 14:46:49 -0700 (PDT) To: PHP Internals List References: <239cea65-a832-29a5-11e5-ee721e3bd957@gmail.com> Message-ID: <88ff7632-7659-2f77-bb4c-20d32db178d8@gmail.com> Date: Wed, 19 Sep 2018 22:46:49 +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 19/09/2018 22:30, Marco Pivetta wrote: > > At least the approach without nullable properties will lead to a > Throwable when a read is attempted on an uninitialized object, which > is still better than nullability checks all over the place. Is it? Doesn't it just mean writing this: try {     someFunction($object->propertyThatClaimsToBeNonNullable); } catch ( TypeError $e ) {     ... } Instead of this: if ( ! is_null($object->propertyThatClaimsToBeNonNullable) ) {     someFunction($object->propertyThatClaimsToBeNonNullable); } else {     ... } For that matter, all I need to do is define someFunction as taking a non-nullable parameter, and I get the TypeError either way. Surely the point of a non-nullable property shouldn't be "it gives a slightly different error if it's not set", it should be "you don't have to worry about this not being set, because the language will enforce that somewhere". (And to cover your last point, that somewhere doesn't need to be the constructor, if requiring that is really such a big problem.) Regards, -- Rowan Collins [IMSoP]