{"id":18598478,"url":"https://github.com/backendtea/assert","last_synced_at":"2025-05-16T14:12:02.598Z","repository":{"id":128874628,"uuid":"257683456","full_name":"BackEndTea/Assert","owner":"BackEndTea","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-11T16:50:58.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-17T23:48:17.086Z","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/BackEndTea.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-21T18:37:06.000Z","updated_at":"2024-11-04T21:56:33.000Z","dependencies_parsed_at":"2023-04-16T03:49:00.723Z","dependency_job_id":null,"html_url":"https://github.com/BackEndTea/Assert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackEndTea%2FAssert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackEndTea%2FAssert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackEndTea%2FAssert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BackEndTea%2FAssert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BackEndTea","download_url":"https://codeload.github.com/BackEndTea/Assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544157,"owners_count":22088808,"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-07T01:32:54.523Z","updated_at":"2025-05-16T14:12:02.570Z","avatar_url":"https://github.com/BackEndTea.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assert\n\nStatic analysis safe type assertions, trough callbacks.\n\n## Usage\n\nThe `BackEndTea\\Assert\\Assert` class provides four methods:\n\n* `Assert::either(callable(mixed): TOne, callable(mixed): TTwo): callable(mixed): TOne|TTwo`\n* `Assert::both(callable(mixed): TOne, callable(mixed): TTwo): callable(mixed): TOne\u0026TTwo`\n* `Assert::not(callable(mixed): T): callable(mixed): ~T`\n* `Assert::all(callable(mixed): T): callable(array\u003cmixed\u003e): array\u003cT\u003e`\n\nThese methods are understood by static analysis tools capable of parsing template types (like Psalm \u0026 PHPStan).\nCurrently the `not` method is not understood by these tools.\n\nCallable to use are provided by the `Type` class, for example: `Type::string()` will return a callable that validates strings.\nYou can create your own callbacks, and those should be understood by the tooling, as long as your annotations are correct.\n\nNote that this library differs, in that it returns the validated value. Using this new value will make the tooling understand what it is.\n\n```php\nuse BackEndTea\\Assert\\Assert;\nuse BackEndTea\\Assert\\Type;\n\n/**\n * @param mixed $input\n */\nfunction($input): ?string   \n{\n    $callable = Assert::either(\n        Type::string(),\n        Type::null()\n    );\n    return $callable($input);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendtea%2Fassert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbackendtea%2Fassert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbackendtea%2Fassert/lists"}