Skip to content

Unexpected? change in debug_backtrace for closures #16729

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 git@github.com:sulu/sulu.git sulu
cd sulu
composer update --ignore-platform-reqs
php@8.4 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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