Download the PHP package eboreum/collections without Composer

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

Eboreum/Collections: Moving PHP closer towards generics

license build Code Coverage PHPStan Level

Wish you had generics in PHP? This library provides a sensible means of managing collections of data (i.e. arrays with restrictions), immutably, until such a time that PHP generics are bestowed upon us.

Comes fully equipped with phpstan generics annotations. For details, see: https://phpstan.org/blog/generics-in-php-using-phpdocs

Requirements

For more information, see the composer.json file.

Installation

Via Composer (https://packagist.org/packages/eboreum/collections):

composer install eboreum/collections

Via GitHub:

git clone [email protected]:eboreum/collections.git

Fundamentals

This library has two core components:

  1. The class Eboreum\Collections\Collection.
  2. The interface Eboreum\Collections\Contract\CollectionInterface.

Eboreum\Collections\Collection by itself imposes no restrictions and may used for storing any data type. It can be thought of as a fancy array. However, it has two crucial differences and advantages over simple arrays: It's immutable and it's type hinted, including annotations for generics (https://phpstan.org/blog/generics-in-php-using-phpdocs).

The true power of this library shows once you start making collection classes, extending Eboreum\Collections\Collection, which have restrictions.

This library comes equipped with the following simple data type collection classes:

The real shine comes when we start making restrictions on the contents of the collection classes, for instance restrictions on specific classes.

This library has the following predefined class collections:

You may use the above files as inspiration on how to build your own specific class collections. However, this process can be automated; read more about automation further down.

The above classes utilize the abstract class \Eboreum\Collections\Abstraction\AbstractNamedClassOrInterfaceCollection and subsequently the interface \Eboreum\Collections\Contract\ObjectCollectionInterface.

Automating writing of collection classes

⚠️ NOTICE ⚠️

"eboreum/collection-class-generator" is NOT YET publicly available!

Writing tens or even hundreds of collection classes, which essentially have the same structure, is tedious. This process can be automated by utilizing https://packagist.org/packages/eboreum/collection-class-generator, which will write all desired collection classes for you, directly into in your own project to one or more locations of your choosing. It even comes with opt-in writing of unit tests (https://packagist.org/packages/phpunit/phpunit)!

Make collections for anything – not just classes

You may make restrictions for anything – not just classes – including unions (https://php.watch/versions/8.0/union-types). Essentially, you merely have to override the isElementAccepted method in the collection class you are implementing.

Need something that will accept both integers and float numbers (a union)?

Simply do the following:

Do remember: If you utilize phpstan, you should also add and/or update the @template and its references throughout your custom collection class.

You should also override methods such as current, find, first, etc. with a suitable return type. For instance:

PHP ^8.1:

Notice: Intersection types (https://php.watch/versions/8.1/intersection-types) are not supported as they are not supported by PHP 8 due to https://wiki.php.net/rfc/nullable_intersection_types having been declined.

The reason is that methods such as current, find, first, etc. cannot have nullable return types when handling intersections.

Tests

Test/development requirements

Running tests

For all unit tests, first follow these steps:

License & Disclaimer

See LICENSE file. Basically: Use this library at your own risk.

Contributing

We prefer that you create a ticket and or a pull request at https://github.com/eboreum/collections, and have a discussion about a feature or bug here.

No \ArrayAccess!

This library does not and will not utilize \ArrayAccess (https://www.php.net/manual/en/class.arrayaccess.php).

It goes against the immutable nature of this library, it's a little bit evil, and it makes code unnecessarily obscure.

Credits

Authors

Acknowledgements

doctrine/collections

This library is greatly inspired by https://packagist.org/packages/doctrine/collections (https://github.com/doctrine/collections) and some of the code is indeed copied from that library (acknowledged by inclusion of the LICENSE file contents at the top of select files, as required by https://github.com/doctrine/collections/blob/94918256daa6ac99c7e5774720c0e76f01936bda/LICENSE).


All versions of collections with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
eboreum/caster Version ^1.0
eboreum/exceptional 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 eboreum/collections contains the following files

Loading the files please wait ....