|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52386 ReflectionClass scope problem
Submitted: 2010-07-21 13:16 UTC Modified: 2010-07-22 07:00 UTC
From: laszlo dot janszky at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.3.2 OS: xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: laszlo dot janszky at gmail dot com
New email:
PHP Version: OS:


 [2010-07-21 13:16 UTC] laszlo dot janszky at gmail dot com
Maybe it's not a bug, but I cannot call private or protected methods from within a class by ReflectionClass.

Test script:

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


Expected result:
Create a new instance.

Actual result:
Fatal error: Uncaught exception 'ReflectionException' with message 'Access to non-public constructor of class Test'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-22 05:01 UTC]
-Status: Open +Status: Bogus
 [2010-07-22 05:01 UTC]
That's by design -- reflection's not intended to provide a backdoor
around the usual access specification mechanism.
 [2010-07-22 07:00 UTC] laszlo dot janszky at gmail dot com
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 04:01:34 2024 UTC