After correcting Ruben de Vries for using declaring ticks during compilation, there are two things in the source code (except for the lack of an INT signal).
As Ruben says:
if(false) declare(ticks=1);
This means that ticks will be processed. Give it a try! The docs say how you cannot use variables, etc. This is compilation time.
In addition, using pcntl_signal_dispatch() not a direct substitute for declaring ticks — it must be called at runtime — for example, ticks are executed automatically. Thus, calling it once in the head of the script seems to process any signals awaiting consideration at this point.
For pcntl_signal_dispatch () to work like using ticks to drive it, you will need to sprinkle it all over your code ... depending on where / when you want the interrupts to take effect.
At least:
while(true){ sleep(1); echo date(DATE_ATOM). "\n"; pcntl_signal_dispatch(); }
Thus, the source code actually uses ticks for all versions of PHP and additionally checks only one signal received at boot time if the version is greater than 5.3. Not what the OP intended.
Personally, I think that using ticks to control PCNTL signals a huge dirty pain. The "loop" in my case is in third-party code, so I can’t add a submit method, and declaring ticks at the top level doesn’t work in production unless I add it to every file (some autoload, scope or PHP7 version I think a specific problem )
source share