Download the PHP package thisbar/php-array-of without Composer

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

php-array-of

Build Status

Implement an array of a defined type. Generics replacement for PHP.

Requirements

Requires PHP 7.1

Installation

Through Composer, obviously:

Why?

PHP 7 has pretty good support for type declarations, both in arguments and returns. It now also handles primitives as well as class names. For example:

One thing is still lacking. Array generics. There's an RFC for implementing 'Array Of'. It's been around for quite a while and was roundly rejected.

This library is a workaround for that. It allows you to make type declarations for arrays of a particular type.

Usage

Using an existing implementation

The library comes with ArrayOf implementations for all of the PHP scalar types. i.e.:

These can then be used in a type declaration:

An ArrayOfInteger can be created:

and used like an array:

Implementing your own type

You can create your own ArrayOfs for your own types.

An ArrayOfCard can be created thus:

Other concerns

Enforcement

Members of an ArrayOf are enforced as being of the type specified in the typeToEnforce abstract method. This enforcement occurs on instantiation at runtime. If you try to instantiate with a member of a non-matching type, an exception will be thrown.

Permissible types

Only PHP scalars and objects can be members of an ArrayOf. So no callables and no arrays.

Immutability

ArrayOfs are mutable. This library provides the capability to define immutable objects in the form of ImmutableArrayOfs. These objects extend from ArrayOf and work in the same way except after the initial instantiation, no further changes can be made to the object. If you try to perform a write operation (e.g. unset) on it, an exception will be thrown. All of the scalar types are also provided in immutable form:


All versions of php-array-of with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1 || ~8.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 thisbar/php-array-of contains the following files

Loading the files please wait ....