Bug #72966 [NEW]: declare(ticks=1) doesn't seem to be impacting files included by a parent file
| From: | matt dot minix at gmail dot com | Date: | Mon, 29 Aug 2016 17:49:37 +0000 |
| Subject: | Bug #72966 [NEW]: declare(ticks=1) doesn't seem to be impacting files included by a parent file | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-13863@lists.php.net to get a copy of this message | ||
From: matt dot minix at gmail dot com
Operating system: CentOS Linux release 7.2.1511
PHP version: 7.0.10
Package: Documentation problem
Bug Type: Bug
Bug description:declare(ticks=1) doesn't seem to be impacting files included by a parent file
Description:
------------
---
From manual page: http://www.php.net/control-structures.declare
---
It's possible I'm making some silly mistake, but, I'm 95% sure I was
able to do this in 5.x and I don't see anything saying it's been undone,
and in looking to see if this report has any duplicates I came across an
example of it working as I'd expect it to rather than how it currently
is. From the documentation there's
"The declare construct can also be used in the global scope, affecting
all code following it (however if the file with declare was included
then it does not affect the parent file)."
My interpretation of that is a parent file can for example have
declare(ticks=1); and then a file included by that file that will still
have the tick function called per tick. That does not seem to be the
case at the moment, see test script below.
Test script:
---------------
Two files! If you put everything in one file it will work as intended,
Files start.php and test.php
<- start.php ->
<?php
declare(ticks=1);
register_tick_function(function() {
echo " tick \n";
});
require_once("test.php");
$A = new foo();
$A->bar();
<- test.php ->
<?php
class foo {
function bar() {
for($i = 0; $i < 10; $i++) {
echo $i;
}
}
}
Expected result:
----------------
(This is what you get if it is all in one file)
tick
tick
tick
0 tick
1 tick
2 tick
3 tick
4 tick
5 tick
6 tick
7 tick
8 tick
9 tick
tick
tick
Actual result:
--------------
tick
tick
tick
0123456789 tick
--
Edit bug report at https://bugs.php.net/bug.php?id=72966&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72966&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72966&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72966&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72966&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72966&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72966&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72966&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72966&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72966&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72966&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72966&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72966&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72966&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72966&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72966&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72966&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72966&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72966&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72966&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72966&r=mysqlcfg