Skip to content

Commit

Permalink
FIX Correctly identify deprecated API in withNoReplacement
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Feb 27, 2023
1 parent ab566b0 commit 7ae14fc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Dev/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ protected static function get_called_method_from_trace($backtrace, $level = 1)
$level = 1;
}
$newLevel = $level;
// handle closures inside withNoReplacement()
if (self::$insideWithNoReplacement
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
) {
$newLevel = $newLevel + 2;
}
// handle call_user_func
if ($level === 4 && strpos($backtrace[2]['function'] ?? '', 'call_user_func') !== false) {
$newLevel = 5;
Expand Down Expand Up @@ -277,10 +283,10 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC
// Do not add to self::$userErrorMessageBuffer, as the backtrace is too expensive
return;
}

// Getting a backtrace is slow, so we only do it if we need it
$backtrace = null;

// Get the calling scope
if ($scope == Deprecation::SCOPE_METHOD) {
$backtrace = debug_backtrace(0);
Expand All @@ -291,7 +297,7 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC
} else {
$caller = false;
}

if (substr($string, -1) != '.') {
$string .= ".";
}
Expand Down

0 comments on commit 7ae14fc

Please sign in to comment.