php / php/php-src

register_tick_function() not work in external file

Open
#19,275 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

+ php main.php | grep f2 || echo "f2 function not appear"
f2 function not appear

Why?

Here are some details

+ ls -1
f2.php
main.php



+ cat main.php 
<?php
declare(ticks=1);
require 'f2.php'; // external file

register_tick_function(
    function () {
        debug_print_backtrace();
        echo "\n";
    }
);

function f1() {
    f2();
}

f1();



+ cat f2.php 
<?php
declare(ticks=1);
function f2() {}



+ php main.php 
#0 /tmp/tmp.UFjE757TrJ/main.php(9): {closure}()

#0 /tmp/tmp.UFjE757TrJ/main.php(13): {closure}()
#1 /tmp/tmp.UFjE757TrJ/main.php(16): f1()

#0 /tmp/tmp.UFjE757TrJ/main.php(16): {closure}()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported php main.php | grep f2 || echo "f2 function not appear" reproduction and inspect main.php together with the externally required f2.php. Compare the tick callbacks around the f2() call and determine whether the missing callback is expected or indicates a runtime bug; document the confirmed behavior and add a focused regression test if appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.