{"id":19237148,"url":"https://github.com/extalionlab/php-strict-array","last_synced_at":"2025-07-01T23:07:08.834Z","repository":{"id":56980631,"uuid":"214271568","full_name":"eXtalionLab/php-strict-array","owner":"eXtalionLab","description":"Generator of strict arrays (vector, map)","archived":false,"fork":false,"pushed_at":"2019-12-18T21:42:02.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T23:07:07.101Z","etag":null,"topics":["array","collections","map","php","strict","strict-types","vector"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eXtalionLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-10T19:45:20.000Z","updated_at":"2023-12-13T21:56:01.000Z","dependencies_parsed_at":"2022-08-21T10:50:23.740Z","dependency_job_id":null,"html_url":"https://github.com/eXtalionLab/php-strict-array","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/eXtalionLab/php-strict-array","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXtalionLab%2Fphp-strict-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXtalionLab%2Fphp-strict-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXtalionLab%2Fphp-strict-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXtalionLab%2Fphp-strict-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eXtalionLab","download_url":"https://codeload.github.com/eXtalionLab/php-strict-array/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eXtalionLab%2Fphp-strict-array/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263047676,"owners_count":23405280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","collections","map","php","strict","strict-types","vector"],"created_at":"2024-11-09T16:25:00.110Z","updated_at":"2025-07-01T23:07:08.791Z","avatar_url":"https://github.com/eXtalionLab.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prepare for future with php-strict-array\n\nAccording to this [article](https://www.sitepoint.com/creating-strictly-typed-arrays-collections-php/)\nwhich shows how to create strictly typed arrays and collections in Php7,\nphp-strict-array was born.\n\n---\n\nThere is some [discusion](https://wiki.php.net/rfc/generic-arrays) about\ngeneric in Php but who knows when it comes to us.\n\nIt is not exacly what you know from **Java** or **C++** where generic looks like\n`array\u003cbool\u003e()` or `array\u003cstring, \\Foo\\User\u003e()`.\n\nHere strict arrays looks like `array_int_`, `array_bool_` and\n`array_string_and_float_` so I hope when they come to nativ Php all what you\nneed to do will be:\n1. Replace all `new array_User`, `new array_string_and_array_object__` to\n`array\u003cUser\u003e`, `array\u003cstring, array\u003cobject\u003e\u003e`.\n\nNow you do not have to validate array from user inside your packages:\n\n```php\nfunction foo(array $users)\n{\n    foreach ($users as $user) {\n        if (!$user instanceof User) {\n            thorw new \\InvalidArgumentException();\n        }\n    }\n\n    ...\n}\n```\n\nYour code can be much simpler:\n\n```php\nfunction foo(array_User_ $users)\n{\n    ...\n}\n```\n\n## Install\n\n```bash\ncomposer require eXtalion/php-strict-array\n```\n\n## Base strict arrays\n\nSome base arrays are generated:\n- `array_array_`,\n- `array_bool_`,\n- `array_callable_`,\n- `array_float_`,\n- `array_int_`,\n- `array_iterable_`,\n- `array_object_`,\n- `array_string_`,\n- `array_string_and_array_`,\n- `array_string_and_bool_`,\n- `array_string_and_callable_`,\n- `array_string_and_float_`,\n- `array_string_and_int_`,\n- `array_string_and_iterable_`,\n- `array_string_and_object_`,\n- `array_string_and_string_`.\n\n## Create new strict array\n\nRun:\n\n```\nvendor/bin/php-sa [path/to/arrays-dir]\n```\n\nand answer to fee questions. Without **path/to/arrays-dir** code will be display to\nSTDOUT.\n\n## It's \"normal\" array\n\nThere are some array functions which works with strict arrays:\n- `sarray_filter`,\n- `sarray_key_exists`,\n- `sarray_keys`,\n- `sarray_search`,\n- `sarray_values`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextalionlab%2Fphp-strict-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextalionlab%2Fphp-strict-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextalionlab%2Fphp-strict-array/lists"}