Download the PHP package jausions/php-typed-doctrine-collections without Composer

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

Typed Doctrine Collections

Type hinting is evolving but PHP 7 still does not currently provide a way to define the type of the elements of an array (a.k.a. Generics.)

This library is built on top of Doctrine/Collections to enforce type checking on elements added to a collection. We could also call them strongly typed arrays.

The aim is to leverage type hinting to help prevent bugs, or, at the very least, detect them earlier in the development cycle.

For the purpose of this library, the term type is used loosely to refer to built-in PHP types, classes, and even application-domain types.

Installation

In the examples below, the require 'vendor/autoload.php'; is implied.

Type Defined by Initial Value

The first element passed to the constructor determines the criteria for the elements that come after it.

Type Defined by a Sample Value

The element validation is done against the type of a sample value.

Type Defined by a Closure

The elements added to the collection can be checked with a closure:

Type Defined by a Class Name

Objects added to the collection can be checked against a class name:

Built-In Library Types

Apart from a closure or a class name, the setElementType() method also accepts the following values:

Built-In Collections

Several typed collections are predefined:

Custom Type Collections

You can easily create collections by extending the base class or by including the trait into your own implementation of the ArrayAccess interface.

Remarks:

  1. We could have type hinted the enter() method with the Car class instead of the Vehicle class. This would also have thrown a \TypeError exception.
  2. I am aware that I mixed the types in the docBlock and the signature of the getCars() method. It is somewhat more legible and may help your IDE. However, the benefit may vary depending on your editor / IDE, and it may lead to confusion if trying to use some array function that expect a native array type.

All versions of php-typed-doctrine-collections with dependencies

PHP Build Version
Package Version
Requires doctrine/collections Version ^v1.5
jausions/php-typed-collections Version ^v1.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 jausions/php-typed-doctrine-collections contains the following files

Loading the files please wait ....