{"id":15916885,"url":"https://github.com/xp-lang/xp-generics","last_synced_at":"2026-03-03T22:31:54.024Z","repository":{"id":62788133,"uuid":"562471101","full_name":"xp-lang/xp-generics","owner":"xp-lang","description":"XP generics for PHP","archived":false,"fork":false,"pushed_at":"2024-09-01T08:07:59.000Z","size":75,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-28T19:30:11.057Z","etag":null,"topics":["compiler-plugin","generic-types","generics","php7","php8","xp-compiler","xp-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xp-lang.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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-11-06T13:19:27.000Z","updated_at":"2024-09-01T08:08:02.000Z","dependencies_parsed_at":"2023-11-20T22:24:39.782Z","dependency_job_id":"e6179261-cee2-4e5d-ad47-9973c9389dbd","html_url":"https://github.com/xp-lang/xp-generics","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"337205b98b9d4b34b20a43e2650fab7688401d59"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/xp-lang/xp-generics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-lang%2Fxp-generics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-lang%2Fxp-generics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-lang%2Fxp-generics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-lang%2Fxp-generics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-lang","download_url":"https://codeload.github.com/xp-lang/xp-generics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-lang%2Fxp-generics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30064306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["compiler-plugin","generic-types","generics","php7","php8","xp-compiler","xp-framework"],"created_at":"2024-10-06T18:06:15.727Z","updated_at":"2026-03-03T22:31:54.004Z","avatar_url":"https://github.com/xp-lang.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"XP generics for PHP\n===================\n\n[![Build status on GitHub](https://github.com/xp-lang/xp-generics/workflows/Tests/badge.svg)](https://github.com/xp-lang/xp-generics/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-lang/xp-generics/version.svg)](https://packagist.org/packages/xp-lang/xp-generics)\n\nPlugin for the [XP Compiler](https://github.com/xp-framework/compiler/) which adds support for XP generics.\n\nExample\n-------\n\n```php\n// Declaration\nnamespace com\\example;\n\nclass PriorityQueue\u003cE\u003e {\n  private $elements;\n  private $comparator= null;\n  private $sorted= true;\n\n  public function __construct(E... $elements) {\n    $this-\u003eelements= $elements;\n  }\n\n  public function comparing(?function(E, E): int $comparator): self {\n    $this-\u003ecomparator= $comparator;\n    return $this;\n  }\n\n  public function push(E $element): void {\n    $this-\u003eelements[]= $element;\n    $this-\u003esorted= false;\n  }\n\n  public function pop(): ?E {\n    if (!$this-\u003esorted) {\n      $this-\u003ecomparator ? usort($this-\u003eelements, $this-\u003ecomparator) : sort($this-\u003eelements);\n      $this-\u003esorted= true;\n    }\n    return array_pop($this-\u003eelements);\n  }\n}\n\n\n// Usage\n$q= new PriorityQueue\u003cstring\u003e();\n$q-\u003epush('Test');\n\n$q-\u003epush(123); // lang.IllegalArgumentException\n```\n\nInstallation\n------------\nAfter installing the XP Compiler into your project, also include this plugin.\n\n```bash\n$ composer require xp-framework/compiler\n# ...\n\n$ composer require xp-lang/xp-generics\n# ...\n```\n\nNo further action is required.\n\nSee also\n--------\n* [Generics in PHP??? - PHP Annotated](https://www.youtube.com/watch?v=ffhhx5_TUB8) from August 2024\n* [State of Generics and Collections](https://thephp.foundation/blog/2024/08/19/state-of-generics-and-collections/) from August 2024\n* [XP RFC: Generics](https://github.com/xp-framework/rfc/issues/106) from January 2007\n* [XP RFC: Generics optimization](https://github.com/xp-framework/rfc/issues/193) \n* [PHP RFC: Generics](https://wiki.php.net/rfc/generics)\n* [HHVM Generics](https://docs.hhvm.com/hack/generics/introduction)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-lang%2Fxp-generics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-lang%2Fxp-generics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-lang%2Fxp-generics/lists"}