Bug #52386 [Opn->Bgs]: ReflectionClass scope problem
| From: | aharvey@php.net | Date: | Thu, 22 Jul 2010 03:01:45 +0000 |
| Subject: | Bug #52386 [Opn->Bgs]: ReflectionClass scope problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152598@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52386&edit=1
ID: 52386
Updated by: aharvey@php.net
Reported by: laszlo dot janszky at gmail dot com
Summary: ReflectionClass scope problem
-Status: Open
+Status: Bogus
Type: Bug
Package: Reflection related
Operating System: xp
PHP Version: 5.3.2
New Comment:
That's by design -- reflection's not intended to provide a backdoor
around the usual access specification mechanism.
Previous Comments:
------------------------------------------------------------------------
[2010-07-21 13:16:16] laszlo dot janszky at gmail dot com
Description:
------------
Maybe it's not a bug, but I cannot call private or protected
methods from within a class by ReflectionClass.
Test script:
---------------
<?php

class
Test
{
	static public function
instance()
	{
		$class=new
ReflectionClass(get_called_class());
		return
$class->newInstanceArgs(func_get_args());
	}
	
	private
function
__construct()
	{}
}

Test::instance();
Expected result:
----------------
Create a new instance.
Actual result:
--------------
Fatal error: Uncaught exception 'ReflectionException'
with message 'Access to non-public constructor of class
Test'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52386&edit=1