Bug #74712 [Opn]: Now have to redeclare ticks on every file in PHP 7
| From: | hello at peterfeatherstone dot com | Date: | Thu, 08 Jun 2017 16:53:20 +0000 |
| Subject: | Bug #74712 [Opn]: Now have to redeclare ticks on every file in PHP 7 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209421@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74712&edit=1
ID: 74712
User updated by: hello at peterfeatherstone dot com
Reported by: hello at peterfeatherstone dot com
Summary: Now have to redeclare ticks on every file in PHP 7
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Ubuntu 17.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Replication code:
index.php
<?php
declare(ticks=1);
$count = 0;
register_tick_function('ticker');
function ticker() {
global $count;
$count++;
}
$foo = 'foo';
$bar = 'bar';
include dirname(__FILE__) . '/inc.php';
echo $count;
inc.php
$baz = "baz";
$qux = "qux";
Previous Comments:
------------------------------------------------------------------------
[2017-06-08 16:49:09] hello at peterfeatherstone dot com
Sure, no problem - although your recommendations say to link externally if its pver 20 lines so I
couldnt paste it...
------------------------------------------------------------------------
[2017-06-08 16:43:59] peehaa@php.net
Please add the repro code on here instead of having to hunt for it on an external site with the
possibility of the link going down.
------------------------------------------------------------------------
[2017-06-08 16:38:21] hello at peterfeatherstone dot com
Description:
------------
In PHP 5.6 it seems that adding declare(ticks=1) and then using register_tick_function() would
follow any includes and provide profiling information accordingly.
In PHP 7+ however it now seems I have to add declare(ticks=1) in every file. I use this for
profiling every method call on a page load and can't now add this to each PHP file in my system
(If they are in libraries etc.).
I can't find anything in the docs about changes that were made to this or an alternative method
for profiling every tick in the application.
Test script:
---------------
Replication code can be found here - https://stackoverflow.com/questions/44440613/how-to-avoid-redeclaring-ticks-on-every-file-in-php-7?noredirect=1#comment75879747_44440613
Expected result:
----------------
Running php index.php I would expect to see 7
Actual result:
--------------
In PHP 5.6 I see 7 as expected
In PHP 7 I see 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74712&edit=1