2017 © Pedro Peláez
 

library attribute

Attribute for Hack

image

holyshared/attribute

Attribute for Hack

  • Saturday, October 3, 2015
  • by holyshared
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • Hack
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

attribute

Attribute for Hack, (*1)

Latest Stable Version Build Status Dependency Status License, (*2)

ClassAttribute

<?hh //strict

namespace example;

use attribute\ClassAttribute;

final class Tag extends ClassAttribute
{

    public function __construct(
        private string $name
    )
    {
    }

    public function value() : string
    {
        return $this->name;
    }

}
<?hh //strict

namespace example;

<<Tag('important')>>
class TaggedTarget
{
}

<?hh //strict

namespace example;

$attribute = Tag::findByClassName(TaggedTarget::class);
var_dump($attribute->value()); // Tag attribute instance

$attribute = Tag::findByClass(new ReflectionClass(TaggedTarget::class));
var_dump($attribute->value()); // Tag attribute instance

MethodAttribute

<?hh //strict

namespace example;

use attribute\MethodAttribute;

final class Tag extends MethodAttribute
{

    public function __construct(
        private string $name
    )
    {
    }

    public function value() : string
    {
        return $this->name;
    }

}
<?hh //strict

namespace example;

class TaggedTarget
{

    public function __construct(
        private string $name
    )
    {
    }

    <<Tag('important')>>
    public function getName() : string
    {
        return $this->name;
    }

}
<?hh //strict

namespace example;

$attributes = Tag::findByClassName(TaggedTarget::class);
var_dump($attributes->at('getName')->value()); // important

$attributes = Tag::findByClass(new ReflectionClass(TaggedTarget::class));
var_dump($attributes->at('getName')->value()); // important

$attribute = Tag::findByMethod(new ReflectionMethod(TaggedTarget::class, 'getName'));
var_dump($attribute->value()); // important

Run the test

composer install
composer test

The Versions

03/10 2015

dev-master

9999999-dev

Attribute for Hack

  Sources   Download

MIT

The Requires

  • hhvm >=3.6.0

 

The Development Requires

by Noritaka Horio

hack hhvm annotation attribute

03/10 2015

0.1.1

0.1.1.0

Attribute for Hack

  Sources   Download

MIT

The Requires

  • hhvm >=3.6.0

 

The Development Requires

by Noritaka Horio

hack hhvm annotation attribute

03/10 2015

0.1.0

0.1.0.0

Attribute for Hack

  Sources   Download

MIT

The Requires

  • hhvm >=3.6.0

 

The Development Requires

by Noritaka Horio

hack hhvm annotation attribute