Changelog
v3.0.1
Bug Fixes:
- Removed
@psalm-consistent-templatesfromStrictCollection,StrictList,StrictQueueandStrictStack, because it made Psalm reject subclasses with a fixed item type (e.g.class MyQueue extends StrictQueue<Foo>)
v3.0.0
New Features:
- Added a PHPUnit test suite (
composer phpunit:test), running on PHP 8.2 to 8.5 in CI - Added static
fromArray()constructors to all datastructures (e.g.StrictList::fromArray([1, 2], ['int'])), which also let PHPStan and Psalm infer the item types TypeChecker(and thus all datastructures) now supports union types (e.g.int|string), nullable types (e.g.?int) andmixed
Breaking Changes:
- Raised minimum PHP version from 8.1 to 8.2, as PHP 8.1 reached end of life
- Atomic type keywords for
TypeChecker(and thus all datastructures) are now case-sensitive and must be lowercase (e.g.'Int'or'STRING'are now treated as class names and therefore never match scalar values) StrictCollectionandStrictArrayno longer implement the legacySerializableinterface (and thus no longer haveserialize()andunserialize()methods). Serializing them with PHP'sserialize()andunserialize()functions works as before.StrictList,StrictQueueandStrictStackstill implement it, because their SPL parent classes doGetter::__isset()no longer swallows exceptions thrown by_magicGet*()methodsTypeChecker::setAllowedTypes()splits union and nullable types into separate types and throws anInvalidArgumentExceptionfor empty types (e.g.''or'int|')
Maintenance:
- Updated Psalm to version 7 and PHP Mess Detector to version 3
- Imported the
OverrideandReturnTypeWillChangeattributes instead of using their fully qualified names - The documentation is now built and deployed by GitHub Actions on every new release instead of being committed to the repository
Bug Fixes:
TypeCheckerno longer calls arbitraryis_*()functions for class names (e.g. a classFilecaused aTypeErrorfromis_file(), andCountableaccepted arrays viais_countable()). Everything but the atomic type keywords is now checked withinstanceofStrictArraynow supports appending with$array[] = $valueStrictCollection::get()andStrictCollection::remove()now work for items with valuenullTriggerExceptionErrorno longer usesE_USER_ERROR(deprecated since PHP 8.4), but triggers anE_USER_WARNINGand exits with status255StrictList::add(),StrictQueue::add()andStrictStack::add()now insert the item at the given offset instead of replacing the existing itemStrictList::prepend(),StrictQueue::prepend()andStrictStack::prepend()now keep the order of the given items (likearray_unshift()) instead of reversing them- Unserializing a
StrictStack(or any list in LIFO iteration mode) no longer reverses the order of its items
v2.1.3
Maintenance:
- Updated development dependencies
- Raised PHPStan rule level to 10
- Updated links to documentation
- Used more generics in PHPStan and Psalm type-hints
v2.1.2
New Features:
- Added Composer commands for development tools (PHP Mess Detector, Psalm Taint Analysis)
v2.1.1
New Features:
- Added Composer commands for development tools (PHP_CodeSniffer, PHP-CS-Fixer, PHPStan, Psalm and phpDocumentor)
Minor Changes:
- Extended documentation
v2.1.0
Breaking Changes:
- Traits for datastructures renamed to StrictSplDoublyLinkedListTrait
New Features:
- Extended API for StrictArray
v2.0.0
Breaking Changes:
- Raised minimum PHP version from 8.0 to 8.1 in order to use new features like array_is_list() and the spread operator on string-keyed arrays
-
Interfaces traits renamed and moved to different namespace
OCC\Basics\InterfaceTraits\ArrayAccess -> OCC\Basics\Interfaces\ArrayAccessTrait OCC\Basics\InterfaceTraits\Countable -> OCC\Basics\Interfaces\CountableTrait OCC\Basics\InterfaceTraits\IteratorAggregate -> OCC\Basics\Interfaces\IteratorAggregateTrait OCC\Basics\InterfaceTraits\Iterator -> OCC\Basics\Interfaces\IteratorTrait -
Prefixed internal methods for Getter and Setter with
_to avoid confusion with regular class methods// old methods function magicGet{Property}(): mixed function magicSet{Property}(mixed $value): void// new methods function _magicGet{Property}(): mixed function _magicSet{Property}(mixed $value): void
New Features:
- Added new datastructure StrictCollection
- Added new datastructure StrictArray
- Added new error handler TriggerExceptionError
- Added new trait OverloadingGetter
- Added new trait OverloadingSetter
- Added new trait TypeChecker
- Extended API for all datastructures (see StrictSplDoublyLinkedListTrait )
- Introduced InvalidDataTypeException for strict datastructures
Minor Changes:
- Extended documentation
v1.1.0
Breaking Changes:
-
Changed the constructor's signature for all DataStructures to improve compatibility with the corresponding SPL datastructures
// old constructor signature public function __construct(iterable $items = [], array $allowedTypes = [])// new constructor signature public function __construct(array $allowedTypes = [])
v1.0.1
Minor Changes:
- Improved exception handling in Singleton trait
v1.0.0
Initial Release