Download the PHP package extalion/php-strict-array without Composer
On this page you can find all versions of the php package extalion/php-strict-array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download extalion/php-strict-array
More information about extalion/php-strict-array
Files in extalion/php-strict-array
Package php-strict-array
Short Description Generator for generic arrays (vector, map)
License MIT
Informations about the package php-strict-array
Prepare for future with php-strict-array
According to this article which shows how to create strictly typed arrays and collections in Php7, php-strict-array was born.
There is some discusion about generic in Php but who knows when it comes to us.
It is not exacly what you know from Java or C++ where generic looks like
array<bool>()
or array<string, \Foo\User>()
.
Here strict arrays looks like array_int_
, array_bool_
and
array_string_and_float_
so I hope when they come to nativ Php all what you
need to do will be:
- Replace all
new array_User
,new array_string_and_array_object__
toarray<User>
,array<string, array<object>>
.
Now you do not have to validate array from user inside your packages:
Your code can be much simpler:
Install
Base strict arrays
Some base arrays are generated:
array_array_
,array_bool_
,array_callable_
,array_float_
,array_int_
,array_iterable_
,array_object_
,array_string_
,array_string_and_array_
,array_string_and_bool_
,array_string_and_callable_
,array_string_and_float_
,array_string_and_int_
,array_string_and_iterable_
,array_string_and_object_
,array_string_and_string_
.
Create new strict array
Run:
and answer to fee questions. Without path/to/arrays-dir code will be display to STDOUT.
It's "normal" array
There are some array functions which works with strict arrays:
sarray_filter
,sarray_key_exists
,sarray_keys
,sarray_search
,sarray_values
.
All versions of php-strict-array with dependencies
extalion/php-enum Version ^0.1
symfony/console Version ^5.0
twig/twig Version ^2.12