Coroutine::getSuspendFileAndLine

(PHP 8.6+, True Async 1.0)

public Coroutine::getSuspendFileAndLine(): array

Returns the file and line number where the coroutine was suspended (or was last suspended).

Return Value

array – an array of two elements:

Examples

Example #1 Basic usage

<?php

use function Async\spawn;
use function Async\suspend;

$coroutine = spawn(function() {
    suspend(); // line 7
});

suspend(); // let the coroutine suspend

[$file, $line] = $coroutine->getSuspendFileAndLine();
echo "Suspended at: $file:$line\n"; // /app/script.php:7

See Also