Skip to content

Commit

Permalink
API Add new deprecation notices.
Browse files Browse the repository at this point in the history
These are removed in CMS 5.
  • Loading branch information
GuySartorelli committed Feb 14, 2023
1 parent 1f7adab commit cca6c76
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/Core/Manifest/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 2 additions & 1 deletion src/Dev/CSVParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* $obj->write();
* }
* </code>
* @deprecated 4.13.0 Use League\Csv\Reader instead
*/
class CSVParser implements Iterator
{
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/Dev/CsvBulkLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ protected function processChunk($filepath, $preview = false)
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) {
Expand Down
8 changes: 8 additions & 0 deletions src/Dev/TestSession_STResponseWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* 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
{
Expand All @@ -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;
}

Expand Down
16 changes: 13 additions & 3 deletions tests/php/Dev/CSVParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Dev\Tests;

use SilverStripe\Dev\CSVParser;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;

class CSVParserTest extends SapphireTest
Expand All @@ -24,7 +25,10 @@ protected function setUp(): void
public function testParsingWithHeaders()
{
/* By default, a CSV file will be interpreted as having headers */
$csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
$filepath = $this->csvPath;
$csv = Deprecation::withNoReplacement(function () use ($filepath) {
return new CSVParser($filepath . 'PlayersWithHeader.csv');
});

$firstNames = $birthdays = $biographies = $registered = [];
foreach ($csv as $record) {
Expand Down Expand Up @@ -72,7 +76,10 @@ public function testParsingWithHeaders()
public function testParsingWithHeadersAndColumnMap()
{
/* By default, a CSV file will be interpreted as having headers */
$csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
$filepath = $this->csvPath;
$csv = Deprecation::withNoReplacement(function () use ($filepath) {
return new CSVParser($filepath . 'PlayersWithHeader.csv');
});

/* We can set up column remapping. The keys are case-insensitive. */
$csv->mapColumns([
Expand Down Expand Up @@ -117,7 +124,10 @@ public function testParsingWithHeadersAndColumnMap()
public function testParsingWithExplicitHeaderRow()
{
/* If your CSV file doesn't have a header row */
$csv = new CSVParser($this->csvPath . 'PlayersWithHeader.csv');
$filepath = $this->csvPath;
$csv = Deprecation::withNoReplacement(function () use ($filepath) {
return new CSVParser($filepath . 'PlayersWithHeader.csv');
});

$csv->provideHeaderRow(['__fn','__bio','__bd','__reg']);

Expand Down

0 comments on commit cca6c76

Please sign in to comment.