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

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

Typed 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.

This library provides traits that can be used to implement type checking.

If you do not wish to implement anything, simply use one of the prebuilt solutions below:

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.

Simplistic Example

This example only implements the ArrayAccess PHP Predefined Interface. This means no foreach iteration, count(), and so on...

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 predefined values:

Checking a Value

If you want to know if a value would be accepted in the typed collection, you can use the isElementType() method.

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-collections with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
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-collections contains the following files

Loading the files please wait ....