Download the PHP package hhvm/type-assert without Composer

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

TypeAssert

Continuous Integration

Hack library for converting untyped data to typed data.

Warning for TypeAssert\matches_type_structure()

TypeStructure<T>, type_structure(), and ReflectionTypeAlias::getTypeStructures() are experimental features of HHVM, and not supported by Facebook or the HHVM team. This means that matches_type_structure() may need to be removed in a future release without warning.

We strongly recommend moving to TypeAssert\matches<T>() and TypeCoerce\match<T>() instead.

Installation

Usage

TypeAssert provides functions that take a mixed input, and will either return it unmodified (but with type data) or throw an exception; for example:

These include:

Coercion

TypeAssert also contains the Facebook\TypeCoerce namespace, which includes a similar set of functions:

These will do 'safe' transformations, such as int-ish strings to int, ints to strings, arrays to vecs, arrays to dicts, and so on.

TypeSpec

You can also assert/coerce complex types (except for shapes and tuples) without a type_structure:

Shapes and tuples are not supported, as they can not be expressed generically.

matches_type_structure<T>(TypeStructure<T>, mixed): T

Asserts that a variable matches the given type structure; these can be arbitrary nested shapes. This is particular useful for dealing with JSON responses.

You can use type_structure() to get a TypeStructure<T> for a type constant, or ReflectionTypeAlias::getTypeStructure() for top-level type aliases.

not_null<T>(?T): T

Throws if it's null, and refines the type otherwise - for example:

is_instance_of<T>(classname<T>, mixed): T

Asserts that the input is an object of the given type; for example:

is_classname_of<T>(classname<T>, mixed): classname<T>

Asserts that the input is the name of a child of the specified class, or implements the specified interface.

Credit

This library is a reimplementation of ideas from:

Security Issues

We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.

Facebook has a bounty program for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.

License

Type-Assert is MIT-licensed.


All versions of type-assert with dependencies

PHP Build Version
Package Version
Requires hhvm Version ^4.115
hhvm/hsl Version ^4.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 hhvm/type-assert contains the following files

Loading the files please wait ....