ssmiff/attribute-collector

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ssmiff/attribute-collector

1.0.2 2025-11-04 21:56 UTC

This package is auto-updated.

Last update: 2025-11-04 21:56:51 UTC


README

Collect all public class/method/properties attributes into a single registry.

Usage

There are two built in memoizers, FileMemoizer and InMemoryMemoizer. These can optionally be used to cache the results of the discovery process.

Example:

use Ssmith\AttributeCollector\Cache\FileMemoizer;
use Ssmith\AttributeCollector\ComposerClassMap;
use Ssmith\AttributeCollector\Tests\fixtures\Attributes\TargetClass;

include __DIR__ . '/vendor/autoload.php';

$classMap = new ComposerClassMap([__DIR__ . '/tests/fixtures']);
$memoize = new InMemoryMemoizer();
$logger = new PrsLogger();
$discovery = new Ssmith\AttributeCollector\ClassAttributeCollector($classMap, $memoize, $logger);

$registry = $discovery->buildRegistry();

$allAttributesByName = $registry->forAttribute(MyAttribute::class);

$allAttributesOnClass = $registry->forClass(MyClass::class);
$allAttributesOnClassMethod = $registry->forMethod(MyClass::class, 'myMethod');
$allAttributesOnClassProperty = $registry->forProperty(MyClass::class, 'myProperty');
$distinctAttributes = $registry->count();