From f4d5b7b068b2178967b3f610b284fe1c6bd87a4d Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 18 Sep 2024 10:38:50 +1200 Subject: [PATCH] API Rename Deprecation::withNoReplacement to Deprecation::withSuppressedWarning --- .../ConfirmationMiddleware/CliBypass.php | 2 +- src/Core/CoreKernel.php | 2 +- src/Dev/BuildTask.php | 2 +- src/Dev/Deprecation.php | 38 ++++++++++++------- src/Dev/DevBuildController.php | 2 +- src/Dev/DevConfigController.php | 2 +- src/Dev/DevelopmentAdmin.php | 4 +- src/Dev/SSListExporter.php | 2 +- src/Dev/Tasks/CleanupTestDatabasesTask.php | 2 +- src/Forms/GridField/GridFieldConfig_Base.php | 2 +- .../GridFieldConfig_RecordEditor.php | 2 +- .../GridFieldConfig_RelationEditor.php | 2 +- src/Logging/HTTPOutputHandler.php | 2 +- src/ORM/ArrayLib.php | 24 ++++++------ src/ORM/ArrayList.php | 4 +- src/ORM/DataExtension.php | 4 +- src/ORM/DataObject.php | 2 +- src/ORM/DatabaseAdmin.php | 4 +- src/ORM/GroupedList.php | 2 +- src/ORM/ListDecorator.php | 2 +- src/ORM/Map.php | 2 +- src/ORM/PaginatedList.php | 2 +- src/ORM/ValidationException.php | 2 +- src/ORM/ValidationResult.php | 2 +- .../CookieAuthenticationHandler.php | 2 +- src/View/ArrayData.php | 2 +- src/View/ViewableData.php | 2 +- src/View/ViewableData_Customised.php | 2 +- src/View/ViewableData_Debugger.php | 2 +- tests/php/Control/IPUtilsTest.php | 6 +-- tests/php/Dev/DeprecationTest.php | 30 +++++++-------- .../DeprecationTest/DeprecationTestObject.php | 2 +- tests/php/Security/PasswordEncryptorTest.php | 2 +- tests/php/Security/RememberLoginHashTest.php | 4 +- 34 files changed, 89 insertions(+), 79 deletions(-) diff --git a/src/Control/Middleware/ConfirmationMiddleware/CliBypass.php b/src/Control/Middleware/ConfirmationMiddleware/CliBypass.php index 1a16be0c695..ea91e59a075 100644 --- a/src/Control/Middleware/ConfirmationMiddleware/CliBypass.php +++ b/src/Control/Middleware/ConfirmationMiddleware/CliBypass.php @@ -16,7 +16,7 @@ class CliBypass implements Bypass { public function __construct() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be removed without equivalent functionality to replace it', diff --git a/src/Core/CoreKernel.php b/src/Core/CoreKernel.php index acf43ddfcf0..40ac2c44a05 100644 --- a/src/Core/CoreKernel.php +++ b/src/Core/CoreKernel.php @@ -71,7 +71,7 @@ protected function validateDatabase() $msg = 'Silverstripe Framework requires a "database" key in DB::getConfig(). ' . 'Did you forget to set SS_DATABASE_NAME or SS_DATABASE_CHOOSE_NAME in your environment?'; $this->detectLegacyEnvironment(); - Deprecation::withNoReplacement(fn() => $this->redirectToInstaller($msg)); + Deprecation::withSuppressedWarning(fn() => $this->redirectToInstaller($msg)); } } diff --git a/src/Dev/BuildTask.php b/src/Dev/BuildTask.php index 5497cc3f0f0..461168cc4cd 100644 --- a/src/Dev/BuildTask.php +++ b/src/Dev/BuildTask.php @@ -96,7 +96,7 @@ public function getTitle() */ public function getDescription() { - Deprecation::withNoReplacement( + Deprecation::withSuppressedWarning( fn() => Deprecation::notice('5.4.0', 'Will be replaced with a static method with the same name') ); return $this->description; diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index 9c7d4f5dab1..d8f47845015 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -53,7 +53,7 @@ class Deprecation /** * @internal */ - private static bool $insideWithNoReplacement = false; + private static bool $insideWarningSuppression = false; /** * @internal @@ -103,22 +103,32 @@ public static function disable(): void } /** - * Used to wrap deprecated methods and deprecated config get()/set() that will be removed - * in the next major version with no replacement. This is done to surpress deprecation notices - * by for calls from the vendor dir to deprecated code that projects have no ability to change + * Used to wrap deprecated methods and deprecated config get()/set() called from the vendor + * dir that projects have no ability to change. * * @return mixed + * @deprecated 5.4.0 Use withSuppressedWarning() instead */ public static function withNoReplacement(callable $func) { - if (Deprecation::$insideWithNoReplacement) { + Deprecation::notice('5.4.0', 'Use withSuppressedWarning() instead'); + return Deprecation::withSuppressedWarning($func); + } + + /** + * Used to wrap deprecated methods and deprecated config get()/set() called from the vendor + * dir that projects have no ability to change. + */ + public static function withSuppressedWarning(callable $func): mixed + { + if (Deprecation::$insideWarningSuppression) { return $func(); } - Deprecation::$insideWithNoReplacement = true; + Deprecation::$insideWarningSuppression = true; try { return $func(); } finally { - Deprecation::$insideWithNoReplacement = false; + Deprecation::$insideWarningSuppression = false; } } @@ -137,8 +147,8 @@ protected static function get_called_method_from_trace($backtrace, $level = 1) $level = 1; } $newLevel = $level; - // handle closures inside withNoReplacement() - if (Deprecation::$insideWithNoReplacement + // handle closures inside withSuppressedWarning() + if (Deprecation::$insideWarningSuppression && substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}' ) { $newLevel = $newLevel + 2; @@ -247,8 +257,8 @@ public static function outputNotices(): void $count++; $arr = array_shift(Deprecation::$userErrorMessageBuffer); $message = $arr['message']; - $calledInsideWithNoReplacement = $arr['calledInsideWithNoReplacement']; - if ($calledInsideWithNoReplacement && !Deprecation::$showNoReplacementNotices) { + $calledWithWarningSuppression = $arr['calledWithWarningSuppression']; + if ($calledWithWarningSuppression && !Deprecation::$showNoReplacementNotices) { continue; } Deprecation::$isTriggeringError = true; @@ -284,7 +294,7 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC $data = [ 'key' => sha1($string), 'message' => $string, - 'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement + 'calledWithWarningSuppression' => Deprecation::$insideWarningSuppression ]; } else { if (!Deprecation::isEnabled()) { @@ -310,7 +320,7 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC $string .= "."; } - $level = Deprecation::$insideWithNoReplacement ? 4 : 2; + $level = Deprecation::$insideWarningSuppression ? 4 : 2; $string .= " Called from " . Deprecation::get_called_method_from_trace($backtrace, $level) . '.'; if ($caller) { @@ -319,7 +329,7 @@ public static function notice($atVersion, $string = '', $scope = Deprecation::SC $data = [ 'key' => sha1($string), 'message' => $string, - 'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement + 'calledWithWarningSuppression' => Deprecation::$insideWarningSuppression ]; } if ($data && !array_key_exists($data['key'], Deprecation::$userErrorMessageBuffer)) { diff --git a/src/Dev/DevBuildController.php b/src/Dev/DevBuildController.php index 1559296865a..523ecf4c4c3 100644 --- a/src/Dev/DevBuildController.php +++ b/src/Dev/DevBuildController.php @@ -34,7 +34,7 @@ class DevBuildController extends Controller implements PermissionProvider public function __construct() { parent::__construct(); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\DbBuild', diff --git a/src/Dev/DevConfigController.php b/src/Dev/DevConfigController.php index 056f0ee04fe..643562dddc6 100644 --- a/src/Dev/DevConfigController.php +++ b/src/Dev/DevConfigController.php @@ -47,7 +47,7 @@ class DevConfigController extends Controller implements PermissionProvider public function __construct() { parent::__construct(); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\ConfigDump', diff --git a/src/Dev/DevelopmentAdmin.php b/src/Dev/DevelopmentAdmin.php index ccf279c309e..a6c92b16855 100644 --- a/src/Dev/DevelopmentAdmin.php +++ b/src/Dev/DevelopmentAdmin.php @@ -233,7 +233,7 @@ protected function getRegisteredController($baseUrlPart) */ public function buildDefaults() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\DbDefaults' @@ -266,7 +266,7 @@ public function buildDefaults() */ public function generatesecuretoken() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\GenerateSecureToken' diff --git a/src/Dev/SSListExporter.php b/src/Dev/SSListExporter.php index 3ae352b7800..79bc111c9a7 100644 --- a/src/Dev/SSListExporter.php +++ b/src/Dev/SSListExporter.php @@ -21,7 +21,7 @@ class SSListExporter extends Exporter implements TestOnly { public function __construct() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be removed without equivalent functionality to replace it', diff --git a/src/Dev/Tasks/CleanupTestDatabasesTask.php b/src/Dev/Tasks/CleanupTestDatabasesTask.php index 10c399afbd3..6c4a549331a 100644 --- a/src/Dev/Tasks/CleanupTestDatabasesTask.php +++ b/src/Dev/Tasks/CleanupTestDatabasesTask.php @@ -36,7 +36,7 @@ public function run($request) public function canView(): bool { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with canRunInBrowser()' diff --git a/src/Forms/GridField/GridFieldConfig_Base.php b/src/Forms/GridField/GridFieldConfig_Base.php index 3db245fe872..a4cbe62dc39 100644 --- a/src/Forms/GridField/GridFieldConfig_Base.php +++ b/src/Forms/GridField/GridFieldConfig_Base.php @@ -25,7 +25,7 @@ public function __construct($itemsPerPage = null) $this->addComponent(GridFieldPageCount::create('toolbar-header-right')); $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); - Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) { + Deprecation::withSuppressedWarning(function () use ($sort, $filter, $pagination) { $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); diff --git a/src/Forms/GridField/GridFieldConfig_RecordEditor.php b/src/Forms/GridField/GridFieldConfig_RecordEditor.php index 82a273dc585..96ac752793c 100644 --- a/src/Forms/GridField/GridFieldConfig_RecordEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RecordEditor.php @@ -32,7 +32,7 @@ public function __construct($itemsPerPage = null, $showPagination = null, $showA $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd)); - Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) { + Deprecation::withSuppressedWarning(function () use ($sort, $filter, $pagination) { $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); diff --git a/src/Forms/GridField/GridFieldConfig_RelationEditor.php b/src/Forms/GridField/GridFieldConfig_RelationEditor.php index 20a495ec5e4..b7fb3b0f33b 100644 --- a/src/Forms/GridField/GridFieldConfig_RelationEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RelationEditor.php @@ -45,7 +45,7 @@ public function __construct($itemsPerPage = null) $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create()); - Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) { + Deprecation::withSuppressedWarning(function () use ($sort, $filter, $pagination) { $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); diff --git a/src/Logging/HTTPOutputHandler.php b/src/Logging/HTTPOutputHandler.php index 39df450f131..93f641dc2d5 100644 --- a/src/Logging/HTTPOutputHandler.php +++ b/src/Logging/HTTPOutputHandler.php @@ -37,7 +37,7 @@ class HTTPOutputHandler extends AbstractProcessingHandler public function __construct() { parent::__construct(); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be renamed to ErrorOutputHandler', diff --git a/src/ORM/ArrayLib.php b/src/ORM/ArrayLib.php index de2f610a64f..e9984ea692f 100644 --- a/src/ORM/ArrayLib.php +++ b/src/ORM/ArrayLib.php @@ -14,7 +14,7 @@ class ArrayLib { public function __construct() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib', Deprecation::SCOPE_CLASS); }); } @@ -58,7 +58,7 @@ public function __construct() */ public static function invert($arr) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invert()'); }); @@ -86,7 +86,7 @@ public static function invert($arr) */ public static function valuekey($arr) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::valuekey()'); }); @@ -102,7 +102,7 @@ public static function valuekey($arr) */ public static function array_values_recursive($array) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invearray_values_recursivert()'); }); @@ -121,7 +121,7 @@ public static function array_values_recursive($array) */ public static function filter_keys($arr, $keys) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()'); }); @@ -147,7 +147,7 @@ public static function filter_keys($arr, $keys) */ public static function is_associative($array) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::is_associative()'); }); @@ -173,7 +173,7 @@ public static function is_associative($array) */ public static function in_array_recursive($needle, $haystack, $strict = false) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()'); }); @@ -206,7 +206,7 @@ public static function in_array_recursive($needle, $haystack, $strict = false) */ public static function array_map_recursive($f, $array) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()'); }); @@ -232,7 +232,7 @@ public static function array_map_recursive($f, $array) */ public static function array_merge_recursive($array) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()'); }); @@ -282,7 +282,7 @@ public static function array_merge_recursive($array) */ public static function flatten($array, $preserveKeys = true, &$out = []) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::flatten()'); }); @@ -314,7 +314,7 @@ function ($value, $key) use (&$out, $preserveKeys) { */ public static function iterateVolatile(array &$list) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()'); }); @@ -341,7 +341,7 @@ public static function iterateVolatile(array &$list) */ public static function shuffleAssociative(array &$array): void { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()'); }); diff --git a/src/ORM/ArrayList.php b/src/ORM/ArrayList.php index 94920fe3e99..e1c3e4b4d07 100644 --- a/src/ORM/ArrayList.php +++ b/src/ORM/ArrayList.php @@ -61,7 +61,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L */ public function __construct(array $items = []) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ArrayList', Deprecation::SCOPE_CLASS); }); @@ -731,7 +731,7 @@ protected function filterOrExclude(array $filters, bool $inclusive = true, bool // Apply default case sensitivity for backwards compatability if (!str_contains($filterKey, ':case') && !str_contains($filterKey, ':nocase')) { - $caseSensitive = Deprecation::withNoReplacement(fn() => static::config()->get('default_case_sensitive')); + $caseSensitive = Deprecation::withSuppressedWarning(fn() => static::config()->get('default_case_sensitive')); if ($caseSensitive && in_array('case', $searchFilter->getSupportedModifiers())) { $searchFilter->setModifiers($searchFilter->getModifiers() + ['case']); } elseif (!$caseSensitive && in_array('nocase', $searchFilter->getSupportedModifiers())) { diff --git a/src/ORM/DataExtension.php b/src/ORM/DataExtension.php index b41fa120938..1b0963cae67 100644 --- a/src/ORM/DataExtension.php +++ b/src/ORM/DataExtension.php @@ -22,10 +22,10 @@ abstract class DataExtension extends Extension { public function __construct() { - // Wrapping with Deprecation::withNoReplacement() to avoid triggering deprecation notices + // Wrapping with Deprecation::withSuppressedWarning() to avoid triggering deprecation notices // as we are unable to update existing subclasses of this class until a new major // unless we add in the pointless empty methods that are in this class - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { $class = Extension::class; Deprecation::notice('5.3.0', "Subclass $class instead", Deprecation::SCOPE_CLASS); }); diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index c496f631d9f..e4cc8e90535 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -1986,7 +1986,7 @@ public function getComponents($componentName, $id = null) if ($details['polymorphic']) { $result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class); if ($details['needsRelation']) { - Deprecation::withNoReplacement(fn () => $result->setForeignRelation($componentName)); + Deprecation::withSuppressedWarning(fn () => $result->setForeignRelation($componentName)); } } else { $result = HasManyList::create($componentClass, $details['joinField']); diff --git a/src/ORM/DatabaseAdmin.php b/src/ORM/DatabaseAdmin.php index 29f56474a23..9db4b4d310f 100644 --- a/src/ORM/DatabaseAdmin.php +++ b/src/ORM/DatabaseAdmin.php @@ -67,7 +67,7 @@ class DatabaseAdmin extends Controller public function __construct() { parent::__construct(); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\DbBuild', @@ -213,7 +213,7 @@ public function buildDefaults() */ public static function lastBuilt() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '5.4.0', 'Will be replaced with SilverStripe\Dev\Command\DbBuild::lastBuilt()' diff --git a/src/ORM/GroupedList.php b/src/ORM/GroupedList.php index e81d5bbbede..b804eeed7e8 100644 --- a/src/ORM/GroupedList.php +++ b/src/ORM/GroupedList.php @@ -19,7 +19,7 @@ class GroupedList extends ListDecorator public function __construct(SS_List&Sortable&Filterable&Limitable $list) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\GroupedList', Deprecation::SCOPE_CLASS); }); parent::__construct($list); diff --git a/src/ORM/ListDecorator.php b/src/ORM/ListDecorator.php index 94712368afe..48ee5354673 100644 --- a/src/ORM/ListDecorator.php +++ b/src/ORM/ListDecorator.php @@ -32,7 +32,7 @@ abstract class ListDecorator extends ViewableData implements SS_List, Sortable, */ public function __construct(SS_List&Sortable&Filterable&Limitable $list) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ListDecorator', Deprecation::SCOPE_CLASS); }); diff --git a/src/ORM/Map.php b/src/ORM/Map.php index 186cf2246fd..7fab5ffa059 100644 --- a/src/ORM/Map.php +++ b/src/ORM/Map.php @@ -42,7 +42,7 @@ class Map implements ArrayAccess, Countable, IteratorAggregate */ public function __construct(SS_List $list, $keyField = "ID", $valueField = "Title") { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\Map', Deprecation::SCOPE_CLASS); }); diff --git a/src/ORM/PaginatedList.php b/src/ORM/PaginatedList.php index b7d392700f4..abf7bed7fac 100644 --- a/src/ORM/PaginatedList.php +++ b/src/ORM/PaginatedList.php @@ -41,7 +41,7 @@ class PaginatedList extends ListDecorator */ public function __construct(SS_List $list, $request = []) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\PaginatedList', Deprecation::SCOPE_CLASS); }); diff --git a/src/ORM/ValidationException.php b/src/ORM/ValidationException.php index 1ee47db2793..36a56093a3c 100644 --- a/src/ORM/ValidationException.php +++ b/src/ORM/ValidationException.php @@ -34,7 +34,7 @@ class ValidationException extends Exception */ public function __construct($result = null, $code = 0) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationException', Deprecation::SCOPE_CLASS); }); diff --git a/src/ORM/ValidationResult.php b/src/ORM/ValidationResult.php index d57a3b8b24d..8bcb5e0fb42 100644 --- a/src/ORM/ValidationResult.php +++ b/src/ORM/ValidationResult.php @@ -66,7 +66,7 @@ class ValidationResult public function __construct() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationResult', Deprecation::SCOPE_CLASS); }); } diff --git a/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php b/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php index 8373ba77242..475ea3ae400 100644 --- a/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php +++ b/src/Security/MemberAuthenticator/CookieAuthenticationHandler.php @@ -176,7 +176,7 @@ public function authenticateRequest(HTTPRequest $request) } // Renew the token - Deprecation::withNoReplacement(fn() => $rememberLoginHash->renew()); + Deprecation::withSuppressedWarning(fn() => $rememberLoginHash->renew()); // Send the new token to the client if it was changed if ($rememberLoginHash->getToken()) { diff --git a/src/View/ArrayData.php b/src/View/ArrayData.php index 34786a962b1..9363b2cde0d 100644 --- a/src/View/ArrayData.php +++ b/src/View/ArrayData.php @@ -34,7 +34,7 @@ class ArrayData extends ViewableData */ public function __construct($value = []) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ArrayData', Deprecation::SCOPE_CLASS); }); diff --git a/src/View/ViewableData.php b/src/View/ViewableData.php index 37970ba691d..4b93f690f26 100644 --- a/src/View/ViewableData.php +++ b/src/View/ViewableData.php @@ -99,7 +99,7 @@ class ViewableData implements IteratorAggregate public function __construct() { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelData', Deprecation::SCOPE_CLASS); }); } diff --git a/src/View/ViewableData_Customised.php b/src/View/ViewableData_Customised.php index 0988b2957f7..6c1f0c03dc3 100644 --- a/src/View/ViewableData_Customised.php +++ b/src/View/ViewableData_Customised.php @@ -23,7 +23,7 @@ class ViewableData_Customised extends ViewableData */ public function __construct(ViewableData $originalObject, ViewableData $customisedObject) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataCustomised', Deprecation::SCOPE_CLASS); }); diff --git a/src/View/ViewableData_Debugger.php b/src/View/ViewableData_Debugger.php index c2ea7357b6c..312e0aa6acc 100644 --- a/src/View/ViewableData_Debugger.php +++ b/src/View/ViewableData_Debugger.php @@ -22,7 +22,7 @@ class ViewableData_Debugger extends ViewableData */ public function __construct(ViewableData $object) { - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataDebugger', Deprecation::SCOPE_CLASS); }); $this->object = $object; diff --git a/tests/php/Control/IPUtilsTest.php b/tests/php/Control/IPUtilsTest.php index 8b0ddfe4697..8fab8df907f 100644 --- a/tests/php/Control/IPUtilsTest.php +++ b/tests/php/Control/IPUtilsTest.php @@ -22,7 +22,7 @@ class IPUtilsTest extends SapphireTest */ public function testIPv4($matches, $remoteAddr, $cidr) { - Deprecation::withNoReplacement(function () use ($matches, $remoteAddr, $cidr) { + Deprecation::withSuppressedWarning(function () use ($matches, $remoteAddr, $cidr) { $this->assertSame($matches, IPUtils::checkIP($remoteAddr, $cidr)); }); } @@ -54,7 +54,7 @@ public function testIPv6($matches, $remoteAddr, $cidr) $this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".'); } - Deprecation::withNoReplacement(function () use ($matches, $remoteAddr, $cidr) { + Deprecation::withSuppressedWarning(function () use ($matches, $remoteAddr, $cidr) { $this->assertSame($matches, IPUtils::checkIP($remoteAddr, $cidr)); }); } @@ -85,7 +85,7 @@ public function testAnIPv6WithOptionDisabledIPv6() $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".'); } - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { IPUtils::checkIP('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'); }); } diff --git a/tests/php/Dev/DeprecationTest.php b/tests/php/Dev/DeprecationTest.php index 30d6b2018f3..968ee88d0e7 100644 --- a/tests/php/Dev/DeprecationTest.php +++ b/tests/php/Dev/DeprecationTest.php @@ -113,72 +113,72 @@ public function testCallUserFuncArray() Deprecation::outputNotices(); } - public function testWithNoReplacementDefault() + public function testWithSuppressedWarningDefault() { Deprecation::enable(); - $ret = Deprecation::withNoReplacement(function () { + $ret = Deprecation::withSuppressedWarning(function () { return $this->myDeprecatedMethod(); }); $this->assertSame('abc', $ret); Deprecation::outputNotices(); } - public function testWithNoReplacementTrue() + public function testWithSuppressedWarningTrue() { $message = implode(' ', [ 'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.', 'My message.', - 'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrue.' + 'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithSuppressedWarningTrue.' ]); $this->expectDeprecation(); $this->expectDeprecationMessage($message); Deprecation::enable(true); - $ret = Deprecation::withNoReplacement(function () { + $ret = Deprecation::withSuppressedWarning(function () { return $this->myDeprecatedMethod(); }); $this->assertSame('abc', $ret); Deprecation::outputNotices(); } - public function testWithNoReplacementTrueCallUserFunc() + public function testWithSuppressedWarningTrueCallUserFunc() { $message = implode(' ', [ 'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.', 'My message.', - 'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrueCallUserFunc.' + 'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithSuppressedWarningTrueCallUserFunc.' ]); $this->expectDeprecation(); $this->expectDeprecationMessage($message); Deprecation::enable(true); - $ret = Deprecation::withNoReplacement(function () { + $ret = Deprecation::withSuppressedWarning(function () { return call_user_func([$this, 'myDeprecatedMethod']); }); $this->assertSame('abc', $ret); Deprecation::outputNotices(); } - public function testNoticeWithNoReplacementTrue() + public function testNoticeWithSuppressedWarningTrue() { $message = implode(' ', [ - 'SilverStripe\Dev\Tests\DeprecationTest->testNoticeWithNoReplacementTrue is deprecated.', + 'SilverStripe\Dev\Tests\DeprecationTest->testNoticeWithSuppressedWarningTrue is deprecated.', 'My message.', 'Called from PHPUnit\Framework\TestCase->runTest.' ]); $this->expectDeprecation(); $this->expectDeprecationMessage($message); Deprecation::enable(true); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice('123', 'My message.'); }); Deprecation::outputNotices(); } - public function testClassWithNoReplacement() + public function testClassWithSuppressedWarning() { $message = implode(' ', [ 'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.', 'Some class message.', - 'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithNoReplacement.' + 'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithSuppressedWarning.' ]); $this->expectDeprecation(); $this->expectDeprecationMessage($message); @@ -190,12 +190,12 @@ public function testClassWithNoReplacement() Deprecation::outputNotices(); } - public function testClassWithInjectorWithNoReplacement() + public function testClassWithInjectorWithSuppressedWarning() { $message = implode(' ', [ 'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.', 'Some class message.', - 'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithInjectorWithNoReplacement.' + 'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithInjectorWithSuppressedWarning.' ]); $this->expectDeprecation(); $this->expectDeprecationMessage($message); diff --git a/tests/php/Dev/DeprecationTest/DeprecationTestObject.php b/tests/php/Dev/DeprecationTest/DeprecationTestObject.php index 60a725458a1..2fe76610990 100644 --- a/tests/php/Dev/DeprecationTest/DeprecationTestObject.php +++ b/tests/php/Dev/DeprecationTest/DeprecationTestObject.php @@ -11,7 +11,7 @@ class DeprecationTestObject extends DataObject implements TestOnly public function __construct() { parent::__construct(); - Deprecation::withNoReplacement(function () { + Deprecation::withSuppressedWarning(function () { Deprecation::notice( '1.2.3', 'Some class message', diff --git a/tests/php/Security/PasswordEncryptorTest.php b/tests/php/Security/PasswordEncryptorTest.php index 95b91d0f0d0..008f43615e0 100644 --- a/tests/php/Security/PasswordEncryptorTest.php +++ b/tests/php/Security/PasswordEncryptorTest.php @@ -156,7 +156,7 @@ public function testEncryptorLegacyPHPHashCheck() 'encryptors', ['test_sha1legacy' => [PasswordEncryptor_LegacyPHPHash::class => 'sha1']] ); - $e = Deprecation::withNoReplacement(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy')); + $e = Deprecation::withSuppressedWarning(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy')); // precomputed hashes for 'mypassword' from different architectures $amdHash = 'h1fj0a6m4o6k0sosks88oo08ko4gc4s'; $intelHash = 'h1fj0a6m4o0g04ocg00o4kwoc4wowws'; diff --git a/tests/php/Security/RememberLoginHashTest.php b/tests/php/Security/RememberLoginHashTest.php index ced2991af5d..5e42138d885 100644 --- a/tests/php/Security/RememberLoginHashTest.php +++ b/tests/php/Security/RememberLoginHashTest.php @@ -110,7 +110,7 @@ public function testRenew($replaceToken) $member = $this->objFromFixture(Member::class, 'main'); - Deprecation::withNoReplacement( + Deprecation::withSuppressedWarning( fn() => RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken) ); @@ -121,7 +121,7 @@ public function testRenew($replaceToken) // Fetch the token from the DB - otherwise we still have the token from when this was originally created $storedHash = RememberLoginHash::get()->find('ID', $hash->ID); - Deprecation::withNoReplacement(fn() => $storedHash->renew()); + Deprecation::withSuppressedWarning(fn() => $storedHash->renew()); if ($replaceToken) { $this->assertNotEquals($oldToken, $storedHash->getToken());