Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103244 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84017 invoked from network); 24 Sep 2018 01:41:07 -0000 Received: from unknown (HELO mail-it1-f174.google.com) (209.85.166.174) by pb1.pair.com with SMTP; 24 Sep 2018 01:41:07 -0000 Received: by mail-it1-f174.google.com with SMTP id h20-v6so8161658itf.2 for ; Sun, 23 Sep 2018 14:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1eez0VlFO/T0Jt2CmgQHRMDVU9/mkMgfIW+/0rhx4qc=; b=X9imlmg463rvwt5NFxk38OKpTa65iYoqHJQ2vbElLGyHv77IZ6I5CWkYqFreGDpn8W 3Tb0K1wzo0IX7InucvHQXXD6ShhyKDz+QlCvdLRxBNmkLocZ0/cCnrMNLAIrSIwNW8Ls L93G9WnLtRgZ2kpgjXXEwIinsPnCEWyb67+9n6rJYXGGF2/dog99LbpTnGaiNMTWLn7e S6L0X8kD++3wXBABm7ASXNgLqqGVB3ycJSWPPlMipdCrDhmmR+hWXqjM6lPRwKABU9pe MPqUqVdTO+3Xds4+ZPUxntl7Lxcb4ZjpHzHFVd68vQu8RLd6znuOkv6m5OaQrx21cMEG eo3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1eez0VlFO/T0Jt2CmgQHRMDVU9/mkMgfIW+/0rhx4qc=; b=X4kWUHcSI5JyGlRCstO3EfvTfC7yaHY4eS/stAILlGb71nzlOVVclhXv05Dc2mSuIU X1rXQShEBzxkHUkZIVbkbovunKOtymjy5WfX2+Q68dpHud+d0tkQ+aAWCtHHfrpiMfO/ GACeQz96ENeD+fqLmymdxd2I1ZtRMuw0Mk1QHRUhyRHc+mXk/ABOl9LWwjCRQBIzAMSB aG4Wjcer9cXfWbrH+dcI9buTGaTQzieSnHfOaHjYZisioGs2iD3vROgP1cduePBuoqNQ PDr1/AEmBfXZCeyePSsPurlhvQXY9iCWaXVDdb2l8JQIeQL/V2IQvKa3gLjxP4SGpTwN 0WPg== X-Gm-Message-State: ABuFfoij+O3juqGeBNq/ETEea7PKcIuu7R+C4zgOLugd97Dcm/WDJoaT et0UfOpY0dwbKvsvQhHKv4MS/NV2xVnf05oxWeU= X-Google-Smtp-Source: ACcGV63bAQiCdiIOy101nUJ23W33v0R4OGZ1B4b8LjqWYd13GW93KIl7GybyqeqOpSJdYFM96M741ufWQXMivDHQdNA= X-Received: by 2002:a24:25c1:: with SMTP id g184-v6mr1973608itg.120.1537739314417; Sun, 23 Sep 2018 14:48:34 -0700 (PDT) MIME-Version: 1.0 References: <1681263.Ri4PIu1jiQ@vulcan> <1476841B-EEBA-4513-8DD8-7ACE1F662372@gmail.com> <95a7902d-8451-06ee-debf-6f03c4fd7190@gmail.com> In-Reply-To: <95a7902d-8451-06ee-debf-6f03c4fd7190@gmail.com> Date: Sun, 23 Sep 2018 23:48:22 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000097d4d6057690d542" Subject: Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2 From: nikita.ppv@gmail.com (Nikita Popov) --00000000000097d4d6057690d542 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Sep 23, 2018 at 10:08 PM Rowan Collins wrote: > On 23/09/2018 19:41, Claude Pache wrote: > >> 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). > > Just to be sure you don=E2=80=99t miss the herd that this elephant is c= oncealing: > > > > In addition, you *must* forbid unset() on those properties... > > > We "must" forbid this IF we aim to guarantee that the object never has > uninitialised properties; but the current consensus is that we can't > make such a guarantee without changing a lot of other parts of the > language. > > There are strong feelings that unset should be available for use in > lazy-initialisation hacks, so this is likely to remain one of the > back-doors which will let elephants in, unless and until someone comes > up with a replacement for that hack. > There might be a compromise here, which is to only perform a ctor initialization check and forbid explicit unset()s if the class does not use property accessors (i.e. does not define __get). This allows the lazy initialization pattern but is stricter for everything else. (Possibly __get in subclasses would also count.) Nikita --00000000000097d4d6057690d542--