forked from https://github.com/symfony/symfony
772547ec02
This PR was merged into the 5.2-dev branch.
Discussion
----------
[VarDumper] Support for ReflectionAttribute
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | N/A
| License | MIT
| Doc PR | not needed
VarDumper currently does not understand that certain reflection objects might have attributes attached to it. Dumping a `ReflectionAttribute` just yields `ReflectionAttribute {#4711}` which is not really helpful. This PR attempts to fix this.
```
ReflectionAttribute {#4711
name: "App\MyAttribute"
arguments: array:2 [
0 => "one"
"extra" => "hello"
]
}
```
While working on this, I noticed that class constants (which can be reflected on since PHP 7.1) are just dumped as plain values, so I've also added a caster for `ReflectionClasConstant` as bonus.
The full output for the `LotsOfAttributes` fixture class that is included with is PR looks like this:
<details>
```
^ ReflectionClass {#7
+name: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
modifiers: "final"
implements: []
constants: array:1 [
0 => ReflectionClassConstant {#20
+name: "SOME_CONSTANT"
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
modifiers: "public"
value: "some value"
attributes: array:2 [
0 => ReflectionAttribute {#33
name: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
arguments: array:1 [
0 => "one"
]
}
1 => ReflectionAttribute {#34
name: "Symfony\Component\VarDumper\Tests\Fixtures\RepeatableAttribute"
arguments: array:1 [
0 => "two"
]
}
]
}
]
properties: array:1 [
"someProperty" => ReflectionProperty {#19
+name: "someProperty"
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
modifiers: "private"
attributes: array:1 [
0 => ReflectionAttribute {#30
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
arguments: array:2 [
0 => "one"
"extra" => "hello"
]
}
]
}
]
methods: array:1 [
"someMethod" => ReflectionMethod {#21
+name: "someMethod"
+class: "Symfony\Component\VarDumper\Tests\Fixtures\LotsOfAttributes"
returnType: "void"
parameters: {
$someParameter: ReflectionParameter {#28
+name: "someParameter"
position: 0
attributes: array:1 [
0 => ReflectionAttribute {#42
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
arguments: array:1 [
0 => "three"
]
}
]
typeHint: "string"
}
}
attributes: array:1 [
0 => ReflectionAttribute {#27
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
arguments: array:1 [
0 => "two"
]
}
]
modifiers: "public"
}
]
attributes: array:1 [
0 => ReflectionAttribute {#22
name: "Symfony\Component\VarDumper\Tests\Fixtures\MyAttribute"
arguments: []
}
]
extra: {
file: "./src/Symfony/Component/VarDumper/Tests/Fixtures/LotsOfAttributes.php"
line: "15 to 28"
isUserDefined: true
}
}
```
</details>
Commits
-------
|
||
---|---|---|
.github | ||
src/Symfony | ||
.appveyor.yml | ||
.editorconfig | ||
.gitignore | ||
.php_cs.dist | ||
.travis.yml | ||
CHANGELOG-4.0.md | ||
CHANGELOG-4.1.md | ||
CHANGELOG-4.2.md | ||
CHANGELOG-4.3.md | ||
CHANGELOG-4.4.md | ||
CHANGELOG-5.0.md | ||
CHANGELOG-5.1.md | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
CONTRIBUTING.md | ||
CONTRIBUTORS.md | ||
LICENSE | ||
link | ||
phpunit | ||
phpunit.xml.dist | ||
README.md | ||
UPGRADE-5.0.md | ||
UPGRADE-5.1.md | ||
UPGRADE-5.2.md | ||
UPGRADE-6.0.md |
Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).
Installation
- Install Symfony with Composer (see requirements details).
- Symfony follows the semantic versioning strictly, publishes "Long Term Support" (LTS) versions and has a release process that is predictable and business-friendly.
Documentation
- Read the Getting Started guide if you are new to Symfony.
- Try the Symfony Demo application to learn Symfony in practice.
- Master Symfony with the Guides and Tutorials, the Components docs and the Best Practices reference.
Community
- Join the Symfony Community and meet other members at the Symfony events.
- Get Symfony support on Stack Overflow, Slack, IRC, etc.
- Follow us on GitHub, Twitter and Facebook.
- Read our Code of Conduct and meet the CARE Team.
Contributing
Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.
Security Issues
If you discover a security vulnerability within Symfony, please follow our disclosure procedure.
About Us
Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.