{"id":13545517,"url":"https://github.com/bramus/reflection","last_synced_at":"2025-04-14T22:34:06.827Z","repository":{"id":62496666,"uuid":"186362496","full_name":"bramus/reflection","owner":"bramus","description":"A library that tries to make PHP's built-in Reflection better.","archived":false,"fork":false,"pushed_at":"2021-12-07T22:31:21.000Z","size":17,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T10:54:21.013Z","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/bramus.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}},"created_at":"2019-05-13T06:55:18.000Z","updated_at":"2025-01-16T07:23:25.000Z","dependencies_parsed_at":"2022-11-02T11:45:49.735Z","dependency_job_id":null,"html_url":"https://github.com/bramus/reflection","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/bramus%2Freflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Freflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Freflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramus%2Freflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramus","download_url":"https://codeload.github.com/bramus/reflection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248973325,"owners_count":21191943,"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-08-01T11:01:04.716Z","updated_at":"2025-04-14T22:34:01.796Z","avatar_url":"https://github.com/bramus.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# `bramus/reflection`\n\n[![Build Status](https://github.com/bramus/reflection/workflows/CI/badge.svg)](https://github.com/bramus/reflection/actions) [![Source](http://img.shields.io/badge/source-bramus/reflection-blue.svg?style=flat-square)](https://github.com/bramus/reflection) [![Version](https://img.shields.io/packagist/v/bramus/reflection.svg?style=flat-square)](https://packagist.org/packages/bramus/reflection) [![Downloads](https://img.shields.io/packagist/dt/bramus/reflection.svg?style=flat-square)](https://packagist.org/packages/bramus/reflection/stats) [![License](https://img.shields.io/packagist/l/bramus/reflection.svg?style=flat-square)](https://github.com/bramus/reflection/blob/master/LICENSE)\n\n`bramus/reflection` is a library that tries to make [PHP's built-in Reflection](https://www.php.net/manual/en/book.reflection.php) better.\n\nBuilt by Bram(us) Van Damme _([https://www.bram.us](https://www.bram.us))_ and [Contributors](https://github.com/bramus/reflection/graphs/contributors)\n\n## Prerequisites/Requirements\n\n- PHP 7.2 or greater\n\n## Installation\n\nInstallation is possible using Composer\n\n```\n$ composer require bramus/reflection ~1.0\n```\n\n## Usage\n\n### A note\n\nAll classes in `bramus/reflection` extend PHP's built-in versions. Therefore they have all of the functions like their parent class:\n\n- `\\Bramus\\Reflection\\ReflectionClass` extends [PHP's built-in `ReflectionClass`](https://www.php.net/manual/en/class.reflectionclass.php).\n- `\\Bramus\\Reflection\\ReflectionClassConstant` extends [PHP's built-in `ReflectionClassConstant`](https://www.php.net/manual/en/class.reflectionclassconstant.php).\n\n### `ReflectionClass`\n\nWhen compared to `\\ReflectionClass`, `\\Bramus\\Reflection\\ReflectionClass` works exactly the same, but will:\n\n- Return an associative array containing `\\Bramus\\Reflection\\ReflectionClassConstant` instances _(instead of simple values)_ when calling [`getConstants()`](https://www.php.net/manual/en/reflectionclass.getconstants.php).\n- Return a `\\Bramus\\Reflection\\ReflectionClassConstant` instance _(instead of simple value)_ when calling [`getConstant()`](https://www.php.net/manual/en/reflectionclass.getconstant.php).\n\nHere's an example comparing `getConstant()`;\n\n- Using PHP's built-in `ReflectionClass`:\n\n\t```php\n\tclass Weekday\n\t{\n\t\t/**\n\t\t * Monday\n\t\t */\n\t\tconst MONDAY = 1;\n\n\t\t/**\n\t\t * Tuesday\n\t\t */\n\t\tconst TUESDAY = …\n\t}\n\n\t$reflected = new \\ReflectionClass(Weekday::class);\n\t$constant = $reflected-\u003egetConstant('MONDAY');\n\n\tvar_dump($constant);\n\t// int(1)\n\t```\n\n- Using `\\Bramus\\Reflection\\ReflectionClass`:\n\n\t```php\n\tclass Weekday\n\t{\n\t\t/**\n\t\t * Monday\n\t\t */\n\t\tconst MONDAY = 1;\n\n\t\t/**\n\t\t * Tuesday\n\t\t */\n\t\tconst TUESDAY = …\n\t}\n\n\t$reflected = new \\Bramus\\Reflection\\ReflectionClass(Weekday::class);\n\t$constants = $reflected-\u003egetConstant('MONDAY');\n\n\tvar_dump($constant);\n\t// object(Bramus\\Reflection\\ReflectionClassConstant)#40 (2) {\n\t//   [\"name\"]=\u003e\n\t//   string(6) \"MONDAY\"\n\t//   [\"class\"]=\u003e\n\t//   string(7) \"Weekday\"\n\t//   [\"docComment\":\"Bramus\\Reflection\\ReflectionClassConstant\":private]=\u003e\n\t//   object(phpDocumentor\\Reflection\\DocBlock)#86 (7) {\n\t//     …\n\t//   }\n\t// }\n\t```\n\n### `ReflectionClassConstant`\n\nWhen compared to `\\ReflectionClassConstant`, `\\Bramus\\Reflection\\ReflectionClassConstant` works exactly the same, but will:\n\n- Return a `\\phpDocumentor\\Reflection\\DocBlock` instance _(instead of a string)_ when calling [`getDocComment()`](https://www.php.net/manual/en/reflectionclassconstant.getdoccomment.php)\n- Provide you with a `getDocCommentString()` method in case you want to access the contents as [`\\ReflectionClassConstant::getDocComment()`](https://www.php.net/manual/en/reflectionclassconstant.getdoccomment.php) would return\n- Provide you with a `getSummary()` shorthand, directly on the `\\Bramus\\Reflection\\ReflectionClassConstant` instance.\n- Provide you with a `getDescription()` shorthand, directly on the `\\Bramus\\Reflection\\ReflectionClassConstant` instance.\n\n\n### Other Reflection Classes\n\nOther Reflection Classes are not provided. They might be in the future.\n\n## Testing\n\n`bramus/reflection` ships with unit tests using [PHPUnit](https://github.com/sebastianbergmann/phpunit/) `~8.0`.\n\n- If PHPUnit is installed globally run `phpunit` to run the tests.\n- If PHPUnit is not installed globally, install it locally throuh composer by running `composer install --dev`. Run the tests themselves by calling `./vendor/bin/phpunit` or using the composer script `composer test`\n\n```\n$ composer test\n```\n\n## License\n\n`bramus/reflection` is released under the MIT public license. See the enclosed `LICENSE` for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramus%2Freflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramus%2Freflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramus%2Freflection/lists"}