Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ChangeLog

## 0.2.1 Under development
## 0.2.2 Under development

- Enh #10: Add generic PHPStan annotations to `Reflector` for typed attribute inference in consumers (@terabytesoftw)

## 0.2.1 March 3, 2026

Expand Down
16 changes: 13 additions & 3 deletions src/Reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public static function cacheSize(): int
*
* @return array Class attributes.
*
* @phpstan-return list<ReflectionAttribute<object>>
* @phpstan-template TAttribute of object
* @phpstan-param class-string<TAttribute>|null $attribute
* @phpstan-return ($attribute is null ? list<ReflectionAttribute<object>> : list<ReflectionAttribute<TAttribute>>)
*/
public static function classAttributes(object|string $class, string|null $attribute = null, int $flags = 0): array
{
Expand Down Expand Up @@ -111,6 +113,10 @@ public static function clearCache(): void
* ```
*
* @return object|null First matching instantiated attribute, or `null` if no matching attribute is found.
*
* @phpstan-template TAttribute of object
* @phpstan-param class-string<TAttribute> $attribute
* @phpstan-return TAttribute|null
*/
public static function firstPropertyAttribute(
object|string $class,
Expand Down Expand Up @@ -205,7 +211,9 @@ public static function property(object|string $class, string $property): Reflect
*
* @return array Instantiated property attributes.
*
* @phpstan-return list<object>
* @phpstan-template TAttribute of object
* @phpstan-param class-string<TAttribute>|null $attribute
* @phpstan-return ($attribute is null ? list<object> : list<TAttribute>)
*/
public static function propertyAttributeInstances(
object|string $class,
Expand Down Expand Up @@ -236,7 +244,9 @@ public static function propertyAttributeInstances(
*
* @return array Property attributes.
*
* @phpstan-return list<ReflectionAttribute<object>>
* @phpstan-template TAttribute of object
* @phpstan-param class-string<TAttribute>|null $attribute
* @phpstan-return ($attribute is null ? list<ReflectionAttribute<object>> : list<ReflectionAttribute<TAttribute>>)
*/
public static function propertyAttributes(
object|string $class,
Expand Down
Loading