From ab566b0a156376020dc25e6754c9d07ca12c2d56 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 15 Feb 2023 13:26:36 +1300 Subject: [PATCH] API Add new deprecation notices. (#10691) These are removed in CMS 5. --- src/Core/Manifest/Module.php | 3 +++ src/Dev/CSVParser.php | 3 ++- src/Dev/CsvBulkLoader.php | 10 +++++----- src/Dev/TestSession_STResponseWrapper.php | 8 ++++++++ tests/php/Dev/CSVParserTest.php | 4 ++++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Core/Manifest/Module.php b/src/Core/Manifest/Module.php index 77dd61ed2..7f4ff1580 100644 --- a/src/Core/Manifest/Module.php +++ b/src/Core/Manifest/Module.php @@ -23,16 +23,19 @@ class Module implements Serializable /** * Return value of getCIConfig() when module uses PHPUNit 9 + * @deprecated 4.13.0 Will be removed without equivalent functionality */ const CI_PHPUNIT_NINE = 'CI_PHPUNIT_NINE'; /** * Return value of getCIConfig() when module uses PHPUNit 5 + * @deprecated 4.13.0 Will be removed without equivalent functionality */ const CI_PHPUNIT_FIVE = 'CI_PHPUNIT_FIVE'; /** * Return value of getCIConfig() when module does not use any CI + * @deprecated 4.13.0 Will be removed without equivalent functionality */ const CI_UNKNOWN = 'CI_UNKNOWN'; diff --git a/src/Dev/CSVParser.php b/src/Dev/CSVParser.php index fda09190c..51ffe7f0c 100644 --- a/src/Dev/CSVParser.php +++ b/src/Dev/CSVParser.php @@ -31,6 +31,7 @@ use SilverStripe\Control\Director; * $obj->write(); * } * + * @deprecated 4.13.0 Use League\Csv\Reader instead */ class CSVParser implements Iterator { @@ -115,7 +116,7 @@ class CSVParser implements Iterator */ public function __construct($filename, $delimiter = ",", $enclosure = '"') { - Deprecation::notice('5.0', __CLASS__ . ' is deprecated, use ' . Reader::class . ' instead'); + Deprecation::notice('4.13.0', 'Use ' . Reader::class . ' instead', Deprecation::SCOPE_CLASS); $filename = Director::getAbsFile($filename); $this->filename = $filename; $this->delimiter = $delimiter; diff --git a/src/Dev/CsvBulkLoader.php b/src/Dev/CsvBulkLoader.php index a4384078b..2c82a03bd 100644 --- a/src/Dev/CsvBulkLoader.php +++ b/src/Dev/CsvBulkLoader.php @@ -254,11 +254,11 @@ class CsvBulkLoader extends BulkLoader Deprecation::notice('4.12.0', 'Process rows individually instead'); $results = BulkLoader_Result::create(); - $csv = new CSVParser( - $filepath, - $this->delimiter, - $this->enclosure - ); + $delimiter = $this->delimiter; + $enclosure = $this->enclosure; + $csv = Deprecation::withNoReplacement(function () use ($filepath, $delimiter, $enclosure) { + return new CSVParser($filepath, $delimiter, $enclosure); + }); // ColumnMap has two uses, depending on whether hasHeaderRow is set if ($this->columnMap) { diff --git a/src/Dev/TestSession_STResponseWrapper.php b/src/Dev/TestSession_STResponseWrapper.php index 402080e84..6a3407314 100644 --- a/src/Dev/TestSession_STResponseWrapper.php +++ b/src/Dev/TestSession_STResponseWrapper.php @@ -6,6 +6,7 @@ use SilverStripe\Control\HTTPResponse; /** * Wrapper around HTTPResponse to make it look like a SimpleHTTPResposne + * @deprecated 4.13.0 Will be removed without equivalent functionality to replace it */ class TestSession_STResponseWrapper { @@ -17,6 +18,13 @@ class TestSession_STResponseWrapper public function __construct(HTTPResponse $response) { + Deprecation::withNoReplacement(function () { + Deprecation::notice( + '4.13.0', + 'Will be removed without equivalent functionality to replace it', + Deprecation::SCOPE_CLASS + ); + }); $this->response = $response; } diff --git a/tests/php/Dev/CSVParserTest.php b/tests/php/Dev/CSVParserTest.php index 1ff17fe16..921f9be52 100644 --- a/tests/php/Dev/CSVParserTest.php +++ b/tests/php/Dev/CSVParserTest.php @@ -3,6 +3,7 @@ namespace SilverStripe\Dev\Tests; use SilverStripe\Dev\CSVParser; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; class CSVParserTest extends SapphireTest @@ -19,6 +20,9 @@ class CSVParserTest extends SapphireTest { parent::setUp(); $this->csvPath = __DIR__ . '/CsvBulkLoaderTest/csv/'; + if (Deprecation::isEnabled()) { + $this->markTestSkipped('Test calls deprecated code'); + } } public function testParsingWithHeaders()