Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79355 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51045 invoked from network); 1 Dec 2014 20:17:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2014 20:17:55 -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.192.170 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.192.170 mail-pd0-f170.google.com Received: from [209.85.192.170] ([209.85.192.170:43650] helo=mail-pd0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/43-32869-2FCCC745 for ; Mon, 01 Dec 2014 15:17:55 -0500 Received: by mail-pd0-f170.google.com with SMTP id fp1so11536722pdb.15 for ; Mon, 01 Dec 2014 12:17:52 -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:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=R1MF/hKplt9N/m000nLeFfeMDitEyHjWQuP5xNusdFk=; b=isWyFDc/Ofbv0yO3HBdl/FMPUwNOTqGIKRPcaFNfkvw5H1M8OIUkRHgo47pL3Ltl4A oGZAlQpUS4KXgGrIdmBAy1UtP5R1shHP8ue1Fg5E3RZtoAgI+IUvFp4ufmvUS8Ly9WKz U722KUw7wa5ursCmXq4R6xkpL1c1QiUKilKFQcUysDSuprS8QoA2ZyscbV/MdZs4F6g6 7OvlJlWSWGagn7VFMiGUxwa4Rd4zfem8xFVoPykSORjzUc5dG75YpGJqyfaEre/hik2W CNS1UHKCvPpTXaxo4ij1vEauM4NOBfMrGNNJosPlYRcVWkb2SVU+G5IL0TYi53XBFxmK ohFQ== X-Received: by 10.66.179.16 with SMTP id dc16mr105519097pac.11.1417465072171; Mon, 01 Dec 2014 12:17:52 -0800 (PST) Received: from stas-air.corp.wikimedia.org (tan4.corp.wikimedia.org. [198.73.209.4]) by mx.google.com with ESMTPSA id nr15sm2739833pdb.73.2014.12.01.12.17.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Dec 2014 12:17:51 -0800 (PST) Message-ID: <547CCCEC.9060307@gmail.com> Date: Mon, 01 Dec 2014 12:17:48 -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: Rowan Collins , internals References: <003c01d00d6e$f4fd77c0$def86740$@tutteli.ch> <868FD3D8-4E80-46F4-872A-125D3FD8F40D@ajf.me> <547C991E.2070700@gmail.com> <547CB956.5010702@gmail.com> In-Reply-To: <547CB956.5010702@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Static classes (Was Abstract final classes) From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > static class Foo { > function bar() { > echo do_something_with($this); > } > } > > Much nicer (and just as easy) for that to give a compile-time error of > "Static class Foo cannot contain non-static function bar" than for it to > autoload fine, and then give a less obvious error when Foo::bar() is run > (probably to do with a non-existent variable, since $this is always > undefined inside a static function). This example is fit the narrow purpose of being the example, but you could have as easily written "static function bar" and be back to square one. I'm not sure how language-enforced "all methods must be static" is really useful - if you don't want to instantiate it, put a private ctor or make it abstract. If you want static methods, just make them static. It won't help you anyway if you use $this in static methods. -- Stas Malyshev smalyshev@gmail.com