{"id":18610567,"url":"https://github.com/ixnode/php-checker","last_synced_at":"2025-11-02T21:30:24.256Z","repository":{"id":65145450,"uuid":"583684733","full_name":"ixnode/php-checker","owner":"ixnode","description":"A collection of various PHP types check classes.","archived":false,"fork":false,"pushed_at":"2023-06-25T09:31:56.000Z","size":80,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-27T01:41:39.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ixnode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-30T15:09:22.000Z","updated_at":"2023-08-21T20:39:42.000Z","dependencies_parsed_at":"2024-11-07T03:11:09.616Z","dependency_job_id":"98b7d3f5-53c0-4b75-b8f7-34def2eaf050","html_url":"https://github.com/ixnode/php-checker","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"182a5314541a27ed911895eb2db36c189c3a757c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ixnode","download_url":"https://codeload.github.com/ixnode/php-checker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239400606,"owners_count":19632051,"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":[],"created_at":"2024-11-07T03:11:05.348Z","updated_at":"2025-11-02T21:30:24.200Z","avatar_url":"https://github.com/ixnode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Checker\n\n[![Release](https://img.shields.io/github/v/release/ixnode/php-checker)](https://github.com/ixnode/php-checker/releases)\n[![PHP](https://img.shields.io/badge/PHP-^8.0-777bb3.svg?logo=php\u0026logoColor=white\u0026labelColor=555555\u0026style=flat)](https://www.php.net/supported-versions.php)\n[![PHPStan](https://img.shields.io/badge/PHPStan-Level%20Max-brightgreen.svg?style=flat)](https://phpstan.org/user-guide/rule-levels)\n[![PHPCS](https://img.shields.io/badge/PHPCS-PSR12-brightgreen.svg?style=flat)](https://www.php-fig.org/psr/psr-12/)\n[![LICENSE](https://img.shields.io/github/license/ixnode/php-checker)](https://github.com/ixnode/php-checker/blob/master/LICENSE)\n\n\u003e A collection of various PHP types check classes.\n\n## Introduction\n\nThis package is helpful to validate complex data types like complex arrays and to comply with DocBlock declarations\n(static code analysis tools like PHPStan or Psalm). Uses and throws exceptions from\n[ixnode/php-exception](https://github.com/ixnode/php-exception) as a \"one-liner\". Instead of using the following code:\n\n```php\nif (!is_array($value)) {\n    throw new TypeInvalidException('array', gettype($this-\u003evalue));\n}\n```\n\njust use this one:\n\n```php\n$checkedArray = (new Checker($value))-\u003echeckArray();\n```\n\n## Installation\n\n```bash\ncomposer require ixnode/php-checker\n```\n\n```bash\nvendor/bin/php-checker -V\n```\n\n```bash\nphp-checker 0.1.0 (12-30-2022 18:08:35) - Björn Hempel \u003cbjoern@hempel.li\u003e\n```\n\n## Usage\n\n### Example 1\n\n```php\nuse Ixnode\\PhpChecker\\Checker;\n```\n\n```php\n$array = (new Checker(.0))-\u003echeckFloat();\n```\n\n### Example 2\n\n```php\nuse Ixnode\\PhpChecker\\CheckerArray;\n```\n\n```php\n$array = (new CheckerArray([new Checker(123), new Checker(456), new Checker(678)])-\u003echeckClass(Checker::class);\n```\n\n### Example 3\n\n```php\nuse Ixnode\\PhpChecker\\CheckerClass;\n```\n\n```php\n$array = (new CheckerClass(new Checker(123)))-\u003echeck(Checker::class);\n```\n\n### Example 4\n\n```php\nuse Ixnode\\PhpChecker\\CheckerJson;\n```\n\n```php\n$array = (new CheckerJson('{\"1\": 1, \"2\": 2, \"3\": 3}'))-\u003echeck();\n```\n\n## Available checkers\n\n### Class `Ixnode\\PhpChecker\\Checker`\n\nChecks general data type specific properties.\n\n| Method                                                     | Expected input                  | Method Parameters | Output value (if passed) | Exception                                       |\n|------------------------------------------------------------|---------------------------------|-------------------|--------------------------|-------------------------------------------------|\n| `checkArray` (_Alias of_ `CheckerArray::check`)            | `array\u003cint\\|string, mixed\u003e` | `null`            | _Same as input_          | `TypeInvalidException`                          || `checkBoolean`                                  | `bool`                                                                   | `null`                         | _Same as input_                    | `TypeInvalidException`                          |\n| `checkClass` (_Alias of_ `CheckerClass::checkClass`)       | `ClassName`                     | `class-string`    | _Same as input_          | `TypeInvalidException`, `ClassInvalidException` |\n| `checkFloat`                                               | `float`                         | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkInteger`                                             | `int`                           | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkIterable`                                            | `iterable`                      | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkJson` (_Alias of_ `CheckerJson::check`)              | `json-string`                   | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkObject`                                              | `object`                        | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkStdClass` (_Alias of_ `CheckerClass::checkStdClass`) | `stdClass`                      | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkString`                                              | `string`                        | `null`            | _Same as input_          | `TypeInvalidException`                          |\n| `checkStringOrNull`                                        | `string\\|null`              | `null`            | _Same as input_          | `TypeInvalidException`                          |\n\n### Class `Ixnode\\PhpChecker\\CheckerArray`\n\nChecks array specific properties. \n\n| Method                        | Expected input                                                                                   | Method Parameters                        | Output value (if passed)                                                                    | Exception                                           |\n|-------------------------------|--------------------------------------------------------------------------------------------------|------------------------------------------|---------------------------------------------------------------------------------------------|-----------------------------------------------------|\n| `check`                       | `array\u003cint\\|string, mixed\u003e`                                                                  | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkArray`                  | `array\u003cint\\|tring, array\u003cstring, mixed\u003e\u003e`                                                   | `null` or `array\u003cint, string\u003e`           | `array\u003cint, array\u003cstring, mixed\u003e\u003e`                                                          | `TypeInvalidException`                              |\n| `checkAssoziative`            | `array\u003cstring, mixed\u003e`                                                                           | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkClass`                  | `array\u003cint\\|string, ClassName\u003e`                                                              | `class-string`                           | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkFlat`                   | `array\u003cint\\|string, bool\\|float\\|int\\|string\\|null\u003e`                         | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkSequential`             | `array\u003cint, mixed\u003e`                                                                              | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkString`                 | `array\u003cint\\|string, string\u003e`                                                                 | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkStringOrNull`           | `array\u003cint\\|string, string\\|null\u003e`                                                       | `null`                                   | _Same as input_                                                                             | `TypeInvalidException`                              |\n| `checkIndex`                  | `array\u003cint\\|;string, mixed\u003e`                                                                  | `string`                                 | `mixed` (_index of given_)                                                                  | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArray`             | `array\u003cint\\|string, array\u003cint\\|string, mixed\u003e\u003e`                                          | `string`                                 | `array\u003cint\\|string, mixed\u003e` (_index of given_)                                          | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayArray`        | `array\u003cint\\|string, array\u003cint\\|string, array\u003cstring, mixed\u003e\u003e\u003e`                           | `string`, `null` or `array\u003cint, string\u003e` | `array\u003cint, array\u003cstring, mixed\u003e\u003e` (_index of given_)                                       | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayAssoziative`  | `array\u003cint\\|string, array\u003cstring, mixed\u003e\u003e`                                                   | `string`                                 | `array\u003cstring, mixed\u003e` (_index of given_)                                                   | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayClass`        | `array\u003cint\\|string, array\u003cint\\|string, ClassName\u003e\u003e`                                      | `string`                                 | `array\u003cint\\|string, ClassName\u003e` (_index of given_)                                      | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayFlat`         | `array\u003cint\\|string, array\u003cint\\|string, bool\\|float\\|int\\|string\\|null\u003e\u003e` | `string`                                 | `array\u003cint\\|string, bool\\|float\\|int\\|string\\|null\u003e` (_index of given_) | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArraySequential`   | `array\u003cint\\|string, array\u003cint, mixed\u003e\u003e`                                                      | `string`                                 | `array\u003cint, string\u003e` (_index of given_)                                                     | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayString`       | `array\u003cint\\|string, array\u003cint\\|string, string\u003e\u003e`                                         | `string`                                 | `array\u003cint\\|string, string\u003e` (_index of given_)                                         | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexArrayStringOrNull` | `array\u003cint\\|string, array\u003cint\\|string, string\\|null\u003e\u003e`                               | `string`                                 | `array\u003cint\\|string, string\\|null\u003e` (_index of given_)                               | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexInteger`           | `array\u003cint\\|string, int\u003e`                                                                    | `string`                                 | `int` (_index of given_)                                                                    | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexString`            | `array\u003cint\\|string, string\u003e`                                                                 | `string`                                 | `string` (_index of given_)                                                                 | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n| `checkIndexStringOrNull`      | `array\u003cint\\|string, string\\|null\u003e`                                                       | `string`                                 | `string\\|null` (_index of given_)                                                       | `TypeInvalidException`, `ArrayKeyNotFoundException` |\n\n### Class `Ixnode\\PhpChecker\\CheckerClass`\n\nChecks class specific properties.\n\n| Method          | Expected input | Method Parameters | Output value (if passed) | Exception                                       |\n|-----------------|----------------|-------------------|--------------------------|-------------------------------------------------|\n| `checkClass`    | `ClassName`    | `class-string`    | _Same as input_          | `TypeInvalidException`, `ClassInvalidException` |\n| `checkStdClass` | `stdClass`     | `null`            | _Same as input_          | `TypeInvalidException`                          |\n\n### Class `Ixnode\\PhpChecker\\CheckerJson`\n\nChecks JSON specific properties.\n\n| Method   | Expected input | Method Parameters | Output value (if passed) | Exception              |\n|----------|----------------|-------------------|--------------------------|------------------------|\n| `check`  | `json-string`  | `null`            | _Same as input_          | `TypeInvalidException` |\n| `isJson` | `json-string`  | `null`            | `bool`                   | `null`                 |\n\n## Development\n\n```bash\ngit clone git@github.com:ixnode/php-checker.git \u0026\u0026 cd php-checker\n```\n\n```bash\ncomposer install\n```\n\n```bash\ncomposer test\n```\n\n## License\n\nThis tool is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fixnode%2Fphp-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fixnode%2Fphp-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fixnode%2Fphp-checker/lists"}