Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64096 invoked from network); 16 Jul 2018 08:43:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2018 08:43:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.65 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.221.65 mail-wr1-f65.google.com Received: from [209.85.221.65] ([209.85.221.65:37387] helo=mail-wr1-f65.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/96-39793-A9A5C4B5 for ; Mon, 16 Jul 2018 04:43:08 -0400 Received: by mail-wr1-f65.google.com with SMTP id q10-v6so30970334wrd.4 for ; Mon, 16 Jul 2018 01:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:cc:from:message-id; bh=qqes00DzBvp0H3SaSfq/fY0n5YJUKx/Vwu3EXfLvxdU=; b=NQEG3uRISmD9G1giWmz+pLgF6OEHtgFNFZKNsAm8jv/fy61frY707qrlRG3oVelY2h IxpZ/9O9NDHB+7Iz1t1TzmKAFdMvlVV2VyT280ItvqVRgmLXEdAr/5JLvuNZ9GJ4cZgt TqW8WHkp6bklOhBCZagu3BOe0g32K2v0kJHaOB7liNN+FDnEvA8UfLejzZvhAxdl+z7t Zc3midA3CD/ykjg24RF0GuS7iEw74YlSWyJmwccJh+CWhkd3CmczwZfR0rLQ3zXGgzCU s7qyvvd76ASEnv68qLwRgkg98lNBTxM/N8apkUXluRoDfbMEFa4UxzRtNe+bG9U01Gty GdsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:cc:from:message-id; bh=qqes00DzBvp0H3SaSfq/fY0n5YJUKx/Vwu3EXfLvxdU=; b=iwNtsJ112ZqaJvUs//JKCbAkd/h4wy2/M6UOePykU+4mdnj5hOUyvFxIFoYLQcn8Rm FMSJkAQn/BIIU+hBXXdS5KEbF8PWrw26IafJtpu3Fw8apGcMowSe+qPUGK0gj8AYdttd UFNKFQL1l+0iTWY4CgKANRH5l4n7NYegKzvSMkctS84nIJvgrua6z+g373ITEZ+Qi+pq AtuqJQJ715lY9yQwlYMxt2InLXGkGgsiDeEY1y3uVvH3rU5tMXSAQJ4zYv3TzUgV7ekS siLEcKrkLAnlTTiav9aBP4QMZuvGKRmt3zlnqjIRPjCjSz/j6Pi8qsDaWgHvul5zpNaj 065A== X-Gm-Message-State: AOUpUlGU4DdvYuYmhwm7FFBDm1i4WZWa58FsEAg5qNjjvdtl4NLk8njm 4uRuSj4MbF/cnC+IBKHAgz52Vg== X-Google-Smtp-Source: AAOMgpe48ZkFymQuHlgMkliWJ7etlWaHKmn2HL1wFGM5k1LfyM1IphGSsSiq5EpxLl6EjIEQQsgkSQ== X-Received: by 2002:a5d:4210:: with SMTP id n16-v6mr10746255wrq.55.1531730583857; Mon, 16 Jul 2018 01:43:03 -0700 (PDT) Received: from ?IPv6:2a00:23c4:4b86:4b00:1c4c:789f:a876:6880? ([2a00:23c4:4b86:4b00:1c4c:789f:a876:6880]) by smtp.gmail.com with ESMTPSA id m17-v6sm50730858wrg.65.2018.07.16.01.43.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 01:43:03 -0700 (PDT) Date: Mon, 16 Jul 2018 09:43:01 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <8916EC21-D368-40F8-9ABD-CE0C04A73539@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable CC: PHP internals Message-ID: <0AA3251E-A0D8-492E-AEAC-3B2FBBFDB944@gmail.com> Subject: Re: [PHP-DEV] Non-nullable properties From: rowan.collins@gmail.com (Rowan Collins) On 16 July 2018 00:52:53 BST, Dan Ackroyd wrote: >On 14 July 2018 at 14:09, Rowan Collins >wrote: >> Hi all, >> >> The current RFC proposes the next simplest solution, which is to >allow non-nullable types, and trust the user to initialise them before >use=2E > > >From the RFC: >> If a typed property does not have a default value, no implicit null >default value is implied (even if the property is nullable)=2E >> Instead, the property is considered to be uninitialized=2E Reads from >uninitialized properties will generate a TypeError > >Are you miss-quoting the RFC? > >Because those two sentences are completely different=2E There's no contradiction here; throwing an error when a property is *read*= is not the same as enforcing that it always has a valid value=2E Compare with parameter type hints: function thing(Foo $foo) { $foo->bar(); } thing(null); The line that throws the error is thing(null), and that's the line that ne= eds fixing=2E We don't allow the parameter in, and then throw an error when= trying to use it, leaving the user to work out how it got there; that woul= d defeat the purpose of the type hint=2E The difference between "uninitialised" and "null" is largely irrelevant: e= ither way, the only way to run code like $foo->bar->baz() safely is to test= the property before use=2E Or, to simply trust the user not to make a mist= ake=2E Regards, --=20 Rowan Collins [IMSoP]