Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79259 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96729 invoked from network); 28 Nov 2014 06:34:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Nov 2014 06:34:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.49 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.49 mail-pa0-f49.google.com Received: from [209.85.220.49] ([209.85.220.49:52872] helo=mail-pa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/55-59154-E7718745 for ; Fri, 28 Nov 2014 01:34:39 -0500 Received: by mail-pa0-f49.google.com with SMTP id eu11so6151722pac.8 for ; Thu, 27 Nov 2014 22:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=ogFEu3Q9brimCdDfXmjAD/SlTt501ys2vF9xLB9IRXI=; b=wQLbSE/EQgphb7R4dcehIuGuGM9C9O+CyfHsbblKKpW9AF0kOebeLrz1JZAt9LRa3C rDsiKqCGihPZ5StTWRVkvOjbPvhI2hIPD883VrH0qo/viONkJbk4QC0Vm+jkHEUTBo01 etavMoiGZbYwttsjz+eQS/BkmsRstMzNLmD7RRsnvl5MmQ4O7pPzhT+ZKvqv2vTvC89i t2p+iURORHvtMwbSUZBItaFhOiYLgbxEq4inZWiw6w/zWUtOgyU3oGUxeo2knKM5oiHZ FiZpzHA0Rw3IF8z6SPES2NjWy9X223QeLputFFmnmDyM/0WVoxQK/cnXgplsfQohf+gH oJhA== X-Received: by 10.70.41.137 with SMTP id f9mr17537383pdl.83.1417156475252; Thu, 27 Nov 2014 22:34:35 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id v2sm8871242pdm.19.2014.11.27.22.34.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Nov 2014 22:34:34 -0800 (PST) Message-ID: <54781777.6090208@gmail.com> Date: Thu, 27 Nov 2014 22:34:31 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "guilhermeblanco@gmail.com" , Rowan Collins CC: PHP internals References: <547723A8.8090008@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Abstract final classes From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > By forgetting "static" in any of your declared methods, you get no parse > error and gives you 2 possibilities: > - With E_STRICT enabled: Fatal error when non-static method is being > statically called. You'll only get this at runtime, leading to potentially > error prone. Now the testability come that with this addiction, you get a > fatal error, which is easily fixable at compile time, not runtime. I don't see how it matters for testability - sure, if you don't test your functions, you don't see the errors, but that's just best practice. Also, since PHP is not a compiled language, practical difference between "compile time" and "runtime" does not really exist. > - With E_STRICT disabled: You get a warning on php log and everything works > (which is a huge wtf mode). Not everything, your functions still do not. If you write a function and put it in production without ever trying to run it even once, that's something that needs to be fixed (and you could as well have made a typo in a function name or written whille() - there are a lot of errors that one can make and PHP does not catch, especially if you never run your code). Otherwise, the error is immediately obvious. > My end goal is to add class visibility to PHP. Unfortunately, I was forced I'm not sure how it is related, but if it's not directly connected then since that RFC does not exist AFAIK I don't think it can be an argument for this one. If it is directly connected then maybe it could wait for that RFC but then connection needs to be explained. > No, because conceptually, a static something means that subsequent calls > always return same value. A static class means a singleton, not what this I'm not sure where it comes from - static function definitely does not return same value on each call. Neither do static variables (which are just class variables, but not immutable) or static closures (which are just unbound closures). The only case where it is kind of true is static variable in function, if you replace "value" by "variable", but this is only because the syntax was borrowed from C. So static in PHP means a lot of thing but the general gist is "not subject to current scope". Where the "static class means a singleton" came from? Could you explain? > You are correct. Methods cannot be declared abstract if you have an > "abstract final". They must also be static. I added these checks together To me, it just feels a bit unnatural. So you have abstract class, which usually has abstract methods. Then you have "abstract final" class which can not have abstract methods, but instead should have "static" methods. This just sounds a bit weird to me - adding "final" to description of the class completely changes all the rules in very unexpected direction. -- Stas Malyshev smalyshev@gmail.com