Download the PHP package dgame/php-cast without Composer

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

Type Assumptions & Assertions simplified

Have you ever had to validate user data? Probably you have used something like webmozarts/assert:

The problem is, even though we checked that $id must be an int, it is actually still seen as mixed (see this example for phpstan). To change this, you need to write / use your own phpstan rule that makes phpstan believe that it will now always be an int. So if you use your own verification methods, you must also write / use your own phpstan rules.

This package tries to simplify that. To verify that something is an int, you can assume that it must be an int. If it is not, you get null:

With this, $id is of type int|null for phpstan, psalm, phpstorm and so on.

If you want to assert that it is an int, you can do that too by using:

Now $id is of type int or it fails with an AssertionError. A message for the AssertionError can also be optionally set:

You can do that for array values.


int

intify

With intify you get either the int-value or the int-casted scalar value, if any:

unsigned

unsigned will return a non-null value, if the given value is a number that is >= 0.

positive

positive will return a non-null value, if the given value is a number that is > 0.

negative

negative will return a non-null value, if the given value is a number that is < 0.

float

floatify

With floatify you get either the float-value or the float-casted scalar value, if any:

bool

With bool you get the bool-value for true, false, 1, 0, on, off, yes, no or null.

boolify

With boolify you get either the bool-value or the bool-casted scalar value, if any:

string

stringify

With stringify you get either the string-value or the string-casted scalar value, if any:

number

With number you get either the int or float-value or null, if it is neither.

scalar

With scalar you get either the int, float, bool or string-value or null, if it is neither.

array

With collection you can test whether your value is an array:

And with collectionOf you can test whether your value is an array of type T:

If not all values in the array are of type int, you get null. If you just want to filter the non-int values, you can do that by using filter:

But be aware that filter expects an array<int|string, mixed> as input and not mixed!

list

If you want to make sure, that you have a list of values (and not an assoc. array) you can use listOf:

map

If you want to make sure, that you have an assoc. array (and not a list) you can use mapOf:


All versions of php-cast with dependencies

PHP Build Version
Package Version
Requires php Version ^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 dgame/php-cast contains the following files

Loading the files please wait ....