Skip to content

Instantly share code, notes, and snippets.

@shin1x1
Created September 19, 2020 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shin1x1/68273168690caaf44ead6d24db997518 to your computer and use it in GitHub Desktop.
Save shin1x1/68273168690caaf44ead6d24db997518 to your computer and use it in GitHub Desktop.
<?php
namespace Acme;
use Attribute;
@@Attribute
final class Attr1 {}
@@Attr1
final class Foo {}
$reflectionClass = new \ReflectionClass(Foo::class);
$attributes = $reflectionClass->getAttributes();
var_dump($attributes[0]->newInstance());
<?php
namespace Acme;
use Attribute;
#[Attribute]
final class Attr1 {}
#[Attr1]
final class Foo {}
$reflectionClass = new \ReflectionClass(Foo::class);
$attributes = $reflectionClass->getAttributes();
var_dump($attributes[0]->newInstance());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment