Download the PHP package simondeeley/type without Composer

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

Reusable immutable objects for PHP

License Latest Stable Version Latest Unstable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

This package contains a few reusable classes, interfaces and traits which have been written to provide a basis for creating both immutable and variable objects.

This package was born out of a love creating beautifully crafted 'boilerplate' code which can be reused again and again in any number of both simple and complex objects. Most of the ideas used in this package revolve around the need to create the most basic of PHP objects - one that is immutable and unchanging. Trouble is, PHP has a fair few 'magic methods' which, although great for method overriding, are less great for ensuring an immutable state. This package aims to solve that problem and provide a number of base classes to allow you to build easy-to-use immutable classes of your own.

Requirements

Installation

Usage

Create your own immutable object

This is the starting point to creating an immutable object. Behind the scenes, the base class of ImmutableObject sets up a few sensible defaults including overriding PHP's magic methods __set and __unset to prevent implicitly setting (or unsetting) of class properties.

There is one further method that you need to implement in your concrete classes which is getType. This method is inherited from the interface simondeeley\Type\Type which defines one static method getType which should return a string describing the type of the object.

It might seem strange having this method but it's useful when defining a bunch of objects which might, for example, share the same base class but who's identity you want to differentiate.

In the example above, you might implement the interface as such:

Going Further

As well as ImmutableObject this package also provides a second base class for objects which need to behave like arrays, implementing PHP's built-in ArrayAccess. This behaviour is provided in ImmutableArrayTypeObject which extends ImmutableObject and includes default implementations of offsetSet and offsetUnset.

Each of these classes uses a few traits which provide the default implementations described above. You can explore these as well as the interfaces in the code which is fully documented and annotated.

Testing Equality

Oftentimes there is a need to check that two objects are equal. This package provides a TypeEquality interface which describes one method, equals.

This method takes an object of type simondeeley\Type\Type as an argument. This interface is the base interface that all other 'types' are built on. This method also optionally accepts a further parameter - a bitwise integer flag. This can be used to enforce or ignore certain constraints. Currently, two flags are supported:

Bitwise operators can be combined by using the pipe '|' operator, for example $foo->equals($bar, TypeEquality::IGNORE_OBJECT_TYPE | TypeEquality::IGNORE_OBJECT_IDENTITY)

When implementing this method you can choose whether to utilise the bitwise flags but they should be present in your method signature. The body of the method should then perform whatever actions are necessary to compare the two objects to determine equality. An example of this can be found in the simondeeley\Tuple package which uses this package to build an immutable tuple object that can check equality against another tuple.


All versions of type 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 simondeeley/type contains the following files

Loading the files please wait ....