Coroutine::getSpawnFileAndLine

(PHP 8.6+, True Async 1.0)

public Coroutine::getSpawnFileAndLine(): array

Restituisce il file e il numero di riga dove spawn() è stato chiamato per creare questa coroutine.

Valore di ritorno

array – un array di due elementi:

Esempi

Esempio #1 Uso base

<?php

use function Async\spawn;

$coroutine = spawn(fn() => "test"); // riga 5

[$file, $line] = $coroutine->getSpawnFileAndLine();

echo "File: $file\n";  // /app/script.php
echo "Riga: $line\n"; // 5

Vedi anche