Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114380 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42997 invoked from network); 11 May 2021 13:49:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 13:49:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5B2141804B1 for ; Tue, 11 May 2021 06:57:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 May 2021 06:57:46 -0700 (PDT) Received: by mail-wr1-f47.google.com with SMTP id v12so20231877wrq.6 for ; Tue, 11 May 2021 06:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=e2vgSeedsGpUdyAFeYtm8DnkYUDAZZDqB17p8mLOT3U=; b=QpAAv41pD4fFCqEIwGSyz3hRZdvMkwTruBA4FuH5ikLYmovk7FLyD5WrDD/RnxGmtC OGQxbH6G3sdJWxptqSg/mFh0/sWEuAIXkg0QLtYr3bubCVjLMNp1+r8wiNd4eNg6nn9E JvNJTKTspVQYw6avNmV50EkI0rsQUDV2sdpyOrajdpTTdZH+F3EsUb48Fw3lxisC1Zlb aMClYRiApmmkimDdxyJT28V6BDwj8wN+sjytcBfd/8nCx6wUAD7KgciTG8AFpjfpbq4B 8hJOWnHJb3GGqS+09DXq0LCdT8GTbVQZDT4TK7D9fuM0unlxKkkJO2nqKIZ1PFxSno4e cQxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=e2vgSeedsGpUdyAFeYtm8DnkYUDAZZDqB17p8mLOT3U=; b=HJL/EZoCGygF0jec3GLvMM1mmTCvnsRD1n1WOMzD2RmuxoigignknmJovvmxvYnZqi 5q/3ljSzWrCWb+dF7vECJdXuEYdJNq9RplvzTfQXmDV/rbFxRTu00jxjxSavtkYRvJVe Lj+mKRI4euL2gC85umVkDaHDFL7lLWwDiKNWIc8W0VzchDxEVRI4WBD4BG1B+PET+cV6 vErofYbT/wPb+0PItFq4VFaaJrAHCEm/isQl2SzN4ONV/QH/8j+s8DR/JBG8JO+jrQRD Gh4mIhEjRqDlgkGM/P2V63kPowNIbFSUm0XHjhumSStlkWeChXu0/MiWWVVpYhFi373U QHTw== X-Gm-Message-State: AOAM5335wqfmDBScAdYnSNOfZhq2sXO8h5mY/+3OG7S8aLIDy9cEyCak Hh5CuGaqjXo4LTHRp/i9s87ZETxJ3FQ= X-Google-Smtp-Source: ABdhPJzRGPzllW9ar16JjzNnuCxBes3CRb6lVrrFj+yOBmgmBSvF6GHSOWQNDeqZMdiVJFTEN2MHuw== X-Received: by 2002:a05:6000:188d:: with SMTP id a13mr2771842wri.61.1620741461714; Tue, 11 May 2021 06:57:41 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id i14sm4364835wmq.1.2021.05.11.06.57.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 May 2021 06:57:41 -0700 (PDT) To: internals@lists.php.net References: <3f3cb374-23d8-9d26-4ea2-fe891538a7b6@gmail.com> Message-ID: <47e8f7c7-6ae6-3744-b590-c3f39b144c46@gmail.com> Date: Tue, 11 May 2021 14:57:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <3f3cb374-23d8-9d26-4ea2-fe891538a7b6@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] New in initializers From: rowan.collins@gmail.com (Rowan Tommins) On 11/05/2021 14:12, Dik Takken wrote: > So the use of "new" in initializers would require extending this base > class and call the parent constructor. Maybe forgetting to do so could > throw, preventing initializers from silently not working. If we managed to get that working, I wonder if we could also include a check for uninitialized typed properties, a bit like Swift's "two-phase initializers". In short, make this throw an error: class Foo extends \PHP\Base {     private Logger $logger;     public function __construct() {         parent::construct(); // "Error: Property $logger has no default and was not initialized before calling Base constructor"     } } This would catch bugs closer to their source, where currently there is no error until $logger is accessed. However, the "if" at the beginning of this message is quite a big one: it's not obvious where to assert any of this, because the constructor is just called as a normal method *after* the engine considers the object to be "created". Regards, -- Rowan Tommins [IMSoP]