Skip to content

Improve handling of prefix stripping for anonymous frames#1820

Merged
stayallive merged 3 commits intomasterfrom
prefix-improvements
Apr 10, 2025
Merged

Improve handling of prefix stripping for anonymous frames#1820
stayallive merged 3 commits intomasterfrom
prefix-improvements

Conversation

@stayallive
Copy link
Copy Markdown
Collaborator

Improve handling of prefix stripping for anonymous frames. As reported in #1817 we did not handle the case where the class name is known opposed to being "class". Added a test and ensure we handle that case now. Also added a (micro) optimization to never even run the code if there is no benefit (no prefixes defined).

Fixes #1817

@stayallive stayallive requested a review from cleptric April 8, 2025 09:36
@stayallive stayallive self-assigned this Apr 8, 2025
@stayallive stayallive force-pushed the prefix-improvements branch from 06b1231 to 6b6437e Compare April 8, 2025 09:39
Comment thread src/FrameBuilder.php

if (mb_substr($functionName, 0, mb_strlen(Frame::ANONYMOUS_CLASS_PREFIX)) === Frame::ANONYMOUS_CLASS_PREFIX) {
$functionName = Frame::ANONYMOUS_CLASS_PREFIX . $this->stripPrefixFromFilePath($this->options, substr($backtraceFrame['class'], \strlen(Frame::ANONYMOUS_CLASS_PREFIX)));
// Optimization: skip doing regex if we don't have prefixes to strip
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Optimization: skip doing regex if we don't have prefixes to strip
// Skip if no prefixes are set

@stayallive stayallive merged commit 6341d84 into master Apr 10, 2025
37 checks passed
@stayallive stayallive deleted the prefix-improvements branch April 10, 2025 09:23
stayallive added a commit that referenced this pull request Apr 10, 2025
@stayallive stayallive mentioned this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouping by Stacktrace with anonymous classes/functions

2 participants