Bug #52900 [Opn->Bgs]: Protected instance method called by static method of the same class
| From: | cataphract@php.net | Date: | Tue, 21 Sep 2010 15:09:13 +0000 |
| Subject: | Bug #52900 [Opn->Bgs]: Protected instance method called by static method of the same class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-154535@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52900&edit=1
ID: 52900
Updated by: cataphract@php.net
Reported by: e dot visciola at xaos dot it
Summary: Protected instance method called by static method of
the same class
-Status: Open
+Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: WIN & OSX
PHP Version: Irrelevant
Block user comment: N
New Comment:
Not a bug.
Inside the static method, the calling scope is A. The scope of
instanceMethod is also A.
Protected methods are accessible whenever their scope and the calling
scope are in the same class hierarchy.
Previous Comments:
------------------------------------------------------------------------
[2010-09-21 16:02:01] e dot visciola at xaos dot it
Description:
------------
When I call a protected instance method of an object inside a class
method of "the same type" I'd like to have an error.
The example explain:
Test script:
---------------
class A {
protected function instanceMethod()
{
echo 'Instance method called, but it is not right because instance
method is protected<br />';
}
public static function staticMethod()
{
echo 'Static method called<br />';
$a = new A();
$a->instanceMethod();
}
}
A::staticMethod();
Expected result:
----------------
That was generated an error to access the protected method
Actual result:
--------------
Static method called
Instance method called, but it is not right because instance method is
protected
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52900&edit=1