public function convertPhpToClassicFormat()

in agent/php/ElasticApm/Impl/Util/StackTraceUtil.php [191:227]


    public function convertPhpToClassicFormat(
        ?array $prevPhpFormatFrame,
        iterable $phpFormatFrames,
        ?int $maxNumberOfFrames,
        bool $keepElasticApmFrames,
        bool $includeArgs,
        bool $includeThisObj
    ): array {
        $allClassicFormatFrames = [];
        $prevInFrame = $prevPhpFormatFrame;
        foreach ($phpFormatFrames as $currentInFrame) {
            $outFrame = new ClassicFormatStackTraceFrame();
            $isOutFrameEmpty = true;
            if ($prevInFrame !== null && $this->hasLocationPropertiesInPhpFormat($prevInFrame)) {
                $this->copyLocationPropertiesFromPhpToClassicFormat($prevInFrame, $outFrame);
                $isOutFrameEmpty = false;
            }
            if ($this->hasNonLocationPropertiesInPhpFormat($currentInFrame)) {
                $this->copyNonLocationPropertiesFromPhpToClassicFormat($currentInFrame, $includeArgs, $includeThisObj, $outFrame);
                $isOutFrameEmpty = false;
            }
            if (!$isOutFrameEmpty) {
                $allClassicFormatFrames[] = $outFrame;
            }
            $prevInFrame = $currentInFrame;
        }

        if ($prevInFrame !== null && $this->hasLocationPropertiesInPhpFormat($prevInFrame)) {
            $outFrame = new ClassicFormatStackTraceFrame();
            $this->copyLocationPropertiesFromPhpToClassicFormat($prevInFrame, $outFrame);
            $allClassicFormatFrames[] = $outFrame;
        }

        return $keepElasticApmFrames
            ? ($maxNumberOfFrames === null ? $allClassicFormatFrames : array_slice($allClassicFormatFrames, /* offset */ 0, $maxNumberOfFrames))
            : $this->excludeCodeToHide($allClassicFormatFrames, $maxNumberOfFrames);
    }