Bug #61025 [Opn->Csd]: __invoke() visibility not honored
Edit report at https://bugs.php.net/bug.php?id=61025&edit=1
ID: 61025
Updated by: laruence@php.net
Reported by: jpauli@php.net
Summary: __invoke() visibility not honored
-Status: Open
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: *nix
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=01049ca7aed40a5f1081d0303c69a40dae0f982e
Log: Fixed bug #61025 (__invoke() visibility not honored)
Previous Comments:
------------------------------------------------------------------------
[2013-03-07 14:27:32] laruence@php.net
the __toString is more likely:
<?php
class A {
private function __toString() {
echo __CLASS__;
}
}
$a = new A;
echo $a;
echo $a->__toString();
?>
result:
PHP Warning: The magic method __toString() must have public visibility and
cannot be static in /tmp/1.php on line 3
A
PHP Fatal error: Call to private method A::__toString() from context '' in
/tmp/1.php on line 10
so, I don't see much problem here, I think we only need a warning is okey. since
it's a magic method, not a normal method.
------------------------------------------------------------------------
[2013-03-07 03:20:30] laruence@php.net
I don't think this need to be fixed in this way, like __call:
```php
<?php
class Bar {
private function __call($name, $value) {
return __CLASS__;
}
}
$b = new Bar;
$b->__call("name", NULL);
```
works well, but with an warning:
```
Warning: The magic method __call() must have public visibility and cannot be
static
```
I am not sure whether this is a bug, or just need document.
------------------------------------------------------------------------
[2013-03-06 16:58:22] reeze@php.net
Hi, I made a patch again 5.5. how about fix it in 5.5?
------------------------------------------------------------------------
[2012-07-30 02:22:11] willfitch@php.net
johannes - I can commit a fix for this, but at what point should it be introduced?
------------------------------------------------------------------------
[2012-02-10 22:34:44] johannes@php.net
Yes, the current behavior is wrong. I don't think it should be fixed in 5.3 though as the fix
might break existing code.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=61025
--
Edit this bug report at https://bugs.php.net/bug.php?id=61025&edit=1
Thread (9 messages)