Bug #55137 [Asn->Csd]: Changing trait static method visibility
| From: | felipe@php.net | Date: | Wed, 06 Jul 2011 00:33:41 +0000 |
| Subject: | Bug #55137 [Asn->Csd]: Changing trait static method visibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161625@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55137&edit=1
ID: 55137
Updated by: felipe@php.net
Reported by: connec dot 2002 at gmail dot com
Summary: Changing trait static method visibility
-Status: Assigned
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Irrelevant
PHP Version: 5.4.0alpha1
Assigned To: gron
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-07-05 20:33:37] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=312972
Log: - Fixed bug #55137 (Changing trait static method visibility)
------------------------------------------------------------------------
[2011-07-05 14:07:13] connec dot 2002 at gmail dot com
Description:
------------
When changing the visibility of a static method from a trait, it seems the methods
static-ness is removed.
The test script should be expected to work, as B uses A::foo as public. Instead
you get a fatal error: "Non-static method B::foo() cannot be called statically".
Omitting the 'as' segment throws an expected visibility error "Call to protected
method B::foo() from context ''".
Note: the same occurs when visibility isn't changed (but as is still used), e.g.
if A::foo is declared public but B's definition doesn't change, the same problem
is found. The only solution that will run is to not change static method
visibility, and instead change the trait definition.
Test script:
---------------
<?php
trait A {
protected static function foo() { echo 'lolwas'; }
}
class B {
use A {
A::foo as public;
}
}
B::foo();
?>
Expected result:
----------------
lolwas
Actual result:
--------------
Fatal error: Non-static method B::foo() cannot be called statically in
C:\Server\Apache\htdocs\tests\trait_static_visibility.php on line 13
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55137&edit=1