note 54103 rejected from function.is-callable by nlopess
| From: | nlopess@php.net | Date: | Thu, 23 Jun 2005 19:48:46 +0000 |
| Subject: | note 54103 rejected from function.is-callable by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90853@lists.php.net to get a copy of this message | ||
Note Submitter: php at adaniels dot nl
----
Please not that is_callable will not handle private/public well from within a class:
<?php
class X {
private function getXX($value) {
return "XX $value";
}
function testXX() {
echo (is_callable(array($this, 'getXX')) ? $this->getXX("test") :
"Can't call getXX within " . __CLASS__) . "\n";
}
}
class Y extends X {
function testXX() {
echo (is_callable(array($this, 'getXX')) ? $this->getXX("test") :
"Can't call getXX within " . __CLASS__) . "\n";
}
}
$x = new X;
echo (is_callable($x, 'getXX') ? $x->getXX("test") : "Can't call
getXX outside for " . get_class($x)) . "\n";
$x->testXX();
$y = new y;
echo (is_callable($y, 'getXX') ? $y->getXX("test") : "Can't call
getXX outside for " . get_class($y)) . "\n";
$y->testXX();
?>
Results in:
Can't call getXX outside for X
XX test
Can't call getXX outside for Y
<br />
<b>Fatal error</b>: Call to private method X::getXX() from context 'Y' in
...
While we would expect for $y->testXX():
Can't call getXX within Y
I believe this is a bug and will report it as so (as soon as I find out how)