{"id":36311101,"url":"https://github.com/typhoon-php/type","last_synced_at":"2026-03-01T23:02:41.256Z","repository":{"id":87421308,"uuid":"606811357","full_name":"typhoon-php/type","owner":"typhoon-php","description":"Typhoon Type System","archived":false,"fork":false,"pushed_at":"2026-02-11T00:12:03.000Z","size":814,"stargazers_count":64,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"0.8.x","last_synced_at":"2026-02-11T03:36:42.649Z","etag":null,"topics":["php","php-library"],"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/typhoon-php.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://www.tinkoff.ru/cf/5MqZQas2dk7"]}},"created_at":"2023-02-26T16:31:39.000Z","updated_at":"2026-02-11T00:12:08.000Z","dependencies_parsed_at":"2024-02-22T01:27:44.296Z","dependency_job_id":"d438a194-ce3a-4c44-b3b5-6d3012c95989","html_url":"https://github.com/typhoon-php/type","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"b724ad5fb73f711a9f62273c67547c616b74b327"},"previous_names":["typhoon-php/type","php-extended-type-system/type"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/typhoon-php/type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typhoon-php%2Ftype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typhoon-php%2Ftype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typhoon-php%2Ftype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typhoon-php%2Ftype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typhoon-php","download_url":"https://codeload.github.com/typhoon-php/type/tar.gz/refs/heads/0.8.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typhoon-php%2Ftype/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29987656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T22:42:38.399Z","status":"ssl_error","status_checked_at":"2026-03-01T22:41:51.863Z","response_time":124,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php","php-library"],"created_at":"2026-01-11T10:56:15.374Z","updated_at":"2026-03-01T23:02:41.251Z","avatar_url":"https://github.com/typhoon-php.png","language":"PHP","funding_links":["https://www.tinkoff.ru/cf/5MqZQas2dk7"],"categories":[],"sub_categories":[],"readme":"# Typhoon Type\n\n[![PHP Version Requirement](https://img.shields.io/packagist/dependency-v/typhoon/type/php)](https://packagist.org/packages/typhoon/type)\n[![GitHub Release](https://img.shields.io/github/v/release/typhoon-php/type)](https://github.com/typhoon-php/type/releases)\n[![PHPStan](https://img.shields.io/badge/phpstan%20level-max-brightgreen.svg?style=flat\u0026logo=php)](phpstan.dist.neon)\n[![Code Coverage](https://codecov.io/gh/typhoon-php/type/branch/0.8.x/graph/badge.svg)](https://codecov.io/gh/typhoon-php/type/tree/0.8.x)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Ftyphoon-php%2Ftype%2F0.8.x)](https://dashboard.stryker-mutator.io/reports/github.com/typhoon-php/type/0.8.x)\n\nTyphoon Type is an object abstraction over the modern PHP type system. Use this library to build tools that work with\nsophisticated types:\n\n```php\nuse function Typhoon\\Type\\arrayShapeT;\nuse function Typhoon\\Type\\objectT;\nuse function Typhoon\\Type\\nonEmptyListT;\n\n$json = \u003c\u003c\u003cJSON\n    {\n        \"people\": [\n            {\"name\": \"Valentin\"},\n            {\"name\": \"Andrey\"}\n        ],\n    }\n    JSON;\n    \nfinal readonly class Person\n{\n    public function __construct(\n        public string $name,\n    ) {}    \n}\n\n$type = arrayShapeT([\n    'people' =\u003e nonEmptyListT(objectT(Person::class)),\n]);\n\n$request = new Mapper()-\u003emap($json, $type);\n```\n\n## Installation\n\n```\ncomposer require typhoon/type\n```\n\n## Printing types\n\nTo print any type, use `stringify()`:\n\n```php\nuse function Typhoon\\Type\\stringify;\n\n$type = arrayShapeT([\n    'people' =\u003e nonEmptyListT(objectT(Person::class)),\n]);\n\nvar_dump(stringify($type));\n\n// array{'people': non-empty-list\u003cPerson\u003e}\n```\n\n## Supported types\n\n### Native\n\n| Typhoon                                                                 | Native                  |\n|-------------------------------------------------------------------------|-------------------------|\n| `nullT`                                                                 | `null`                  |\n| `voidT`                                                                 | `void`                  |\n| `neverT`                                                                | `never`                 |\n| `falseT`                                                                | `false`                 |\n| `trueT`                                                                 | `true`                  |\n| `boolT`                                                                 | `bool`                  |\n| `intT`                                                                  | `int`                   |\n| `floatT`                                                                | `float`                 |\n| `stringT`                                                               | `string`                |\n| `arrayT`                                                                | `array`                 |\n| `objectT`                                                               | `object`                |\n| `objectT(Foo::class)`                                                   | `Foo`                   |\n| `selfT`                                                                 | `self`                  |\n| `parentT`                                                               | `parent`                |\n| `staticT`                                                               | `static`                |\n| `iterableT`                                                             | `iterable`              |\n| `callableT`                                                             | `callable`              |\n| `resourceT`                                                             | `resource`              |\n| `nullOrT(stringT)`                                                      | `?string`               |\n| `unionT(intT, stringT)`                                                 | `int\\|string`           |\n| `intersectionT(objectT(Countable::class), objectT(Traversable::class))` | `Countable\u0026Traversable` |\n| `mixedT`                                                                | `mixed`                 |\n\n### PHPDoc numbers\n\n| Typhoon                                            | PHPDoc                    |\n|----------------------------------------------------|---------------------------|\n| `intT(123)`                                        | `123`                     |\n| `positiveIntT`                                     | `positive-int`            |\n| `negativeIntT`                                     | `negative-int`            |\n| `nonPositiveIntT`                                  | `non-positive-int`        |\n| `nonNegativeIntT`                                  | `non-negative-int`        |\n| `nonZeroIntT`                                      | `non-zero-int`            |\n| `intRangeT(-5, 6)`                                 | `int\u003c-5, 6\u003e`              |\n| `intRangeT(max: 6)`                                | `int\u003cmin, 6\u003e`             |\n| `intRangeT(min: -5)`                               | `int\u003c-5, max\u003e`            |\n| `intMaskT(1, 2, 4)`                                | `int-mask\u003c1, 2, 4\u003e`       |\n| `intMaskT(classConstantMaskT(Foo::class, 'INT_*')` | `int-mask-of\u003cFoo::INT_*\u003e` |\n| `floatT(12.5)`                                     | `12.5`                    |\n| `floatRangeT(-0.001, 2.344)`                       | `float\u003c-0.001, 2.344\u003e`    |\n\n### PHPDoc strings\n\n| Typhoon                                                                         | PHPDoc                              |\n|---------------------------------------------------------------------------------|-------------------------------------|\n| `nonEmptyStringT`                                                               | `non-empty-string`                  |\n| `truthyStringT`, `nonFalsyStringT`                                              | `truthy-string`, `non-falsy-string` |\n| `numericStringT`                                                                | `numeric-string`                    |\n| `lowercaseString`                                                               | `lowercase-string`                  |\n| `stringT('abc')`                                                                | `'abc'`                             |\n| `classT(Foo::class)`, `classStringT(Foo::class)`, `classT(objectT(Foo::class))` | `class-string\u003cFoo\u003e`                 |\n| `stringT(Foo::class)`, `classConstantT(Foo::class, 'class')`                    | `Foo::class`                        |\n| `literalStringT`                                                                | `literal-string`                    |\n\n### PHPDoc constants\n\n| Typhoon                                  | PHPDoc        |\n|------------------------------------------|---------------|\n| `constantT('PHP_INT_MAX')`               | `PHP_INT_MAX` |\n| `constantMaskT('JSON_*')`                | `JSON_*`      |\n| `classConstantT(Foo::class, 'BAR')`      | `Foo::BAR`    |\n| `classConstantMaskT(Foo::class, 'IS_*')` | `Foo::IS_*`   |\n\n### PHPDoc arrays and iterables\n\n| Typhoon                                         | PHPDoc                               |\n|-------------------------------------------------|--------------------------------------|\n| `arrayT(value: objectT(Foo::class))`            | `Foo[]`                              |\n| `listT(stringT)`                                | `list\u003cstring\u003e`                       |\n| `nonEmptyListT(stringT)`                        | `non-empty-list\u003cstring\u003e`             |\n| `listShapeT([intT, stringT])`                   | `list{int, string}`                  |\n| `arrayShapeT([intT, optional(stringT)])`        | `list{int, 1?: string}`              |\n| `unsealedListShapeT([intT])`                    | `list{int, ...}`                     |\n| `unsealedListShapeT([intT], stringT)`           | `list{int, ...\u003cstring\u003e}`             |\n| `arrayT(value: stringT)`                        | `array\u003cstring\u003e`                      |\n| `arrayT(intT, stringT)`                         | `array\u003cint, string\u003e`                 |\n| `nonEmptyArrayT(arrayKeyT, stringT)`            | `non-empty-array\u003carray-key, string\u003e` |\n| `arrayShapeT()`                                 | `array{}`                            |\n| `arrayShapeT([intT, stringT])`                  | `array{int, string}`                 |\n| `arrayShapeT([intT, 'a' =\u003e optional(stringT)])` | `array{int, a?: string}`             |\n| `unsealedArrayShapeT([intT])`                   | `array{int, ...}`                    |\n| `unsealedArrayShapeT([floatT], intT, stringT)`  | `array{float, ...\u003cint, string\u003e}`     |\n| `keyOfT(classConstantT(Foo::class, 'ARRAY'))`   | `key-of\u003cFoo::ARRAY\u003e`                 |\n| `valueOfT(classConstantT(Foo::class, 'ARRAY'))` | `value-of\u003cFoo::ARRAY\u003e`               |\n| `offsetT($TArray-\u003etype, $TKey-\u003etype)`           | `TArray[TKey]`                       |\n| `iterableT(objectT, stringT)`                   | `iterable\u003cobject, string\u003e`           |\n| `iterableT(value: stringT)`                     | `iterable\u003cstring\u003e`                   |\n\n### PHPDoc objects\n\n| Typhoon                                        | PHPDoc                  |\n|------------------------------------------------|-------------------------|\n| `objectT(Foo::class, [stringT, floatT])`       | `Foo\u003cstring, float\u003e`    |\n| `selfT([stringT, floatT])`                     | `self\u003cstring, float\u003e`   |\n| `parentT([stringT, floatT])`                   | `parent\u003cstring, float\u003e` |\n| `staticT([stringT, floatT])`                   | `static\u003cstring, float\u003e` |\n| `objectShapeT(['prop' =\u003e stringT])`            | `object{prop: string}`  |\n| `objectShapeT(['prop' =\u003e optional(stringT))])` | `object{prop?: string}` |\n\n### PHPDoc callables\n\n| Typhoon                                       | PHPDoc                       |\n|-----------------------------------------------|------------------------------|\n| `callableT([stringT], voidT)`                 | `callable(string): void`     |\n| `callableT([param(stringT, default: true)])`  | `callable(string=): mixed`   |\n| `callableT([param(stringT, variadic: true)])` | `callable(string...): mixed` |\n| `callableT([param(stringT, byRef: true)])`    | `callable(string\u0026): mixed`   |\n| `closureT([stringT], voidT)`                  | `Closure(string): void`      |\n| `closureT([param(stringT, default: true)])`   | `Closure(string=): mixed`    |\n| `closureT([param(stringT, variadic: true)])`  | `Closure(string...): mixed`  |\n| `closureT([param(stringT, byRef: true)])`     | `Closure(string\u0026): mixed`    |\n\n### Union aliases\n\n| Typhoon     | PHPDoc      |\n|-------------|-------------|\n| `array-key` | `arrayKeyT` |\n| `numericT`  | `numeric`   |\n| `scalarT`   | `scalar`    |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyphoon-php%2Ftype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyphoon-php%2Ftype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyphoon-php%2Ftype/lists"}