API Rename Deprecation::withNoReplacement (#11390)

This commit is contained in:
Guy Sartorelli 2024-09-19 11:27:08 +12:00 committed by GitHub
parent c7ba8d19c5
commit 6287b6ebeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
34 changed files with 89 additions and 79 deletions

View File

@ -16,7 +16,7 @@ class CliBypass implements Bypass
{
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be removed without equivalent functionality to replace it',

View File

@ -71,7 +71,7 @@ class CoreKernel extends BaseKernel
$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::withSuppressedNotice(fn() => $this->redirectToInstaller($msg));
}
}

View File

@ -96,7 +96,7 @@ abstract class BuildTask
*/
public function getDescription()
{
Deprecation::withNoReplacement(
Deprecation::withSuppressedNotice(
fn() => Deprecation::notice('5.4.0', 'Will be replaced with a static method with the same name')
);
return $this->description;

View File

@ -53,7 +53,7 @@ class Deprecation
/**
* @internal
*/
private static bool $insideWithNoReplacement = false;
private static bool $insideNoticeSuppression = false;
/**
* @internal
@ -103,22 +103,32 @@ class Deprecation
}
/**
* 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 withSuppressedNotice() instead
*/
public static function withNoReplacement(callable $func)
{
if (Deprecation::$insideWithNoReplacement) {
Deprecation::notice('5.4.0', 'Use withSuppressedNotice() instead');
return Deprecation::withSuppressedNotice($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 withSuppressedNotice(callable $func): mixed
{
if (Deprecation::$insideNoticeSuppression) {
return $func();
}
Deprecation::$insideWithNoReplacement = true;
Deprecation::$insideNoticeSuppression = true;
try {
return $func();
} finally {
Deprecation::$insideWithNoReplacement = false;
Deprecation::$insideNoticeSuppression = false;
}
}
@ -137,8 +147,8 @@ class Deprecation
$level = 1;
}
$newLevel = $level;
// handle closures inside withNoReplacement()
if (Deprecation::$insideWithNoReplacement
// handle closures inside withSuppressedNotice()
if (Deprecation::$insideNoticeSuppression
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
) {
$newLevel = $newLevel + 2;
@ -247,8 +257,8 @@ class Deprecation
$count++;
$arr = array_shift(Deprecation::$userErrorMessageBuffer);
$message = $arr['message'];
$calledInsideWithNoReplacement = $arr['calledInsideWithNoReplacement'];
if ($calledInsideWithNoReplacement && !Deprecation::$showNoReplacementNotices) {
$calledWithNoticeSuppression = $arr['calledWithNoticeSuppression'];
if ($calledWithNoticeSuppression && !Deprecation::$showNoReplacementNotices) {
continue;
}
Deprecation::$isTriggeringError = true;
@ -284,7 +294,7 @@ class Deprecation
$data = [
'key' => sha1($string),
'message' => $string,
'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement
'calledWithNoticeSuppression' => Deprecation::$insideNoticeSuppression
];
} else {
if (!Deprecation::isEnabled()) {
@ -310,7 +320,7 @@ class Deprecation
$string .= ".";
}
$level = Deprecation::$insideWithNoReplacement ? 4 : 2;
$level = Deprecation::$insideNoticeSuppression ? 4 : 2;
$string .= " Called from " . Deprecation::get_called_method_from_trace($backtrace, $level) . '.';
if ($caller) {
@ -319,7 +329,7 @@ class Deprecation
$data = [
'key' => sha1($string),
'message' => $string,
'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement
'calledWithNoticeSuppression' => Deprecation::$insideNoticeSuppression
];
}
if ($data && !array_key_exists($data['key'], Deprecation::$userErrorMessageBuffer)) {

View File

@ -34,7 +34,7 @@ class DevBuildController extends Controller implements PermissionProvider
public function __construct()
{
parent::__construct();
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\DbBuild',

View File

@ -47,7 +47,7 @@ class DevConfigController extends Controller implements PermissionProvider
public function __construct()
{
parent::__construct();
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\ConfigDump',

View File

@ -233,7 +233,7 @@ class DevelopmentAdmin extends Controller implements PermissionProvider
*/
public function buildDefaults()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\DbDefaults'
@ -266,7 +266,7 @@ class DevelopmentAdmin extends Controller implements PermissionProvider
*/
public function generatesecuretoken()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\GenerateSecureToken'

View File

@ -21,7 +21,7 @@ class SSListExporter extends Exporter implements TestOnly
{
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be removed without equivalent functionality to replace it',

View File

@ -36,7 +36,7 @@ class CleanupTestDatabasesTask extends BuildTask
public function canView(): bool
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with canRunInBrowser()'

View File

@ -25,7 +25,7 @@ class GridFieldConfig_Base extends GridFieldConfig
$this->addComponent(GridFieldPageCount::create('toolbar-header-right'));
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);

View File

@ -32,7 +32,7 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
$this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd));
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);

View File

@ -45,7 +45,7 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
$this->addComponent(GridFieldDetailForm::create());
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
$sort->setThrowExceptionOnBadDataType(false);
$filter->setThrowExceptionOnBadDataType(false);
$pagination->setThrowExceptionOnBadDataType(false);

View File

@ -37,7 +37,7 @@ class HTTPOutputHandler extends AbstractProcessingHandler
public function __construct()
{
parent::__construct();
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be renamed to ErrorOutputHandler',

View File

@ -14,7 +14,7 @@ class ArrayLib
{
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib', Deprecation::SCOPE_CLASS);
});
}
@ -58,7 +58,7 @@ class ArrayLib
*/
public static function invert($arr)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invert()');
});
@ -86,7 +86,7 @@ class ArrayLib
*/
public static function valuekey($arr)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::valuekey()');
});
@ -102,7 +102,7 @@ class ArrayLib
*/
public static function array_values_recursive($array)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invearray_values_recursivert()');
});
@ -121,7 +121,7 @@ class ArrayLib
*/
public static function filter_keys($arr, $keys)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()');
});
@ -147,7 +147,7 @@ class ArrayLib
*/
public static function is_associative($array)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::is_associative()');
});
@ -173,7 +173,7 @@ class ArrayLib
*/
public static function in_array_recursive($needle, $haystack, $strict = false)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()');
});
@ -206,7 +206,7 @@ class ArrayLib
*/
public static function array_map_recursive($f, $array)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()');
});
@ -232,7 +232,7 @@ class ArrayLib
*/
public static function array_merge_recursive($array)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()');
});
@ -282,7 +282,7 @@ class ArrayLib
*/
public static function flatten($array, $preserveKeys = true, &$out = [])
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::flatten()');
});
@ -314,7 +314,7 @@ class ArrayLib
*/
public static function iterateVolatile(array &$list)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()');
});
@ -341,7 +341,7 @@ class ArrayLib
*/
public static function shuffleAssociative(array &$array): void
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()');
});

View File

@ -61,7 +61,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
*/
public function __construct(array $items = [])
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ArrayList', Deprecation::SCOPE_CLASS);
});
@ -731,7 +731,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
// 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::withSuppressedNotice(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())) {

View File

@ -22,10 +22,10 @@ abstract class DataExtension extends Extension
{
public function __construct()
{
// Wrapping with Deprecation::withNoReplacement() to avoid triggering deprecation notices
// Wrapping with Deprecation::withSuppressedNotice() 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::withSuppressedNotice(function () {
$class = Extension::class;
Deprecation::notice('5.3.0', "Subclass $class instead", Deprecation::SCOPE_CLASS);
});

View File

@ -1986,7 +1986,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
if ($details['polymorphic']) {
$result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class);
if ($details['needsRelation']) {
Deprecation::withNoReplacement(fn () => $result->setForeignRelation($componentName));
Deprecation::withSuppressedNotice(fn () => $result->setForeignRelation($componentName));
}
} else {
$result = HasManyList::create($componentClass, $details['joinField']);

View File

@ -67,7 +67,7 @@ class DatabaseAdmin extends Controller
public function __construct()
{
parent::__construct();
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\DbBuild',
@ -213,7 +213,7 @@ class DatabaseAdmin extends Controller
*/
public static function lastBuilt()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'5.4.0',
'Will be replaced with SilverStripe\Dev\Command\DbBuild::lastBuilt()'

View File

@ -19,7 +19,7 @@ class GroupedList extends ListDecorator
public function __construct(SS_List&Sortable&Filterable&Limitable $list)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\GroupedList', Deprecation::SCOPE_CLASS);
});
parent::__construct($list);

View File

@ -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::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ListDecorator', Deprecation::SCOPE_CLASS);
});

View File

@ -42,7 +42,7 @@ class Map implements ArrayAccess, Countable, IteratorAggregate
*/
public function __construct(SS_List $list, $keyField = "ID", $valueField = "Title")
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\Map', Deprecation::SCOPE_CLASS);
});

View File

@ -41,7 +41,7 @@ class PaginatedList extends ListDecorator
*/
public function __construct(SS_List $list, $request = [])
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\PaginatedList', Deprecation::SCOPE_CLASS);
});

View File

@ -34,7 +34,7 @@ class ValidationException extends Exception
*/
public function __construct($result = null, $code = 0)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationException', Deprecation::SCOPE_CLASS);
});

View File

@ -66,7 +66,7 @@ class ValidationResult
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationResult', Deprecation::SCOPE_CLASS);
});
}

View File

@ -176,7 +176,7 @@ class CookieAuthenticationHandler implements AuthenticationHandler
}
// Renew the token
Deprecation::withNoReplacement(fn() => $rememberLoginHash->renew());
Deprecation::withSuppressedNotice(fn() => $rememberLoginHash->renew());
// Send the new token to the client if it was changed
if ($rememberLoginHash->getToken()) {

View File

@ -34,7 +34,7 @@ class ArrayData extends ViewableData
*/
public function __construct($value = [])
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ArrayData', Deprecation::SCOPE_CLASS);
});

View File

@ -99,7 +99,7 @@ class ViewableData implements IteratorAggregate
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelData', Deprecation::SCOPE_CLASS);
});
}

View File

@ -23,7 +23,7 @@ class ViewableData_Customised extends ViewableData
*/
public function __construct(ViewableData $originalObject, ViewableData $customisedObject)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataCustomised', Deprecation::SCOPE_CLASS);
});

View File

@ -22,7 +22,7 @@ class ViewableData_Debugger extends ViewableData
*/
public function __construct(ViewableData $object)
{
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataDebugger', Deprecation::SCOPE_CLASS);
});
$this->object = $object;

View File

@ -22,7 +22,7 @@ class IPUtilsTest extends SapphireTest
*/
public function testIPv4($matches, $remoteAddr, $cidr)
{
Deprecation::withNoReplacement(function () use ($matches, $remoteAddr, $cidr) {
Deprecation::withSuppressedNotice(function () use ($matches, $remoteAddr, $cidr) {
$this->assertSame($matches, IPUtils::checkIP($remoteAddr, $cidr));
});
}
@ -54,7 +54,7 @@ class IPUtilsTest extends SapphireTest
$this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".');
}
Deprecation::withNoReplacement(function () use ($matches, $remoteAddr, $cidr) {
Deprecation::withSuppressedNotice(function () use ($matches, $remoteAddr, $cidr) {
$this->assertSame($matches, IPUtils::checkIP($remoteAddr, $cidr));
});
}
@ -85,7 +85,7 @@ class IPUtilsTest extends SapphireTest
$this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".');
}
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
IPUtils::checkIP('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65');
});
}

View File

@ -113,72 +113,72 @@ class DeprecationTest extends SapphireTest
Deprecation::outputNotices();
}
public function testWithNoReplacementDefault()
public function testwithSuppressedNoticeDefault()
{
Deprecation::enable();
$ret = Deprecation::withNoReplacement(function () {
$ret = Deprecation::withSuppressedNotice(function () {
return $this->myDeprecatedMethod();
});
$this->assertSame('abc', $ret);
Deprecation::outputNotices();
}
public function testWithNoReplacementTrue()
public function testwithSuppressedNoticeTrue()
{
$message = implode(' ', [
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
'My message.',
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrue.'
'Called from SilverStripe\Dev\Tests\DeprecationTest->testwithSuppressedNoticeTrue.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);
Deprecation::enable(true);
$ret = Deprecation::withNoReplacement(function () {
$ret = Deprecation::withSuppressedNotice(function () {
return $this->myDeprecatedMethod();
});
$this->assertSame('abc', $ret);
Deprecation::outputNotices();
}
public function testWithNoReplacementTrueCallUserFunc()
public function testwithSuppressedNoticeTrueCallUserFunc()
{
$message = implode(' ', [
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
'My message.',
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrueCallUserFunc.'
'Called from SilverStripe\Dev\Tests\DeprecationTest->testwithSuppressedNoticeTrueCallUserFunc.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);
Deprecation::enable(true);
$ret = Deprecation::withNoReplacement(function () {
$ret = Deprecation::withSuppressedNotice(function () {
return call_user_func([$this, 'myDeprecatedMethod']);
});
$this->assertSame('abc', $ret);
Deprecation::outputNotices();
}
public function testNoticeWithNoReplacementTrue()
public function testNoticewithSuppressedNoticeTrue()
{
$message = implode(' ', [
'SilverStripe\Dev\Tests\DeprecationTest->testNoticeWithNoReplacementTrue is deprecated.',
'SilverStripe\Dev\Tests\DeprecationTest->testNoticewithSuppressedNoticeTrue is deprecated.',
'My message.',
'Called from PHPUnit\Framework\TestCase->runTest.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);
Deprecation::enable(true);
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice('123', 'My message.');
});
Deprecation::outputNotices();
}
public function testClassWithNoReplacement()
public function testClasswithSuppressedNotice()
{
$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->testClasswithSuppressedNotice.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);
@ -190,12 +190,12 @@ class DeprecationTest extends SapphireTest
Deprecation::outputNotices();
}
public function testClassWithInjectorWithNoReplacement()
public function testClassWithInjectorwithSuppressedNotice()
{
$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->testClassWithInjectorwithSuppressedNotice.'
]);
$this->expectDeprecation();
$this->expectDeprecationMessage($message);

View File

@ -11,7 +11,7 @@ class DeprecationTestObject extends DataObject implements TestOnly
public function __construct()
{
parent::__construct();
Deprecation::withNoReplacement(function () {
Deprecation::withSuppressedNotice(function () {
Deprecation::notice(
'1.2.3',
'Some class message',

View File

@ -156,7 +156,7 @@ class PasswordEncryptorTest extends SapphireTest
'encryptors',
['test_sha1legacy' => [PasswordEncryptor_LegacyPHPHash::class => 'sha1']]
);
$e = Deprecation::withNoReplacement(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy'));
$e = Deprecation::withSuppressedNotice(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy'));
// precomputed hashes for 'mypassword' from different architectures
$amdHash = 'h1fj0a6m4o6k0sosks88oo08ko4gc4s';
$intelHash = 'h1fj0a6m4o0g04ocg00o4kwoc4wowws';

View File

@ -110,7 +110,7 @@ class RememberLoginHashTest extends SapphireTest
$member = $this->objFromFixture(Member::class, 'main');
Deprecation::withNoReplacement(
Deprecation::withSuppressedNotice(
fn() => RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken)
);
@ -121,7 +121,7 @@ class RememberLoginHashTest extends SapphireTest
// 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::withSuppressedNotice(fn() => $storedHash->renew());
if ($replaceToken) {
$this->assertNotEquals($oldToken, $storedHash->getToken());