Skip to content

Commit

Permalink
FIX Handle PHP 8.4 closure string
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Dec 3, 2024
1 parent c56f8fc commit 62dfe19
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Dev/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ private static function get_called_from_trace(array $backtrace, int $level): arr
{
$newLevel = $level;
// handle closures inside withSuppressedNotice()
if (Deprecation::$insideNoticeSuppression
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
) {
$newLevel = $newLevel + 2;
if (Deprecation::$insideNoticeSuppression) {
$func = $backtrace[$newLevel]['function'];
// different versions of php have different formats for closures
// php <=8.3 example "SilverStripe\Dev\{closure}"
// php >=8.4 example "{closure:SilverStripe\Dev\Deprecation::noticeWithNoReplacment():464}"
if (str_ends_with($func, '{closure}') || str_starts_with($func, '{closure:')) {
$newLevel = $newLevel + 2;
}
}
// handle call_user_func
if ($level === 4 && strpos($backtrace[2]['function'] ?? '', 'call_user_func') !== false) {
Expand Down

0 comments on commit 62dfe19

Please sign in to comment.