Download the PHP package timetoogo/php-generics without Composer

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

PHP-Generics

Boredom and a day: Simple generics for PHP

What are generics?

Generics allows you to write type safe code against multiple types.

Installation

To install with composer add this to your composer.json:

The implementation

This library has taken advantage of PHP's namspacing and autoloading to emulate generic types. The generic classes are parsed, then converted into the required concrete types and stored in the configurated directory.

Getting Started

To get started with PHP-Generics must first set the following configuration:

All generic class files must end in .generic.php

A Generic Example

The below code demonstrate a simple generic type:

Note the use of the __TYPE__ magic constant, these are used as type parameters. The constant will be replaced with the concrete class type as required. You can also use multiple type parameters in the form of __TYPE1__, __TYPE2__ etc. You can use type type parameters in any context: $Var instanceof __TYPE__, func(__TYPE__), __TYPE__::Foo() etc.

Note that __TYPE__ is an alias for __TYPE1__.

Using the generic types

The type parameters of the class are defined as sub-namespaces and are seperated by a special namespace _:

Creating a concete implementation of the above generic can be done like so:

Below creates a Tuple with __TYPE1__ as stdClass and __TYPE2__ as DateTime:

Limitation: All type parameter must be fully qualified:

If you have a namespaced class Foo\Bar\SomeClass this must be specified in the generic type parameter:

This creates a Tuple with __TYPE1__ as Foo\Bar\SomeClass and __TYPE2__ as DateTime.

Other uses

Generics can be used with inheritence:

Generic interfaces and traits are also supported:

Generic can be nested:

You can even extend/implement/use generic type paramerters:


All versions of php-generics with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
nikic/php-parser Version 0.9.4
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 timetoogo/php-generics contains the following files

Loading the files please wait ....