Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97751 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42253 invoked from network); 14 Jan 2017 12:15:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2017 12:15:31 -0000 Authentication-Results: pb1.pair.com header.from=andreas@heigl.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andreas@heigl.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain heigl.org from 195.191.240.18 cause and error) X-PHP-List-Original-Sender: andreas@heigl.org X-Host-Fingerprint: 195.191.240.18 hos109.unaxus.net Received: from [195.191.240.18] ([195.191.240.18:59847] helo=hos109.unaxus.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/C6-00729-2661A785 for ; Sat, 14 Jan 2017 07:15:31 -0500 Received: from [217.243.245.83] (port=20442 helo=[172.16.96.107]) by hos109.unaxus.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cSNF0-000Lns-3m; Sat, 14 Jan 2017 13:15:26 +0100 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) X-Mailer: iPhone Mail (14C92) In-Reply-To: <2051639b-1b63-2e44-51b0-381caa54dfd0@fleshgrinder.com> Date: Sat, 14 Jan 2017 13:15:25 +0100 Cc: Wes , sebastian@php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <0DE25BF8-D349-48EF-A83B-8837DD4AD1E0@gmail.com> <5efcc230-c67b-4439-cc82-b31eacbf36db@php.net> <7c8c8801-a849-6fd2-91e9-954030c55e83@fleshgrinder.com> <2051639b-1b63-2e44-51b0-381caa54dfd0@fleshgrinder.com> To: internals@lists.php.net X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hos109.unaxus.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heigl.org X-Get-Message-Sender-Via: hos109.unaxus.net: authenticated_id: a.heigl+heigl.org/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hos109.unaxus.net: a.heigl@heigl.org Subject: Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch From: andreas@heigl.org (Andreas Heigl) > Am 14.01.2017 um 11:26 schrieb Fleshgrinder : >=20 >> On 1/14/2017 11:20 AM, Andreas Heigl wrote: >> Do we as "makers of PHP" want to dictate the user what the "intended" >> behaviour of PHP is? Or are we treating the user as a responsible person >> that knows what to do and also not to do? >>=20 >> Personally I'm in favour of the later. Let the user be able to call >> __construct whenever they like. It's a special method which is clearly >> visible by the two underscores at the start. So the users either know >> exactly what they are doing or they need to learn it. >>=20 >> Translated to a different example this discussion is like: "Let's remove >> the handle from the window because someone might be able to open the >> window and jump out of it". The handle is there for a valid reason. And >> as a window-maker I have no idea in what way it might be used. But I >> have to accept that there are people missusing it. But should I limit >> all those users with a valid use-case for it just to save some from >> missusing it? And if we start with that, where should we stop? >>=20 >> Just my 0.02=E2=82=AC >>=20 >> Cheers >>=20 >> Andreas >>=20 >=20 > Yes, that is exactly the question. This needs to be voted on. Rust would > be an example that protects you and C/C++ would be examples that do not. > Both approaches are valid approaches. >=20 > Note that the dictation will not always work, this is why e.g. Rust has > unsafe blocks. The corresponding thing in PHP imho would be reflection. > Hence, if someone has a special case: >=20 > - Rust: use unsafe > - PHP: use reflection >=20 > --=20 > Richard "Fleshgrinder" Fussenegger IMHO it already IS safe.=20 In PHP 4 the "constructor" was a method thad had the same name as the class.= But now it is a class that has always the same name and is always preceded w= ith two underscores. There is no way to "accidentaly" call that method. You h= ave to explicitly call "__construct" to "break" things.=20 If developers "want" to break something they will find a way. Protecting "__= construct" will not stop them from doing so. But it will stop the rest of us= do legitimate things.=20 Cheers Andreas=