Future::getCreatedFileAndLine
(PHP 8.6+, True Async 1.0)
public function getCreatedFileAndLine(): array
Future 생성 위치에 대한 정보를 배열로 반환합니다. 이 Future가 생성된 파일 이름과 줄 번호를 포함합니다. 디버깅 및 추적에 유용합니다.
반환값
array — file(문자열, 파일 경로)와 line(정수, 줄 번호) 키를 가진 배열.
예제
예제 #1 생성 위치 가져오기
<?php
use Async\Future;
$future = Future::completed(42); // line 5
$location = $future->getCreatedFileAndLine();
echo "File: " . $location['file'] . "\n";
echo "Line: " . $location['line'] . "\n";
// File: /app/script.php
// Line: 5
예제 #2 Future 정보 로깅
<?php
use Async\Future;
use Async\FutureState;
function createTrackedFuture(): Future {
$state = new FutureState();
$future = new Future($state);
$info = $future->getCreatedFileAndLine();
error_log(sprintf(
"Future created at %s:%d",
$info['file'],
$info['line']
));
return $future;
}
같이 보기
- Future::getCreatedLocation — 문자열로 된 생성 위치
- Future::getCompletedFileAndLine — Future 완료 위치
- Future::getAwaitingInfo — 대기자 정보