Doc #78218 [NEW]: function intercepts execution of code that is not executed

From: Date: Wed, 26 Jun 2019 14:05:19 +0000
Subject: Doc #78218 [NEW]: function intercepts execution of code that is not executed
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16775@lists.php.net to get a copy of this message
From:             lozinskiy dot artem at gmail dot com
Operating system: Ubuntu 18.04 LTS
PHP version:      7.1.30
Package:          Unknown/Other Function
Bug Type:         Documentation Problem
Bug description:function intercepts execution of code that is not executed

Description:
------------
---
From manual page: https://php.net/function.register-tick-function
---
PHP Version 7.1.30-1+ubuntu18.04.1+deb.sury.org+
Linux ubuntu 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC
2018 x86_64
---

function intercepts execution of code that is not executed

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

function my_function() {

    echo print_r(debug_backtrace(), 1) . '<br/>';
    
}

register_tick_function('my_function', true);

$t = false;
$ar = ['test1' => '111'];

var_dump('->' . __METHOD__ . ' on ' . __FILE__ . ':' . __LINE__);

foreach ($ar as $k => $e) {
    
    $t = ($k === 'test2');
    
    var_dump('$t==='. var_export($t, 1));
    
    if ($t===false) {
        continue;
    }
    
    var_dump('this line code is not executed (execute "continue")');
    
    test2();
    test3();    // this will handled or ..
    // test4(); // uncomment this and this will handled (but function
not exist)
}

var_dump('->' . __METHOD__ . ' on ' . __FILE__ . ':' . __LINE__);

function test2() {
    // this never handled (why? =))
    return 1;
}

function test3() {
    var_dump('->' . __METHOD__ . ' on ' . __FILE__ . ':' .
__LINE__);
}

Expected result:
----------------
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 10 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 12 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 13 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:15:string '-> on
/var/www/test.local/public/test/tick.php:15' (length=49)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 15 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 19 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:21:string '$t===false'
(length=10)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 21 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:34:string '-> on
/var/www/test.local/public/test/tick.php:34' (length=49)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 34 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 39 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 43 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 

Actual result:
--------------
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 10 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 12 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 13 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:15:string '-> on
/var/www/test.local/public/test/tick.php:15' (length=49)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 15 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 19 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:21:string '$t===false'
(length=10)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 21 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 30 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
/var/www/test.local/public/test/tick.php:34:string '-> on
/var/www/test.local/public/test/tick.php:34' (length=49)
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 34 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 39 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 
Array ( [0] => Array ( [file] =>
/var/www/test.local/public/test/tick.php [line] => 43 [function] =>
my_function [args] => Array ( [0] => 1 ) ) ) 

---
that wrong...
---
on line 30 function intercepted execution on this line

-- 
Edit bug report at https://bugs.php.net/bug.php?id=78218&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=78218&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=78218&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=78218&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=78218&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=78218&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=78218&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=78218&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=78218&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=78218&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=78218&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=78218&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=78218&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=78218&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78218&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=78218&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=78218&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=78218&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78218&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=78218&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=78218&r=mysqlcfg



Thread (17 messages)

« previous php.doc.bugs (#16775) next »