php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65071 magic __call not implemented as documented
Submitted: 2013-06-20 15:47 UTC Modified: 2013-10-04 17:26 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: simong at ganz dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.3.26 OS:
Private report: No CVE-ID: None
 [2013-06-20 15:47 UTC] simong at ganz dot com
Description:
------------
---
From manual page: http://php.net/manual/en/language.oop5.magic.php
---
Reflected invocation of protected method fails with:

"PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Trying to invoke protected method"

Documentation says:

"__call() is triggered when invoking inaccessible methods in an object context."

Should read:

"__call() is triggered when invoking invisible methods in an object context."



Test script:
---------------
<?php
class test {
	public function __call($name, $args) {
		return 123;
	}
}

class testdev extends test {
	protected function cansee() {
		return 456;
	}
}

$x = new testdev();
$r = new ReflectionMethod($x, 'cansee');

echo $r->invoke($x) . "\n";



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-04 17:26 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2013-10-04 17:26 UTC] krakjoe@php.net
This is just semantics; I don't see a need to change them.

Technically, private/protected/public are in fact access modifiers and not visibility modifiers ... method_exists, or just method calls illustrate this, from a context where a protected method is not accessible it is still visible.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC