Req #74338 [Opn->Wfx]: separate namespace of static member and non-static member

From: Date: Thu, 30 Mar 2017 08:20:27 +0000
Subject: Req #74338 [Opn->Wfx]: separate namespace of static member and non-static member
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208176@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74338&edit=1 ID: 74338 Updated by: requinix@php.net Reported by: uukoo at 163 dot com Summary: separate namespace of static member and non-static member -Status: Open +Status: Wont fix Type: Feature/Change Request Package: *General Issues PHP Version: 7.1.3 Block user comment: N Private report: N New Comment: Contrary to popular belief, :: does not mean a static call. It is called the scope resolution operator because that is what it does: resolve scope. You've probably used it before with a parent::__construct in a constructor, and that's definitely not a static call. Foo::bar always refers to the same method. When used inside of the Foo scope (which includes child classes) bar may be either an instance or static method, and PHP will call it appropriately. When used outside of Foo the method must be static because there is no instance available for PHP to use. parent, self, and static work similarly but target different scopes: respectively, the parent class (or a further ancestor), the current class, and the LSB class. Previous Comments: ------------------------------------------------------------------------ [2017-03-30 07:35:26] uukoo at 163 dot com Description: ------------ Can we separate namespace of static member and non-static member. So we can declare static and non-static member with same name. Test script: --------------- class Foo { public function bar() { echo 'This is a non-static method.'; } static public function bar() { echo 'This is a static method.'; } } // What we want Foo::bar(); // echoes 'This is a static method.' (new Foo)->bar(); // echoes 'This is a non-static method.' // Actually happens Fatal error: Cannot redeclare Foo::bar() been thrown. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74338&edit=1

« previous php.bugs (#208176) next »