Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39159 invoked from network); 22 Mar 2012 20:27:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2012 20:27:13 -0000 Authentication-Results: pb1.pair.com header.from=dmgx.michael@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmgx.michael@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: dmgx.michael@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:59218] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/6A-16309-F1B8B6F4 for ; Thu, 22 Mar 2012 15:27:12 -0500 Received: by werh12 with SMTP id h12so2517250wer.29 for ; Thu, 22 Mar 2012 13:27:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=bfzsEiXOSQBMRxEgisQa4EkYpyZnU0V3zRPrZSJ9NKM=; b=Thv+KluYESbPuOUiP0wfIBMltv34SvN/w2PSF13lKqZDOUcpuBuNPIWpEv2akJk045 9R3LpxYnufFyFo4mVv2UPUfSwHE319kXrXeJXuJZHasjUk/Fjnpk8TznNZdIkp6KTE9b jLoTJ9rRh7R7HegVvLJFVQmWYY0Uu75iEQhxFf397xvJ4tyC2Ky75JX6mAGmH08ifyao ihdr5inHfix7dWcGuXPQcYSLWEEFAIVo90JmGafnnSFLFDRNDfE4fcCGL/HGdhGhr7Jw 9HVCumjzFHgKERL83Ye6Cj3zOwlcwcTGFX5ohehT7eQ62THGhQaLAorESChoQj3zlQSX y9Mw== MIME-Version: 1.0 Received: by 10.180.105.194 with SMTP id go2mr484667wib.22.1332448028523; Thu, 22 Mar 2012 13:27:08 -0700 (PDT) Received: by 10.216.229.86 with HTTP; Thu, 22 Mar 2012 13:27:08 -0700 (PDT) Date: Thu, 22 Mar 2012 16:27:08 -0400 Message-ID: To: PHP Internals List Content-Type: text/plain; charset=ISO-8859-1 Subject: [PHP-DEV] Override keyword From: dmgx.michael@gmail.com (Michael Morris) Without cluttering the RFC list up further (I fear I've done too much of that with the last two bombed suggestions), I'd just like to come out and ask if the addition of an override keyword on classes had ever been considered? I'd see it as more than a self documenting thing for BC reasons than anything else since, for BC we have to allow functions to override even if they don't have the keyword. But if a method is declared as an override, and none of the parent classes or imported traits have that method, then stating override would be a fatal error. Or, given... class A { public function foo() {} } class B extends A { public function foo ( $val ) {} } This is ok to avoid a backwards compat break, though if a move to require the override keyword was desired an E_STRICT might be raised. class C extends A { public override function foo ( $val ) {} } The only real advantage I will admit is self documentation by the code. We know C's foo is overriding something without opening A's class file. class D extends A { public override function bar ( $val ) {} } And this would raise E_FATAL. No existing code would be affected, and a programmer using this keyword would, I assume, want to be alerted that the override they are expecting doesn't exist. After all, if their override calls the parent method, they'd get an error anyway. I can write an RFC for this, but the last two I wrote got shouted down in such swift succession I think it would be better to get this vetted before writing the RFC.