Download the PHP package squirrelphp/scalar-types without Composer

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

Squirrel Scalar Types

Packagist Version PHP Version

Make the coercive mode and strict mode behavior of PHP accessible explicitly via functions: Includes coercions and is_coerceable checks that work like the implicit scalar type coercions in PHP, and an easy way to enforce a specific scalar type mimicking the behavior of strict mode in PHP.

Installation

composer require squirrelphp/scalar-types

Table of contents

Test if value can be coerced

All these functions have one mixed argument $value and return true or false:

is_coerceable_to_int

Returns true if $value is one of the following:

For any other values it returns false.

is_coerceable_to_float

Returns true if $value is one of the following:

For any other values it returns false.

is_coerceable_to_bool

Returns true if $value is one of the following:

For any other values it returns false.

is_coerceable_to_string

Returns true if $value is one of the following:

For any other values it returns false.

Coerce value

All these functions have one mixed argument $value and return the type they are coercing to, following the same logic as implicit type coercions in PHP.

coerce_to_int

Coerce a value like PHP 8.2 would do it, which can lead to a TypeError for non-scalar and non-numeric values and a deprecation notice for a float or numeric string with a fractional part.

coerce_to_float

Coerce a value like PHP 8.2 would do it, which can lead to a TypeError for non-scalar and non-numeric values.

coerce_to_bool

Coerce a value like PHP 8.2 would do it, which can lead to a TypeError for non-scalar values and a deprecation notice for values other than "", "0", "1", 0, 1, 0.0 and 1.0.

coerce_to_string

Coerce a value like PHP 8.2 would do it, which can lead to a TypeError for non-scalar values except if it is an object that implements the magic __toString method.

Enforce a type for a value

All these functions have one mixed argument $value and return the type they are enforcing, according to the same logic as strict mode in PHP.

enforce_int

Returns $value as an integer if it is an integer. Throws a TypeError otherwise.

enforce_float

Returns $value as a float if it is an integer or a float. Throws a TypeError otherwise.

enforce_bool

Returns $value as a boolean if it is a boolean. Throws a TypeError otherwise.

enforce_string

Returns $value as a string if it is a string. Throws a TypeError otherwise.


All versions of scalar-types with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 squirrelphp/scalar-types contains the following files

Loading the files please wait ....