diff --git a/src/ORM/ArrayLib.php b/src/ORM/ArrayLib.php index 371d0f6df..d3c4815e6 100644 --- a/src/ORM/ArrayLib.php +++ b/src/ORM/ArrayLib.php @@ -3,12 +3,20 @@ namespace SilverStripe\ORM; use Generator; +use SilverStripe\Dev\Deprecation; /** * Library of static methods for manipulating arrays. + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\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 @@ -45,9 +53,14 @@ class ArrayLib * * @param array $arr * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::invert() */ public static function invert($arr) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invert()'); + }); + if (!$arr) { return []; } @@ -68,9 +81,14 @@ class ArrayLib * * @param $arr array * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::valuekey() */ 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 ?? []); } @@ -79,9 +97,14 @@ class ArrayLib * * @param array $array * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_values_recursive() */ 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); } @@ -93,9 +116,14 @@ class ArrayLib * @param $keys array * * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::filter_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) { if (!in_array($key, $keys ?? [])) { unset($arr[$key]); @@ -114,9 +142,14 @@ class ArrayLib * @param array $array * * @return boolean + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::is_associative() */ 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) && is_array($array) && ($array !== array_values($array ?? [])); @@ -135,9 +168,14 @@ class ArrayLib * @param boolean $strict * * @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) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()'); + }); + if (!is_array($haystack)) { return false; } @@ -163,9 +201,14 @@ class ArrayLib * @param $f callback to apply * @param $array 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) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()'); + }); + $applyOrRecurse = function ($v) use ($f) { return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v); }; @@ -184,9 +227,14 @@ class ArrayLib * @param array $array * * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive() */ 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(); $merged = []; @@ -229,9 +277,14 @@ class ArrayLib * @param array $out * * @return array + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::flatten() */ 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, function ($value, $key) use (&$out, $preserveKeys) { @@ -256,9 +309,14 @@ class ArrayLib * * @param array $list * @return Generator + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile() */ 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 $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. * Shuffles the array in place. + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative() */ public static function shuffleAssociative(array &$array): void { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()'); + }); + $shuffledArray = []; $keys = array_keys($array); shuffle($keys); diff --git a/src/ORM/ArrayList.php b/src/ORM/ArrayList.php index 16fc11de4..94920fe3e 100644 --- a/src/ORM/ArrayList.php +++ b/src/ORM/ArrayList.php @@ -35,6 +35,7 @@ use Traversable; * @implements Filterable * @implements Sortable * @implements Limitable + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ArrayList */ 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 = []) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ArrayList', Deprecation::SCOPE_CLASS); + }); + $this->items = array_values($items ?? []); parent::__construct(); } diff --git a/src/ORM/Filterable.php b/src/ORM/Filterable.php index ce5196e46..4caf7032f 100644 --- a/src/ORM/Filterable.php +++ b/src/ORM/Filterable.php @@ -14,6 +14,7 @@ namespace SilverStripe\ORM; * * @template T * @extends SS_List + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Filterable */ interface Filterable extends SS_List { diff --git a/src/ORM/GroupedList.php b/src/ORM/GroupedList.php index 6fdd257d8..e81d5bbbe 100644 --- a/src/ORM/GroupedList.php +++ b/src/ORM/GroupedList.php @@ -2,6 +2,7 @@ namespace SilverStripe\ORM; +use SilverStripe\Dev\Deprecation; use SilverStripe\View\ArrayData; /** @@ -11,10 +12,19 @@ use SilverStripe\View\ArrayData; * @template TList * @template T * @extends ListDecorator + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\GroupedList */ 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 * @return array diff --git a/src/ORM/Limitable.php b/src/ORM/Limitable.php index 4a2d37b3a..f9e290649 100644 --- a/src/ORM/Limitable.php +++ b/src/ORM/Limitable.php @@ -14,6 +14,7 @@ namespace SilverStripe\ORM; * * @template T * @implements SS_List + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Limitable */ interface Limitable extends SS_List { diff --git a/src/ORM/ListDecorator.php b/src/ORM/ListDecorator.php index b063acb74..94712368a 100644 --- a/src/ORM/ListDecorator.php +++ b/src/ORM/ListDecorator.php @@ -4,6 +4,7 @@ namespace SilverStripe\ORM; use SilverStripe\View\ViewableData; use LogicException; +use SilverStripe\Dev\Deprecation; use Traversable; /** @@ -17,6 +18,7 @@ use Traversable; * @implements Sortable * @implements Filterable * @implements Limitable + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ListDecorator */ 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) { + Deprecation::withNoReplacement(function () { + Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ListDecorator', Deprecation::SCOPE_CLASS); + }); + $this->setList($list); parent::__construct(); diff --git a/src/ORM/Map.php b/src/ORM/Map.php index a1b81f609..186cf2246 100644 --- a/src/ORM/Map.php +++ b/src/ORM/Map.php @@ -6,10 +6,13 @@ use ArrayAccess; use BadMethodCallException; use Countable; use IteratorAggregate; +use SilverStripe\Dev\Deprecation; use Traversable; /** * 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 { @@ -39,6 +42,10 @@ class Map implements ArrayAccess, Countable, IteratorAggregate */ 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->keyField = $keyField; $this->valueField = $valueField; diff --git a/src/ORM/PaginatedList.php b/src/ORM/PaginatedList.php index 99e7ebb81..b7d392700 100644 --- a/src/ORM/PaginatedList.php +++ b/src/ORM/PaginatedList.php @@ -9,6 +9,7 @@ use SilverStripe\View\ArrayData; use ArrayAccess; use Exception; use IteratorIterator; +use SilverStripe\Dev\Deprecation; use Traversable; /** @@ -17,6 +18,7 @@ use Traversable; * @template TList of SS_List * @template T * @extends ListDecorator + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\PaginatedList */ class PaginatedList extends ListDecorator { @@ -39,6 +41,10 @@ class PaginatedList extends ListDecorator */ 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) { throw new Exception('The request must be readable as an array.'); } diff --git a/src/ORM/SS_List.php b/src/ORM/SS_List.php index 2aa82783d..4cb769a86 100644 --- a/src/ORM/SS_List.php +++ b/src/ORM/SS_List.php @@ -12,6 +12,8 @@ use IteratorAggregate; * @template T * @extends ArrayAccess * @extends IteratorAggregate + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\SS_List */ interface SS_List extends ArrayAccess, Countable, IteratorAggregate { diff --git a/src/ORM/Sortable.php b/src/ORM/Sortable.php index 07c9e92fc..2fd84c911 100644 --- a/src/ORM/Sortable.php +++ b/src/ORM/Sortable.php @@ -14,6 +14,7 @@ namespace SilverStripe\ORM; * * @template T * @implements SS_List + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Sortable */ interface Sortable extends SS_List { diff --git a/src/ORM/ValidationException.php b/src/ORM/ValidationException.php index 88f919209..1ee47db27 100644 --- a/src/ORM/ValidationException.php +++ b/src/ORM/ValidationException.php @@ -5,11 +5,14 @@ namespace SilverStripe\ORM; use Exception; use InvalidArgumentException; use SilverStripe\Core\Injector\Injectable; +use SilverStripe\Dev\Deprecation; /** * 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 * can be used as a successful test. + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\Core\Validation\ValidationException */ class ValidationException extends Exception { @@ -31,6 +34,10 @@ class ValidationException extends Exception */ 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 if ($code && !is_numeric($code)) { throw new InvalidArgumentException("Code must be numeric"); diff --git a/src/ORM/ValidationResult.php b/src/ORM/ValidationResult.php index 8ba3ba545..d57a3b8b2 100644 --- a/src/ORM/ValidationResult.php +++ b/src/ORM/ValidationResult.php @@ -4,6 +4,7 @@ namespace SilverStripe\ORM; use InvalidArgumentException; use SilverStripe\Core\Injector\Injectable; +use SilverStripe\Dev\Deprecation; /** * 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, * 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 { @@ -61,6 +64,13 @@ class ValidationResult */ 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, * diff --git a/src/View/ArrayData.php b/src/View/ArrayData.php index 1d166de53..34786a962 100644 --- a/src/View/ArrayData.php +++ b/src/View/ArrayData.php @@ -4,6 +4,7 @@ namespace SilverStripe\View; use SilverStripe\ORM\ArrayLib; use InvalidArgumentException; +use SilverStripe\Dev\Deprecation; use stdClass; /** @@ -15,6 +16,8 @@ use stdClass; * "AddAction" => "Add a new Page page", * )); * + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ArrayData */ class ArrayData extends ViewableData { @@ -31,6 +34,10 @@ class ArrayData extends ViewableData */ 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)) { $this->array = get_object_vars($value); } elseif (is_array($value)) { diff --git a/src/View/ViewableData.php b/src/View/ViewableData.php index d729d36da..37970ba69 100644 --- a/src/View/ViewableData.php +++ b/src/View/ViewableData.php @@ -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 * 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. + * + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelData */ class ViewableData implements IteratorAggregate { @@ -97,6 +99,9 @@ class ViewableData implements IteratorAggregate public function __construct() { + Deprecation::withNoReplacement(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 a8589bb51..0988b2957 100644 --- a/src/View/ViewableData_Customised.php +++ b/src/View/ViewableData_Customised.php @@ -2,6 +2,11 @@ namespace SilverStripe\View; +use SilverStripe\Dev\Deprecation; + +/** + * @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelDataCustomised + */ class ViewableData_Customised extends ViewableData { @@ -18,6 +23,10 @@ class ViewableData_Customised extends ViewableData */ 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->customised = $customisedObject; diff --git a/src/View/ViewableData_Debugger.php b/src/View/ViewableData_Debugger.php index 9c496c99a..c2ea7357b 100644 --- a/src/View/ViewableData_Debugger.php +++ b/src/View/ViewableData_Debugger.php @@ -3,9 +3,11 @@ namespace SilverStripe\View; use ReflectionObject; +use SilverStripe\Dev\Deprecation; /** * 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 { @@ -20,6 +22,9 @@ class ViewableData_Debugger extends ViewableData */ 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; parent::__construct(); }