API Deprecate classes which will be renamed (#11375)

This commit is contained in:
Guy Sartorelli 2024-09-12 17:36:18 +12:00 committed by GitHub
parent b926834fb7
commit 9788a97500
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 145 additions and 0 deletions

View File

@ -3,12 +3,20 @@
namespace SilverStripe\ORM; namespace SilverStripe\ORM;
use Generator; use Generator;
use SilverStripe\Dev\Deprecation;
/** /**
* Library of static methods for manipulating arrays. * Library of static methods for manipulating arrays.
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib
*/ */
class ArrayLib class ArrayLib
{ {
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib', Deprecation::SCOPE_CLASS);
});
}
/** /**
* Inverses the first and second level keys of an associative * Inverses the first and second level keys of an associative
@ -45,9 +53,14 @@ class ArrayLib
* *
* @param array $arr * @param array $arr
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::invert()
*/ */
public static function invert($arr) public static function invert($arr)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invert()');
});
if (!$arr) { if (!$arr) {
return []; return [];
} }
@ -68,9 +81,14 @@ class ArrayLib
* *
* @param $arr array * @param $arr array
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::valuekey()
*/ */
public static function valuekey($arr) public static function valuekey($arr)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::valuekey()');
});
return array_combine($arr ?? [], $arr ?? []); return array_combine($arr ?? [], $arr ?? []);
} }
@ -79,9 +97,14 @@ class ArrayLib
* *
* @param array $array * @param array $array
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_values_recursive()
*/ */
public static function array_values_recursive($array) public static function array_values_recursive($array)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invearray_values_recursivert()');
});
return ArrayLib::flatten($array, false); return ArrayLib::flatten($array, false);
} }
@ -93,9 +116,14 @@ class ArrayLib
* @param $keys array * @param $keys array
* *
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()
*/ */
public static function filter_keys($arr, $keys) public static function filter_keys($arr, $keys)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()');
});
foreach ($arr as $key => $v) { foreach ($arr as $key => $v) {
if (!in_array($key, $keys ?? [])) { if (!in_array($key, $keys ?? [])) {
unset($arr[$key]); unset($arr[$key]);
@ -114,9 +142,14 @@ class ArrayLib
* @param array $array * @param array $array
* *
* @return boolean * @return boolean
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::is_associative()
*/ */
public static function is_associative($array) public static function is_associative($array)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::is_associative()');
});
$isAssociative = !empty($array) $isAssociative = !empty($array)
&& is_array($array) && is_array($array)
&& ($array !== array_values($array ?? [])); && ($array !== array_values($array ?? []));
@ -135,9 +168,14 @@ class ArrayLib
* @param boolean $strict * @param boolean $strict
* *
* @return boolean * @return boolean
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()
*/ */
public static function in_array_recursive($needle, $haystack, $strict = false) public static function in_array_recursive($needle, $haystack, $strict = false)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()');
});
if (!is_array($haystack)) { if (!is_array($haystack)) {
return false; return false;
} }
@ -163,9 +201,14 @@ class ArrayLib
* @param $f callback to apply * @param $f callback to apply
* @param $array array * @param $array array
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()
*/ */
public static function array_map_recursive($f, $array) public static function array_map_recursive($f, $array)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()');
});
$applyOrRecurse = function ($v) use ($f) { $applyOrRecurse = function ($v) use ($f) {
return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v); return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v);
}; };
@ -184,9 +227,14 @@ class ArrayLib
* @param array $array * @param array $array
* *
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()
*/ */
public static function array_merge_recursive($array) public static function array_merge_recursive($array)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()');
});
$arrays = func_get_args(); $arrays = func_get_args();
$merged = []; $merged = [];
@ -229,9 +277,14 @@ class ArrayLib
* @param array $out * @param array $out
* *
* @return array * @return array
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::flatten()
*/ */
public static function flatten($array, $preserveKeys = true, &$out = []) public static function flatten($array, $preserveKeys = true, &$out = [])
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::flatten()');
});
array_walk_recursive( array_walk_recursive(
$array, $array,
function ($value, $key) use (&$out, $preserveKeys) { function ($value, $key) use (&$out, $preserveKeys) {
@ -256,9 +309,14 @@ class ArrayLib
* *
* @param array $list * @param array $list
* @return Generator * @return Generator
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()
*/ */
public static function iterateVolatile(array &$list) public static function iterateVolatile(array &$list)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()');
});
// Keyed by already-iterated items // Keyed by already-iterated items
$iterated = []; $iterated = [];
// Get all items not yet iterated // Get all items not yet iterated
@ -278,9 +336,14 @@ class ArrayLib
/** /**
* Similar to shuffle, but retains the existing association between the keys and the values. * Similar to shuffle, but retains the existing association between the keys and the values.
* Shuffles the array in place. * Shuffles the array in place.
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()
*/ */
public static function shuffleAssociative(array &$array): void public static function shuffleAssociative(array &$array): void
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()');
});
$shuffledArray = []; $shuffledArray = [];
$keys = array_keys($array); $keys = array_keys($array);
shuffle($keys); shuffle($keys);

View File

@ -35,6 +35,7 @@ use Traversable;
* @implements Filterable<T> * @implements Filterable<T>
* @implements Sortable<T> * @implements Sortable<T>
* @implements Limitable<T> * @implements Limitable<T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ArrayList
*/ */
class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, Limitable class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, Limitable
{ {
@ -60,6 +61,10 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
*/ */
public function __construct(array $items = []) public function __construct(array $items = [])
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ArrayList', Deprecation::SCOPE_CLASS);
});
$this->items = array_values($items ?? []); $this->items = array_values($items ?? []);
parent::__construct(); parent::__construct();
} }

View File

@ -14,6 +14,7 @@ namespace SilverStripe\ORM;
* *
* @template T * @template T
* @extends SS_List<T> * @extends SS_List<T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Filterable
*/ */
interface Filterable extends SS_List interface Filterable extends SS_List
{ {

View File

@ -2,6 +2,7 @@
namespace SilverStripe\ORM; namespace SilverStripe\ORM;
use SilverStripe\Dev\Deprecation;
use SilverStripe\View\ArrayData; use SilverStripe\View\ArrayData;
/** /**
@ -11,10 +12,19 @@ use SilverStripe\View\ArrayData;
* @template TList * @template TList
* @template T * @template T
* @extends ListDecorator<TList, T> * @extends ListDecorator<TList, T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\GroupedList
*/ */
class GroupedList extends ListDecorator class GroupedList extends ListDecorator
{ {
public function __construct(SS_List&Sortable&Filterable&Limitable $list)
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\GroupedList', Deprecation::SCOPE_CLASS);
});
parent::__construct($list);
}
/** /**
* @param string $index * @param string $index
* @return array * @return array

View File

@ -14,6 +14,7 @@ namespace SilverStripe\ORM;
* *
* @template T * @template T
* @implements SS_List<T> * @implements SS_List<T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Limitable
*/ */
interface Limitable extends SS_List interface Limitable extends SS_List
{ {

View File

@ -4,6 +4,7 @@ namespace SilverStripe\ORM;
use SilverStripe\View\ViewableData; use SilverStripe\View\ViewableData;
use LogicException; use LogicException;
use SilverStripe\Dev\Deprecation;
use Traversable; use Traversable;
/** /**
@ -17,6 +18,7 @@ use Traversable;
* @implements Sortable<T> * @implements Sortable<T>
* @implements Filterable<T> * @implements Filterable<T>
* @implements Limitable<T> * @implements Limitable<T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ListDecorator
*/ */
abstract class ListDecorator extends ViewableData implements SS_List, Sortable, Filterable, Limitable abstract class ListDecorator extends ViewableData implements SS_List, Sortable, Filterable, Limitable
{ {
@ -30,6 +32,10 @@ abstract class ListDecorator extends ViewableData implements SS_List, Sortable,
*/ */
public function __construct(SS_List&Sortable&Filterable&Limitable $list) public function __construct(SS_List&Sortable&Filterable&Limitable $list)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ListDecorator', Deprecation::SCOPE_CLASS);
});
$this->setList($list); $this->setList($list);
parent::__construct(); parent::__construct();

View File

@ -6,10 +6,13 @@ use ArrayAccess;
use BadMethodCallException; use BadMethodCallException;
use Countable; use Countable;
use IteratorAggregate; use IteratorAggregate;
use SilverStripe\Dev\Deprecation;
use Traversable; use Traversable;
/** /**
* Creates a map from an SS_List by defining a key column and a value column. * Creates a map from an SS_List by defining a key column and a value column.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Map
*/ */
class Map implements ArrayAccess, Countable, IteratorAggregate class Map implements ArrayAccess, Countable, IteratorAggregate
{ {
@ -39,6 +42,10 @@ class Map implements ArrayAccess, Countable, IteratorAggregate
*/ */
public function __construct(SS_List $list, $keyField = "ID", $valueField = "Title") public function __construct(SS_List $list, $keyField = "ID", $valueField = "Title")
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\Map', Deprecation::SCOPE_CLASS);
});
$this->list = $list; $this->list = $list;
$this->keyField = $keyField; $this->keyField = $keyField;
$this->valueField = $valueField; $this->valueField = $valueField;

View File

@ -9,6 +9,7 @@ use SilverStripe\View\ArrayData;
use ArrayAccess; use ArrayAccess;
use Exception; use Exception;
use IteratorIterator; use IteratorIterator;
use SilverStripe\Dev\Deprecation;
use Traversable; use Traversable;
/** /**
@ -17,6 +18,7 @@ use Traversable;
* @template TList of SS_List * @template TList of SS_List
* @template T * @template T
* @extends ListDecorator<TList, T> * @extends ListDecorator<TList, T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\PaginatedList
*/ */
class PaginatedList extends ListDecorator class PaginatedList extends ListDecorator
{ {
@ -39,6 +41,10 @@ class PaginatedList extends ListDecorator
*/ */
public function __construct(SS_List $list, $request = []) public function __construct(SS_List $list, $request = [])
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\PaginatedList', Deprecation::SCOPE_CLASS);
});
if (!is_array($request) && !$request instanceof ArrayAccess) { if (!is_array($request) && !$request instanceof ArrayAccess) {
throw new Exception('The request must be readable as an array.'); throw new Exception('The request must be readable as an array.');
} }

View File

@ -12,6 +12,8 @@ use IteratorAggregate;
* @template T * @template T
* @extends ArrayAccess<array-key, T> * @extends ArrayAccess<array-key, T>
* @extends IteratorAggregate<array-key, T> * @extends IteratorAggregate<array-key, T>
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\SS_List
*/ */
interface SS_List extends ArrayAccess, Countable, IteratorAggregate interface SS_List extends ArrayAccess, Countable, IteratorAggregate
{ {

View File

@ -14,6 +14,7 @@ namespace SilverStripe\ORM;
* *
* @template T * @template T
* @implements SS_List<T> * @implements SS_List<T>
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Sortable
*/ */
interface Sortable extends SS_List interface Sortable extends SS_List
{ {

View File

@ -5,11 +5,14 @@ namespace SilverStripe\ORM;
use Exception; use Exception;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
/** /**
* Exception thrown by {@link DataObject}::write if validation fails. By throwing an * Exception thrown by {@link DataObject}::write if validation fails. By throwing an
* exception rather than a user error, the exception can be caught in unit tests and as such * exception rather than a user error, the exception can be caught in unit tests and as such
* can be used as a successful test. * can be used as a successful test.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\Validation\ValidationException
*/ */
class ValidationException extends Exception class ValidationException extends Exception
{ {
@ -31,6 +34,10 @@ class ValidationException extends Exception
*/ */
public function __construct($result = null, $code = 0) public function __construct($result = null, $code = 0)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationException', Deprecation::SCOPE_CLASS);
});
// Catch legacy behaviour where second argument was not code // Catch legacy behaviour where second argument was not code
if ($code && !is_numeric($code)) { if ($code && !is_numeric($code)) {
throw new InvalidArgumentException("Code must be numeric"); throw new InvalidArgumentException("Code must be numeric");

View File

@ -4,6 +4,7 @@ namespace SilverStripe\ORM;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\Core\Injector\Injectable; use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Dev\Deprecation;
/** /**
* A class that combined as a boolean result with an optional list of error messages. * A class that combined as a boolean result with an optional list of error messages.
@ -11,6 +12,8 @@ use SilverStripe\Core\Injector\Injectable;
* *
* Each message can have a code or field which will uniquely identify that message. However, * Each message can have a code or field which will uniquely identify that message. However,
* messages can be stored without a field or message as an "overall" message. * messages can be stored without a field or message as an "overall" message.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\Validation\ValidationResult
*/ */
class ValidationResult class ValidationResult
{ {
@ -61,6 +64,13 @@ class ValidationResult
*/ */
protected $messages = []; protected $messages = [];
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationResult', Deprecation::SCOPE_CLASS);
});
}
/** /**
* Record an error against this validation result, * Record an error against this validation result,
* *

View File

@ -4,6 +4,7 @@ namespace SilverStripe\View;
use SilverStripe\ORM\ArrayLib; use SilverStripe\ORM\ArrayLib;
use InvalidArgumentException; use InvalidArgumentException;
use SilverStripe\Dev\Deprecation;
use stdClass; use stdClass;
/** /**
@ -15,6 +16,8 @@ use stdClass;
* "AddAction" => "Add a new Page page", * "AddAction" => "Add a new Page page",
* )); * ));
* </code> * </code>
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ArrayData
*/ */
class ArrayData extends ViewableData class ArrayData extends ViewableData
{ {
@ -31,6 +34,10 @@ class ArrayData extends ViewableData
*/ */
public function __construct($value = []) public function __construct($value = [])
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ArrayData', Deprecation::SCOPE_CLASS);
});
if (is_object($value)) { if (is_object($value)) {
$this->array = get_object_vars($value); $this->array = get_object_vars($value);
} elseif (is_array($value)) { } elseif (is_array($value)) {

View File

@ -32,6 +32,8 @@ use UnexpectedValueException;
* A view interrogates the object being currently rendered in order to get data to render into the template. This data * A view interrogates the object being currently rendered in order to get data to render into the template. This data
* is provided and automatically escaped by ViewableData. Any class that needs to be available to a view (controllers, * is provided and automatically escaped by ViewableData. Any class that needs to be available to a view (controllers,
* {@link DataObject}s, page controls) should inherit from this class. * {@link DataObject}s, page controls) should inherit from this class.
*
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelData
*/ */
class ViewableData implements IteratorAggregate class ViewableData implements IteratorAggregate
{ {
@ -97,6 +99,9 @@ class ViewableData implements IteratorAggregate
public function __construct() public function __construct()
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelData', Deprecation::SCOPE_CLASS);
});
} }
// ----------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------

View File

@ -2,6 +2,11 @@
namespace SilverStripe\View; namespace SilverStripe\View;
use SilverStripe\Dev\Deprecation;
/**
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelDataCustomised
*/
class ViewableData_Customised extends ViewableData class ViewableData_Customised extends ViewableData
{ {
@ -18,6 +23,10 @@ class ViewableData_Customised extends ViewableData
*/ */
public function __construct(ViewableData $originalObject, ViewableData $customisedObject) public function __construct(ViewableData $originalObject, ViewableData $customisedObject)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataCustomised', Deprecation::SCOPE_CLASS);
});
$this->original = $originalObject; $this->original = $originalObject;
$this->customised = $customisedObject; $this->customised = $customisedObject;

View File

@ -3,9 +3,11 @@
namespace SilverStripe\View; namespace SilverStripe\View;
use ReflectionObject; use ReflectionObject;
use SilverStripe\Dev\Deprecation;
/** /**
* Allows you to render debug information about a {@link ViewableData} object into a template. * Allows you to render debug information about a {@link ViewableData} object into a template.
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelDataDebugger
*/ */
class ViewableData_Debugger extends ViewableData class ViewableData_Debugger extends ViewableData
{ {
@ -20,6 +22,9 @@ class ViewableData_Debugger extends ViewableData
*/ */
public function __construct(ViewableData $object) public function __construct(ViewableData $object)
{ {
Deprecation::withNoReplacement(function () {
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataDebugger', Deprecation::SCOPE_CLASS);
});
$this->object = $object; $this->object = $object;
parent::__construct(); parent::__construct();
} }