Edit report at https://bugs.php.net/bug.php?id=63482&edit=1

 ID:                 63482
 Updated by:         ni...@php.net
 Reported by:        dev at pp3345 dot de
 Summary:            register_tick_function() does not work correctly
                     with private methods
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Debian Squeeze
 PHP Version:        5.4.8
 Block user comment: N
 Private report:     N

 New Comment:

As the tick function is not called in the class scope it also can't access its 
private methods. That's the whole point of private methods. This is also not 
specific to ticks, its the same with all private-method callbacks: They will 
only work if they are invoked from within the class.


Previous Comments:
------------------------------------------------------------------------
[2012-11-10 19:12:40] dev at pp3345 dot de

Description:
------------
Registering a private method as a tick function leads to two errors on every 
tick.

Test script:
---------------
<?php
declare(ticks = 1);

class A {
        public function __construct() {
                register_tick_function(array($this, 'a'));
        }

        private function a() {
                echo 'Called';
        }
}

new A;

?>


Expected result:
----------------
CalledCalledCalled

Actual result:
--------------
Called
Warning: Invalid callback A::a, cannot access private method A::a() in 
/var/vhosts/pancake/default/register_tick_function.php on line 15

Warning: main(): Unable to call A::a() - function does not exist in 
/var/vhosts/pancake/default/register_tick_function.php on line 15

Warning: Invalid callback A::a, cannot access private method A::a() in 
/var/vhosts/pancake/default/register_tick_function.php on line 17

Warning: main(): Unable to call A::a() - function does not exist in 
/var/vhosts/pancake/default/register_tick_function.php on line 17


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63482&edit=1

Reply via email to