Skip to content

Unexpected? change in debug_backtrace for closures #16729

Closed as not planned
Closed as not planned
@alexander-schranz

Description

@alexander-schranz

Description

The following code:

$callers = \debug_backtrace();

// build cache key
$id = \sprintf('%s::%s', $callers[1]['class'], $callers[1]['function']);

var_dump($callers[1]['class']);
var_dump($callers[1]['function']);
exit;

Can also be reproduced with:

git clone [email protected]:sulu/sulu.git sulu
cd sulu
composer update --ignore-platform-reqs
[email protected] vendor/bin/phpunit --filter="MemoizeTest::testMemoizeFirstCall"

And check: https://github.com/sulu/sulu/blob/7e9300b77f289250928ceb73e93a791d9c146bd4/src/Sulu/Component/Cache/Memoize.php#L45

Resulted in this output (PHP 8.4):

string(43) "Sulu\Component\Cache\Tests\Unit\MemoizeTest"
string(80) "{closure:Sulu\Component\Cache\Tests\Unit\MemoizeTest::testMemoizeFirstCall():53}"

But I expected this output instead (PHP 8.3):

string(43) "Sulu\Component\Cache\Tests\Unit\MemoizeTest"
string(41) "Sulu\Component\Cache\Tests\Unit\{closure}"

Is this change expected when upgrading from PHP 8.3 to 8.4? I'm fine with the change but wanted to report its an unexpected change.

PHP Version

8.4.0-dev

Operating System

macOs Montery

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions