Coroutine::getSpawnFileAndLine
(PHP 8.6+, True Async 1.0)
php
public Coroutine::getSpawnFileAndLine(): arrayReturns the file and line number where spawn() was called to create this coroutine.
Return Value
array -- an array of two elements:
[0]-- file name (stringornull)[1]-- line number (int)
Examples
Example #1 Basic usage
php
<?php
use function Async\spawn;
$coroutine = spawn(fn() => "test"); // line 5
[$file, $line] = $coroutine->getSpawnFileAndLine();
echo "File: $file\n"; // /app/script.php
echo "Line: $line\n"; // 5See Also
- Coroutine::getSpawnLocation -- Creation location as a string
- Coroutine::getSuspendFileAndLine -- Suspension file and line