diff --git a/src/Core/CustomMethods.php b/src/Core/CustomMethods.php index 97f84f07d64..619f551cba0 100644 --- a/src/Core/CustomMethods.php +++ b/src/Core/CustomMethods.php @@ -171,11 +171,14 @@ protected function getExtraMethodConfig($method) } // Lazy define methods $lowerClass = strtolower(static::class); - if (!isset(self::class::$extra_methods[$lowerClass])) { + $lowerMethod = strtolower($method); + if (!array_key_exists($lowerClass, self::class::$extra_methods) + || !array_key_exists($lowerMethod, self::class::$extra_methods[$lowerClass]) + ) { $this->defineMethods(); } - return self::class::$extra_methods[$lowerClass][strtolower($method)] ?? null; + return self::class::$extra_methods[$lowerClass][$lowerMethod] ?? null; } /** diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index 03f0154fd48..a6c1e10162a 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -111,7 +111,7 @@ public function testNoticeNoReplacement() 'Will be removed without equivalent functionality to replace it.', 'Called from SilverStripe\Dev\Tests\DeprecationTest->testNoticeNoReplacement.' ]); - $this->expectDeprecation(); + $this->expectException(DeprecationTestException::class); $this->expectDeprecationMessage($message); $this->enableDeprecationNotices(true); $ret = $this->myDeprecatedMethodNoReplacement();