DanielEScherzer · GitHub

@DanielEScherzer

Copy link Copy Markdown

Member

@DanielEScherzer

Crell

#[Attribute]
class Demo {
public function __construct( $args ) {
echo ReflectionAttribute::getCurrent();

Copy link Copy Markdown

Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more common to use var_dump here.

Copy link Copy Markdown

Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, I'd also be fine with just echoing the name property/method of the object rather than dumping the whole object. Other internals regulars may have a different opinion...

Copy link Copy Markdown

Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make it clear that it has the same information that was present to the caller, and var_dump has less information than toString() for reflection objects

@Crell

Copy link Copy Markdown

Contributor

I believe we'd also want tests to confirm what happens if that method is called outside the constructor, and how it will error (or null, or whatever it's going to do).

@DanielEScherzer

Copy link Copy Markdown

Member Author

I believe we'd also want tests to confirm what happens if that method is called outside the constructor, and how it will error (or null, or whatever it's going to do).

added

@DanielEScherzer

Read the original on github.com ↗