{"id":18407531,"url":"https://github.com/simplecomplex/php-explorable","last_synced_at":"2025-04-12T21:14:12.826Z","repository":{"id":57051276,"uuid":"273508438","full_name":"simplecomplex/php-explorable","owner":"simplecomplex","description":"Foreach'ing protected members made simple","archived":false,"fork":false,"pushed_at":"2021-04-19T10:32:43.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-02-16T04:42:40.476Z","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/simplecomplex.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}},"created_at":"2020-06-19T14:06:08.000Z","updated_at":"2021-04-19T06:16:52.000Z","dependencies_parsed_at":"2022-08-24T03:40:51.213Z","dependency_job_id":null,"html_url":"https://github.com/simplecomplex/php-explorable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplecomplex%2Fphp-explorable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplecomplex%2Fphp-explorable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplecomplex%2Fphp-explorable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplecomplex%2Fphp-explorable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplecomplex","download_url":"https://codeload.github.com/simplecomplex/php-explorable/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631682,"owners_count":21136562,"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-06T03:14:24.026Z","updated_at":"2025-04-12T21:14:12.803Z","avatar_url":"https://github.com/simplecomplex.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# (PHP) Explorable\n\u003csmall\u003ecomposer namespace: simplecomplex/**explorable**\u003c/small\u003e\n\n## Foreach'ing protected members made simple\n\nAn interface, base class and traits making it a breeze to expose a class'\nprotected members.\n\nExtending `Explorable` facilitates:\n- `isset()`\n- `count()`\n- `foreach (...`\n- `var_dump()`\n- `toObject()`, `toArray()`\n- `json_encode()`\n\n## Usage\n\n### Class declaring it's properties\nProperty names hardcoded in constant `EXPLORABLE_VISIBLE`.\n```php\n\u003c?php\n\nuse SimpleComplex\\Explorable\\Explorable;\nuse SimpleComplex\\Explorable\\ExplorableTrait;\n\n/**\n * @property-read string $foo\n * @property-read string $bar\n */\nclass ExplorablesDeclared extends Explorable\n{\n    use ExplorableTrait;\n\n    public const EXPLORABLE_VISIBLE = [\n        'foo' =\u003e true,\n        'bar' =\u003e true,\n    ];\n\n    protected string $foo;\n\n    protected string $bar;\n}\n```\n\n### Class relying on property table discovery\nThe properties will be discovered on-demand, via `explorablePrepare()`.\n\nAll instance vars must be nullable and declared as null\n(`protected ?string $foo = null;`).\u003cbr\u003e\nOtherwise risk of getting \"_::$foo must not be accessed before initialization_\"\nerror, or the instance vars simply won't get discovered (because not set to a\nvalue (null)).\n\n```php\n\u003c?php\n\nuse SimpleComplex\\Explorable\\Explorable;\nuse SimpleComplex\\Explorable\\ExplorableTrait;\n\n/**\n * @property-read string $foo\n * @property-read string $bar\n */\nclass ExplorablesDiscoverable extends Explorable\n{\n    use ExplorableTrait;\n\n    protected ?string $foo = null;\n\n    protected ?string $bar = null;\n}\n```\n\n## MIT licensed\n\n[License and copyright](https://github.com/simplecomplex/php-explorable/blob/master/LICENSE).\n[Explained](https://tldrlegal.com/license/mit-license).\n\n## Requirements ##\n\n- PHP ^7.4 || ^8.0\n\n### Development (require-dev)\n\n- phpunit ^8 || ^9","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplecomplex%2Fphp-explorable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplecomplex%2Fphp-explorable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplecomplex%2Fphp-explorable/lists"}