Download the PHP package edumarques/typed-collections without Composer
On this page you can find all versions of the php package edumarques/typed-collections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edumarques/typed-collections
More information about edumarques/typed-collections
Files in edumarques/typed-collections
Package typed-collections
Short Description Typed collections are an implementation of typed lists.
License MIT
Informations about the package typed-collections
Typed Collections
Description
Typed collections are an implementation of typed lists. Collections allow us to have traversable lists of a predetermined type and its subtypes. Its behavior prevents the looseness of arrays in PHP.
This library contains four collection classes: mutable and immutable lists, and mutable and immutable dictionaries. Mutable lists/dictionaries have its internal array altered whenever we perform operations on it. Immutable lists/dictionaries generate a new instance of itself when operations are done on it.
Installation
Basic usage
Collection
A PHP implementation of an array list. Its type is specified at instantiation/construction. The class will perform runtime type checks to validate the appropriate values are being added. Many of the standard array functionalities are encapsulated in this class.
Dictionary
Dictionaries extend Collections' functionalities. The main difference is that they work with associative arrays, where you map keys to values.
Supported types:
ScalarType::INTEGER
ScalarType::STRING
ScalarType::BOOLEAN
ScalarType::DOUBLE
NonScalarType::ARRAY
NonScalarType::CALLABLE
class-string
Support for abstract classes and interfaces
Collections and Dictionaries will check inheritance, so if you require a base class, derived classes can be added safely.
Contributing
Contributors are always welcome! For more information on how you can contribute, please read our contribution guideline.