Download the PHP package shrikeh/collections without Composer

On this page you can find all versions of the php package shrikeh/collections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package collections

php-immutable-collections

build_status_img code_quality_img latest_stable_version_img latest_unstable_version_img license_img twitter_img

Trait-based helper library to take care of the heavy lifting of immutable collections in PHP.

Overview

This low-level library is just time-saving traits for creating immutable collections. As PHP 7 can use return type hinting, I decided I would always return a Collection if there was a possibility of returning 0-n objects from a method, and could then type hint the return value as a Collection, whether empty or not. PHP does not natively support immutable iterators, so I find that whenever I use Domain-Driven Design, and need an iterable list of Value Objects, I have to do the same boilerplate re-work.

This pattern has been successful for me, as I can also strongly type the Collections themselves, so they can only contain objects of a given type. I also generally make them immutable, so they throw a descendent of DomainException if you try to set or unset a value.

So as I use these more often, I split them up into Traits for re-use across my code. Feel free to use for yourself, they're tiny and just take care of boilerplate stuff for me.

Installation

Recommended installation is via the ubiquitous and seminal composer:

Usage

The library consists of about a dozen traits that aid in matching core PHP and SPL interfaces such as ArrayAccess and OuterIterator. Generally I have an inner "storage", and ensure that access to this directly is removed, including mutable methods such as offSetSet() or offsetUnset(). This ensures that only the values added to the constructor can be iterated over.

As an example, to create a Collection that can only contain SomeObject objects:

Please take a look in the examples and the specs for further usage.

Traits

ArrayAccessTrait

Used to easily meet the requirements of the ArrayAccess interface. Proxies to underlying offsetX methods of the storage.

ClosedOuterIteratorTrait

The OuterIterator interface specifies that a class must implement the method getInnerIterator, and the visibility of this method cannot be changed from public. This defeats the point of having an immutable Collection. Therefore, this trait, when applied, causes the class to throw a ClosedOuterIterator exception for this method.

FixedArrayStorageTrait

This provides a public __construct() method consistent with the IteratorIterator family of SPL classes, providing the class with a SplFixedArray storage (SplFixedArray, sadly, can have it's size changed after instanstiation).

ImmutableArrayAccessTrait

This trait "switches off" the offsetSet() and offsetUnset() methods required by the ArrayAccess interface. Attempting to use either will result in a ImmutableCollection exception being thrown.

ImmutableCollectionTrait

This trait is a shorthand for including the ArrayAccessTrait and then overriding the setters with ImmutableArrayAccessTrait.

NamedConstructorsTrait

Provides the named constructors fromTraversable() and fromArray() to a Collection.

ObjectStorageTrait

This provides a public __construct() method consistent with the IteratorIterator family of SPL classes, providing the class with a SplObjectStorage inner storage.

OuterIteratorTrait

If you don't want to extend any of the IteratorIterator family, but do want to implement OuterIterator, this trait provides the necessary methods that proxy to the inner storage.

RequiresOuterIteratorTrait

"Safety catch" trait used by FixedArrayStorageTrait and ObjectStorageTrait to ensure the class using the trait implements OuterIterator. Throws an IncorrectInterface Exception if not.


All versions of collections with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package shrikeh/collections contains the following files

Loading the files please wait ....