Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97748 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32326 invoked from network); 14 Jan 2017 10:04:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2017 10:04:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.28.122 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.122 mx201.easyname.com Received: from [212.232.28.122] ([212.232.28.122:52180] helo=mx201.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/85-00729-597F9785 for ; Sat, 14 Jan 2017 05:04:07 -0500 Received: from cable-81-173-135-7.netcologne.de ([81.173.135.7] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cSLBq-00055y-OF; Sat, 14 Jan 2017 10:04:02 +0000 Reply-To: internals@lists.php.net References: <0DE25BF8-D349-48EF-A83B-8837DD4AD1E0@gmail.com> <5efcc230-c67b-4439-cc82-b31eacbf36db@php.net> To: Wes , PHP Internals , sebastian@php.net Message-ID: <7c8c8801-a849-6fd2-91e9-954030c55e83@fleshgrinder.com> Date: Sat, 14 Jan 2017 11:03:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch From: php@fleshgrinder.com (Fleshgrinder) On 1/13/2017 8:24 AM, Wes wrote: >> >> I am baffled that this (still) works: >> > > __clone was special cased in 5.x, but special case was removed in 7.0 > means that previously you couldn't do publicly $obj->__clone(); now you can > and, yes, it's as dangerous as it looks > however, the special case was removed for a reason that i'm sure is a good > one, and i'm certain the same good reason is also valid for __construct > What is the reason? On 1/13/2017 8:24 AM, Wes wrote: >> the only reason for prohibiting explicit __construct calls is that it makes >> PHP objects mutable > > > then don't call it explicitly, exactly like you wouldn't use reflection to > call private methods > This is one possible answer to this issue. The question is whether PHP wants to protect developers from errors and help reduce bugs by enforcing things or wants to be a purely convention based language and leave it developers to use it correctly. I am completely in favor of #1 and you seem to be in favor of #2. I actually have the impression that it is not defined which of both PHP actually is or wants to be. The introduction of scalar type hints in PHP 7 definitely points towards #1 but it could just be an outlier. -- Richard "Fleshgrinder" Fussenegger