in agent/php/ElasticApm/Impl/Util/StackTraceUtil.php [521:560]
public static function convertClassicToApmFormat(iterable $inputFrames, ?int $maxNumberOfFrames): array
{
$outputFrames = [];
/** @var ?ClassicFormatStackTraceFrame $prevInputFrame */
$prevInputFrame = null;
$exitedEarly = false;
foreach ($inputFrames as $currentInputFrame) {
if ($prevInputFrame === null) {
if (self::hasLocationPropertiesInClassicFormat($currentInputFrame)) {
$outputFrame = new StackTraceFrame($currentInputFrame->file ?? self::FILE_NAME_NOT_AVAILABLE_SUBSTITUTE, $currentInputFrame->line ?? self::LINE_NUMBER_NOT_AVAILABLE_SUBSTITUTE);
if (!self::addToOutputFrames($outputFrame, $maxNumberOfFrames, /* ref */ $outputFrames)) {
$exitedEarly = true;
break;
}
}
$prevInputFrame = $currentInputFrame;
continue;
}
$outputFrame = new StackTraceFrame($currentInputFrame->file ?? self::FILE_NAME_NOT_AVAILABLE_SUBSTITUTE, $currentInputFrame->line ?? self::LINE_NUMBER_NOT_AVAILABLE_SUBSTITUTE);
$outputFrame->function = StackTraceUtil::buildApmFormatFunctionForClassMethod($prevInputFrame->class, $prevInputFrame->isStaticMethod, $prevInputFrame->function);
if (!self::addToOutputFrames($outputFrame, $maxNumberOfFrames, /* ref */ $outputFrames)) {
$exitedEarly = true;
break;
}
$prevInputFrame = $currentInputFrame;
}
if (!$exitedEarly && $prevInputFrame !== null && $prevInputFrame->function !== null) {
$outputFrame = new StackTraceFrame(
self::FILE_NAME_NOT_AVAILABLE_SUBSTITUTE,
self::LINE_NUMBER_NOT_AVAILABLE_SUBSTITUTE,
StackTraceUtil::buildApmFormatFunctionForClassMethod($prevInputFrame->class, $prevInputFrame->isStaticMethod, $prevInputFrame->function)
);
self::addToOutputFrames($outputFrame, $maxNumberOfFrames, /* ref */ $outputFrames);
}
return $outputFrames;
}