{"id":28236698,"url":"https://github.com/edumarques/typed-collections","last_synced_at":"2025-10-11T20:05:21.974Z","repository":{"id":167630337,"uuid":"643240206","full_name":"edumarques/typed-collections","owner":"edumarques","description":"Typed collections are an implementation of typed lists. Collections allow us to have traversable lists of a predetermined type and its subtypes. Its behavior prevents the looseness of arrays in PHP.","archived":false,"fork":false,"pushed_at":"2024-01-14T22:40:17.000Z","size":79,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"v2.x","last_synced_at":"2025-09-27T11:19:57.580Z","etag":null,"topics":["collections","php","type-safe"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/edumarques/typed-collections","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/edumarques.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-20T14:36:52.000Z","updated_at":"2025-04-28T23:25:36.000Z","dependencies_parsed_at":"2024-01-14T22:56:58.363Z","dependency_job_id":null,"html_url":"https://github.com/edumarques/typed-collections","commit_stats":null,"previous_names":["edumarques/typed-collections"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/edumarques/typed-collections","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edumarques%2Ftyped-collections","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edumarques%2Ftyped-collections/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edumarques%2Ftyped-collections/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edumarques%2Ftyped-collections/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edumarques","download_url":"https://codeload.github.com/edumarques/typed-collections/tar.gz/refs/heads/v2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edumarques%2Ftyped-collections/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008578,"owners_count":26084480,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["collections","php","type-safe"],"created_at":"2025-05-19T00:16:12.167Z","updated_at":"2025-10-11T20:05:21.960Z","avatar_url":"https://github.com/edumarques.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Typed Collections\n================\n![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/edumarques/typed-collections/php?version=v2.x-dev\u0026color=%23777BB3)\n![GitHub](https://img.shields.io/github/license/edumarques/typed-collections)\n[![edumarques](https://circleci.com/gh/edumarques/typed-collections.svg?style=shield)](https://app.circleci.com/pipelines/github/edumarques)\n[![codecov](https://codecov.io/gh/edumarques/typed-collections/branch/main/graph/badge.svg?token=ABGMyvr355)](https://codecov.io/gh/edumarques/typed-collections)\n\n## Description\n\nTyped collections are an implementation of typed lists. Collections allow us to have traversable lists of a predetermined type and its subtypes. Its behavior prevents the looseness of arrays in PHP.\n\nThis library contains four collection classes: mutable and immutable lists, and mutable and immutable dictionaries. Mutable lists/dictionaries have its internal array altered whenever we perform operations on it. Immutable lists/dictionaries generate a new instance of itself when operations are done on it.\n\n## Installation\n\n```\ncomposer require edumarques/typed-collections:2.*\n```\n\n## Basic usage\n\n```php\nuse EduardoMarques\\TypedCollections\\TypedCollection;\nuse EduardoMarques\\TypedCollections\\TypedCollectionImmutable;\nuse EduardoMarques\\TypedCollections\\Enum\\ScalarType;\nuse EduardoMarques\\TypedCollections\\Enum\\NonScalarType;\n\n$typedCollection1 = TypedCollection::create(ScalarType::INTEGER);\n$typedCollection2 = TypedCollection::create(ScalarType::STRING);\n\n$typedCollectionImmutable1 = TypedCollectionImmutable::create(NonScalarType::CALLABLE);\n$typedCollectionImmutable2 = TypedCollectionImmutable::create(\\stdClass::class);\n```\n\n```php\nuse EduardoMarques\\TypedCollections\\TypedDictionary;\nuse EduardoMarques\\TypedCollections\\TypedDictionaryImmutable;\nuse EduardoMarques\\TypedCollections\\Enum\\ScalarType;\nuse EduardoMarques\\TypedCollections\\Enum\\NonScalarType;\n\n$typedDictionary1 = TypedDictionary::create(ScalarType::INTEGER, ScalarType::STRING);\n$typedDictionary2 = TypedDictionary::create(ScalarType::STRING, ScalarType::DOUBLE);\n\n$typedDictionaryImmutable1 = TypedDictionaryImmutable::create(ScalarType::INTEGER, NonScalarType::CALLABLE);\n$typedDictionaryImmutable2 = TypedDictionaryImmutable::create(ScalarType::STRING, \\stdClass::class);\n```\n\n## Collection\n\nA PHP implementation of an array list. Its type is specified at instantiation/construction. The class will perform runtime type checks to validate the appropriate values are being added. Many of the standard array functionalities are encapsulated in this class.\n\n## Dictionary\n\nDictionaries extend Collections' functionalities. The main difference is that they work with associative arrays, where you map keys to values.\n\n## Supported types:\n\n- `ScalarType::INTEGER`\n- `ScalarType::STRING`\n- `ScalarType::BOOLEAN`\n- `ScalarType::DOUBLE`\n- `NonScalarType::ARRAY`\n- `NonScalarType::CALLABLE`\n- `class-string`\n\n## Support for abstract classes and interfaces\n\nCollections and Dictionaries will check inheritance, so if you require a base class, derived classes can be added safely.\n\n## Contributing\n\nContributors are always welcome! For more information on how you can contribute, please read our [contribution guideline](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedumarques%2Ftyped-collections","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedumarques%2Ftyped-collections","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedumarques%2Ftyped-collections/lists"}