Skip to content

Unexpected? change in debug_backtrace for closures #16729

Closed as not planned
Closed as not planned

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

  1. bwoebi commented on Nov 8, 2024

    @bwoebi
    Member

    Yes, Closures got renamed to provide more information about their identity. That's intentional.

  2. bwoebi commented on Nov 8, 2024

    @bwoebi
    Member

    See: #13550.

  3. alexander-schranz commented on Nov 8, 2024

    @alexander-schranz
    Author

    @bwoebi thx for the quick response.

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