Download the PHP package stratadox/immutable-collection without Composer

On this page you can find all versions of the php package stratadox/immutable-collection. 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 immutable-collection

ImmutableCollection

Build Status Coverage Status Scrutinizer Code Quality

Immutable implementation of the Collection interface.

Provides an abstract ImmutableCollection class, which extends (and restricts) the SplFixedArray class, as well as several traits with behavioural logic for (derived) immutable collection classes.

Why use this

Regular php "arrays" are not really arrays at all, but sorted hash maps. They are not objects, they are not thread safe and they cannot guard their own invariants.

Although sorted hash maps are a versatile data structure that can be used in many different scenarios, they aren't always good data structures for the situation.

When dealing with a collection of objects, for instance, you probably want dedicated collection objects, on which you can call methods.

Many frameworks provide some sort of collection class. They rarely provide immutability, though, and are therefore not thread safe. Additionally, they are usually implementing a bloated interface with all of the methods you might some day need - but probably won't.

Due to the many optional expansions which can be applied at will, this package enables powerful typesafe collections that can be fine-tunes for use in any project, without getting distracted by a bloated collection interface.

The immutability of the collection means they can be used in projects that care about reducing state changes.

Installation

Install using composer:

Basic usage

The most basic implementation of the immutable collection might look something like the following:

Or:

Advanced usage

Additional behaviour can be added by implementing the relevant interfaces and/or traits for the particular concrete collection:

Multiple kinds of behaviour can be used simultaneously:

The shorthand for which is:

If desired, the methods current and offsetGet may be implemented with a return type hint, in order to (further) increase type safety and to allow IDE's like PhpStorm to provide code completion in loops and array-like access:


All versions of immutable-collection with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
stratadox/collection-contracts Version ^5.0
stratadox/specification-interfaces Version ^1.0
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 stratadox/immutable-collection contains the following files

Loading the files please wait ....