From 480f430f6bf1b7673dd78d66a1290ba22479bb7e Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 14 Jul 2025 09:55:56 -0500 Subject: [PATCH 1/4] Support reflection on sub-attributes on properties. --- src/ReflectionDefinitionBuilder.php | 23 ++++++++--- .../ClassWithPropertiesWithSubAttributes.php | 2 +- .../ConfigurableClassWithProperties.php | 38 +++++++++++++++++++ .../ConfigurablePropertyWithSubAttributes.php | 30 +++++++++++++++ .../PropertySubAttributeWithReflection.php | 18 +++++++++ .../Attributes/PropertyWithSubAttributes.php | 30 --------------- tests/ClassAnalyzerTest.php | 21 +++++++--- ...thPropertySubAttributesUsingReflection.php | 19 ++++++++++ tests/Records/ClassWithSubAttributes.php | 8 ++-- 9 files changed, 144 insertions(+), 45 deletions(-) create mode 100644 tests/Attributes/ConfigurableClassWithProperties.php create mode 100644 tests/Attributes/ConfigurablePropertyWithSubAttributes.php create mode 100644 tests/Attributes/PropertySubAttributeWithReflection.php delete mode 100644 tests/Attributes/PropertyWithSubAttributes.php create mode 100644 tests/Records/ClassWithPropertySubAttributesUsingReflection.php diff --git a/src/ReflectionDefinitionBuilder.php b/src/ReflectionDefinitionBuilder.php index ef03758..f7e118f 100644 --- a/src/ReflectionDefinitionBuilder.php +++ b/src/ReflectionDefinitionBuilder.php @@ -130,9 +130,7 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v if ($this->isMultivalueAttribute($type)) { $subs = $this->parser->getInheritedAttributes($reflection, $type); foreach ($subs as $sub) { - if ($sub instanceof Finalizable) { - $sub->finalize(); - } + $this->applySubattributeFeatures($sub, $reflection); $this->loadSubAttributes($sub, $reflection); } if ($callback instanceof \Closure) { @@ -142,8 +140,8 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v } } else { $sub = $this->parser->getInheritedAttribute($reflection, $type); - if ($sub instanceof Finalizable) { - $sub->finalize(); + if ($sub) { + $this->applySubattributeFeatures($sub, $reflection); } $this->loadSubAttributes($sub, $reflection); if ($callback instanceof \Closure) { @@ -156,6 +154,21 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v } } + protected function applySubattributeFeatures(object $attribute, \Reflector $reflection): void + { + if ($attribute instanceof FromReflectionClass) { + /** @var \ReflectionClass $reflection */ + $attribute->fromReflection($reflection); + } + if ($attribute instanceof FromReflectionProperty) { + /** @var \ReflectionProperty $reflection */ + $attribute->fromReflection($reflection); + } + if ($attribute instanceof Finalizable) { + $attribute->finalize(); + } + } + /** * Determines if a given attribute class allows repeating. * diff --git a/tests/Attributes/ClassWithPropertiesWithSubAttributes.php b/tests/Attributes/ClassWithPropertiesWithSubAttributes.php index f0ba563..2a65eee 100644 --- a/tests/Attributes/ClassWithPropertiesWithSubAttributes.php +++ b/tests/Attributes/ClassWithPropertiesWithSubAttributes.php @@ -31,7 +31,7 @@ public function includePropertiesByDefault(): bool public function propertyAttribute(): string { - return PropertyWithSubAttributes::class; + return ConfigurablePropertyWithSubAttributes::class; } public function subAttributes(): array diff --git a/tests/Attributes/ConfigurableClassWithProperties.php b/tests/Attributes/ConfigurableClassWithProperties.php new file mode 100644 index 0000000..f8a7ed8 --- /dev/null +++ b/tests/Attributes/ConfigurableClassWithProperties.php @@ -0,0 +1,38 @@ + + */ + public array $properties = []; + + public function __construct( + public string $propertyAttribute, + public bool $includeByDefault = false, + public string $a = 'A', + ) {} + + public function setProperties(array $properties): void + { + $this->properties = $properties; + } + + public function includePropertiesByDefault(): bool + { + return $this->includeByDefault; + } + + public function propertyAttribute(): string + { + return $this->propertyAttribute; + } +} diff --git a/tests/Attributes/ConfigurablePropertyWithSubAttributes.php b/tests/Attributes/ConfigurablePropertyWithSubAttributes.php new file mode 100644 index 0000000..7b66832 --- /dev/null +++ b/tests/Attributes/ConfigurablePropertyWithSubAttributes.php @@ -0,0 +1,30 @@ +subattribute => 'fromSubAttribute']; + } + + public function fromSubAttribute(?object $sub): void + { + $sub ??= new ($this->subattribute)(); + $this->subattrib = $sub; + } +} diff --git a/tests/Attributes/PropertySubAttributeWithReflection.php b/tests/Attributes/PropertySubAttributeWithReflection.php new file mode 100644 index 0000000..ddb8bab --- /dev/null +++ b/tests/Attributes/PropertySubAttributeWithReflection.php @@ -0,0 +1,18 @@ +name = $subject->getName(); + } +} diff --git a/tests/Attributes/PropertyWithSubAttributes.php b/tests/Attributes/PropertyWithSubAttributes.php deleted file mode 100644 index 23a0ea3..0000000 --- a/tests/Attributes/PropertyWithSubAttributes.php +++ /dev/null @@ -1,30 +0,0 @@ - 'fromSubAttribute']; - } - - public function fromSubAttribute(?PropertySubAttribute $sub): void - { - $sub ??= new PropertySubAttribute(); - $this->b = $sub->b; - } - -} diff --git a/tests/ClassAnalyzerTest.php b/tests/ClassAnalyzerTest.php index 9da4d07..00f7643 100644 --- a/tests/ClassAnalyzerTest.php +++ b/tests/ClassAnalyzerTest.php @@ -15,24 +15,23 @@ use Crell\AttributeUtils\Attributes\ClassWithReflection; use Crell\AttributeUtils\Attributes\ClassWithSubSubAttributes; use Crell\AttributeUtils\Attributes\ClosureSubAttributeMain; +use Crell\AttributeUtils\Attributes\ConfigurableClassWithProperties; use Crell\AttributeUtils\Attributes\FinalizableClassAttribute; use Crell\AttributeUtils\Attributes\GenericClass; +use Crell\AttributeUtils\Attributes\InheritableClassAttributeMain; use Crell\AttributeUtils\Attributes\Labeled; use Crell\AttributeUtils\Attributes\PropertyTakesClassDefaultClass; use Crell\AttributeUtils\Attributes\ScopedClass; -use Crell\AttributeUtils\Attributes\InheritableClassAttributeMain; use Crell\AttributeUtils\Attributes\ScopedClassMulti; use Crell\AttributeUtils\Attributes\ScopedClassNoDefaultInclude; use Crell\AttributeUtils\ExclusiveOptions\Audio; use Crell\AttributeUtils\ExclusiveOptions\AudioData; use Crell\AttributeUtils\ExclusiveOptions\BothData; use Crell\AttributeUtils\ExclusiveOptions\DisplayInfo; -use Crell\AttributeUtils\ExclusiveOptions\DisplayType; use Crell\AttributeUtils\ExclusiveOptions\NoData; use Crell\AttributeUtils\ExclusiveOptions\Screen; use Crell\AttributeUtils\ExclusiveOptions\ScreenData; use Crell\AttributeUtils\InterfaceAttributes\Hero; -use Crell\AttributeUtils\InterfaceAttributes\Name; use Crell\AttributeUtils\InterfaceAttributes\Names; use Crell\AttributeUtils\Records\AttributesInheritChild; use Crell\AttributeUtils\Records\ClassWithClosureSubAttributes; @@ -43,11 +42,12 @@ use Crell\AttributeUtils\Records\ClassWithExcludedProperties; use Crell\AttributeUtils\Records\ClassWithExtraAnalysisSource; use Crell\AttributeUtils\Records\ClassWithFinalizableAttributes; -use Crell\AttributeUtils\Records\ClassWithScopes; use Crell\AttributeUtils\Records\ClassWithInterface; use Crell\AttributeUtils\Records\ClassWithMethodsAndProperties; use Crell\AttributeUtils\Records\ClassWithPropertiesWithReflection; +use Crell\AttributeUtils\Records\ClassWithPropertySubAttributesUsingReflection; use Crell\AttributeUtils\Records\ClassWithRecursiveSubAttributes; +use Crell\AttributeUtils\Records\ClassWithScopes; use Crell\AttributeUtils\Records\ClassWithScopesMulti; use Crell\AttributeUtils\Records\ClassWithScopesNotDefault; use Crell\AttributeUtils\Records\ClassWithSubAttributes; @@ -201,9 +201,18 @@ public static function attributeTestProvider(): \Generator 'test' => static function(ClassWithPropertiesWithSubAttributes $classDef) { static::assertEquals('C', $classDef->c); static::assertEquals('A', $classDef->properties['hasSub']->a); - static::assertEquals('B', $classDef->properties['hasSub']->b); + static::assertEquals('B', $classDef->properties['hasSub']->subattrib->b); static::assertEquals('A', $classDef->properties['noSub']->a); - static::assertEquals('B', $classDef->properties['noSub']->b); + static::assertEquals('B', $classDef->properties['noSub']->subattrib->b); + }, + ]; + + yield 'Subattributes with FromReflection' => [ + 'subject' => ClassWithPropertySubAttributesUsingReflection::class, + 'attribute' => ConfigurableClassWithProperties::class, + 'test' => static function(ConfigurableClassWithProperties $classDef) { + static::assertEquals('A', $classDef->a); + static::assertEquals('prop', $classDef->properties['prop']->subattrib->name); }, ]; diff --git a/tests/Records/ClassWithPropertySubAttributesUsingReflection.php b/tests/Records/ClassWithPropertySubAttributesUsingReflection.php new file mode 100644 index 0000000..bcd59b0 --- /dev/null +++ b/tests/Records/ClassWithPropertySubAttributesUsingReflection.php @@ -0,0 +1,19 @@ + Date: Mon, 14 Jul 2025 09:59:11 -0500 Subject: [PATCH 2/4] Minor refactor. --- src/ReflectionDefinitionBuilder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ReflectionDefinitionBuilder.php b/src/ReflectionDefinitionBuilder.php index f7e118f..fdc903a 100644 --- a/src/ReflectionDefinitionBuilder.php +++ b/src/ReflectionDefinitionBuilder.php @@ -131,7 +131,6 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v $subs = $this->parser->getInheritedAttributes($reflection, $type); foreach ($subs as $sub) { $this->applySubattributeFeatures($sub, $reflection); - $this->loadSubAttributes($sub, $reflection); } if ($callback instanceof \Closure) { $callback($subs); @@ -143,7 +142,6 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v if ($sub) { $this->applySubattributeFeatures($sub, $reflection); } - $this->loadSubAttributes($sub, $reflection); if ($callback instanceof \Closure) { $callback($sub); } else { @@ -156,6 +154,7 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v protected function applySubattributeFeatures(object $attribute, \Reflector $reflection): void { + // For each possible type, check for a FromReflection interface. if ($attribute instanceof FromReflectionClass) { /** @var \ReflectionClass $reflection */ $attribute->fromReflection($reflection); @@ -167,6 +166,8 @@ protected function applySubattributeFeatures(object $attribute, \Reflector $refl if ($attribute instanceof Finalizable) { $attribute->finalize(); } + // Call recursively to allow sub-attributes on sub-attributes. (Yo Dawg.) + $this->loadSubAttributes($attribute, $reflection); } /** From 03707ed50051d274b26661ae5dc9e4fe14f1077c Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 14 Jul 2025 11:10:30 -0500 Subject: [PATCH 3/4] Expand subattribute reflection to all component types. --- src/ReflectionDefinitionBuilder.php | 21 ++++- tests/ClassAnalyzerTest.php | 26 ++++-- tests/FunctionAnalyzerTest.php | 21 +++++ .../ClassAllFeaturesForSubAttrib.php | 82 +++++++++++++++++++ ...sWithAllFeaturesForSubAttribReflection.php | 30 +++++++ .../ComponentAttribute.php | 43 ++++++++++ .../EnumForSubAttrib.php | 14 ++++ .../FuncAllFeaturesForSubAttrib.php | 33 ++++++++ .../SubAttributeReflect.php | 33 ++++++++ 9 files changed, 295 insertions(+), 8 deletions(-) create mode 100644 tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php create mode 100644 tests/SubattributeReflection/ClassWithAllFeaturesForSubAttribReflection.php create mode 100644 tests/SubattributeReflection/ComponentAttribute.php create mode 100644 tests/SubattributeReflection/EnumForSubAttrib.php create mode 100644 tests/SubattributeReflection/FuncAllFeaturesForSubAttrib.php create mode 100644 tests/SubattributeReflection/SubAttributeReflect.php diff --git a/src/ReflectionDefinitionBuilder.php b/src/ReflectionDefinitionBuilder.php index fdc903a..897308b 100644 --- a/src/ReflectionDefinitionBuilder.php +++ b/src/ReflectionDefinitionBuilder.php @@ -155,14 +155,29 @@ public function loadSubAttributes(?object $attribute, \Reflector $reflection): v protected function applySubattributeFeatures(object $attribute, \Reflector $reflection): void { // For each possible type, check for a FromReflection interface. - if ($attribute instanceof FromReflectionClass) { + if ($reflection instanceof \ReflectionClass && ! $reflection instanceof \ReflectionEnum && $attribute instanceof FromReflectionClass) { /** @var \ReflectionClass $reflection */ $attribute->fromReflection($reflection); } - if ($attribute instanceof FromReflectionProperty) { - /** @var \ReflectionProperty $reflection */ + if ($reflection instanceof \ReflectionEnum && $attribute instanceof FromReflectionEnum) { $attribute->fromReflection($reflection); } + if ($reflection instanceof \ReflectionFunction && $attribute instanceof FromReflectionFunction) { + $attribute->fromReflection($reflection); + } + if ($reflection instanceof \ReflectionProperty && $attribute instanceof FromReflectionProperty) { + $attribute->fromReflection($reflection); + } + if ($reflection instanceof \ReflectionMethod && $attribute instanceof FromReflectionMethod) { + $attribute->fromReflection($reflection); + } + if ($reflection instanceof \ReflectionClassConstant && $attribute instanceof FromReflectionClassConstant) { + $attribute->fromReflection($reflection); + } + if ($reflection instanceof \ReflectionParameter && $attribute instanceof FromReflectionParameter) { + $attribute->fromReflection($reflection); + } + if ($attribute instanceof Finalizable) { $attribute->finalize(); } diff --git a/tests/ClassAnalyzerTest.php b/tests/ClassAnalyzerTest.php index 00f7643..28b38e2 100644 --- a/tests/ClassAnalyzerTest.php +++ b/tests/ClassAnalyzerTest.php @@ -60,6 +60,9 @@ use Crell\AttributeUtils\Records\PropertiesWithMultipleSubattributes; use Crell\AttributeUtils\Records\PropertyThatTakesClassDefault; use Crell\AttributeUtils\Records\TransitiveFieldClass; +use Crell\AttributeUtils\SubattributeReflection\ClassAllFeaturesForSubAttrib; +use Crell\AttributeUtils\SubattributeReflection\ClassWithAllFeaturesForSubAttribReflection; +use Crell\AttributeUtils\SubattributeReflection\EnumForSubAttrib; use Crell\AttributeUtils\TypeDef\Suit; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; @@ -207,12 +210,25 @@ public static function attributeTestProvider(): \Generator }, ]; - yield 'Subattributes with FromReflection' => [ - 'subject' => ClassWithPropertySubAttributesUsingReflection::class, - 'attribute' => ConfigurableClassWithProperties::class, - 'test' => static function(ConfigurableClassWithProperties $classDef) { + yield 'Subattributes with FromReflection (class)' => [ + 'subject' => ClassWithAllFeaturesForSubAttribReflection::class, + 'attribute' => ClassAllFeaturesForSubAttrib::class, + 'test' => static function(ClassAllFeaturesForSubAttrib $classDef) { static::assertEquals('A', $classDef->a); - static::assertEquals('prop', $classDef->properties['prop']->subattrib->name); + static::assertEquals(ClassWithAllFeaturesForSubAttribReflection::class, $classDef->sub->name); + static::assertEquals('classA', $classDef->properties['classA']->sub->name); + static::assertEquals('method', $classDef->methods['method']->sub->name); + static::assertEquals('parameter', $classDef->methods['method']->parameters['parameter']->sub->name); + static::assertEquals('AConstant', $classDef->constants['AConstant']->sub->name); + }, + ]; + + yield 'Subattributes with FromReflection (enum)' => [ + 'subject' => EnumForSubAttrib::class, + 'attribute' => ClassAllFeaturesForSubAttrib::class, + 'test' => static function(ClassAllFeaturesForSubAttrib $classDef) { + static::assertEquals(EnumForSubAttrib::class, $classDef->sub->name); + static::assertEquals('Case', $classDef->cases['Case']->sub->name); }, ]; diff --git a/tests/FunctionAnalyzerTest.php b/tests/FunctionAnalyzerTest.php index bbe9828..29e46f9 100644 --- a/tests/FunctionAnalyzerTest.php +++ b/tests/FunctionAnalyzerTest.php @@ -10,6 +10,12 @@ use Crell\AttributeUtils\Attributes\Functions\RequiredArg; use Crell\AttributeUtils\Attributes\Functions\SubChild; use Crell\AttributeUtils\Attributes\Functions\SubParent; +use Crell\AttributeUtils\SubattributeReflection\ClassAllFeaturesForSubAttrib; +use Crell\AttributeUtils\SubattributeReflection\ClassWithAllFeaturesForSubAttribReflection; +use Crell\AttributeUtils\SubattributeReflection\ComponentAttribute; +use Crell\AttributeUtils\SubattributeReflection\EnumForSubAttrib; +use Crell\AttributeUtils\SubattributeReflection\FuncAllFeaturesForSubAttrib; +use Crell\AttributeUtils\SubattributeReflection\SubAttributeReflect; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -31,6 +37,12 @@ function has_parameters( #[ParameterAttrib('Override')] int $second, ) {} + +#[FuncAllFeaturesForSubAttrib, SubAttributeReflect] +function func_for_subattrib( + #[ComponentAttribute, SubAttributeReflect] string $parameter, +) {} + class FunctionAnalyzerTest extends TestCase { protected string $ns; @@ -101,5 +113,14 @@ public static function attributeTestProvider(): \Generator static::assertEquals('Override', $funcDef->parameters['second']->a); }, ]; + + yield 'Subattributes with FromReflection (function)' => [ + 'subject' => "{$ns}func_for_subattrib", + 'attribute' => FuncAllFeaturesForSubAttrib::class, + 'test' => static function(FuncAllFeaturesForSubAttrib $funcDef) use ($ns) { + static::assertEquals("{$ns}func_for_subattrib", $funcDef->sub->name); + static::assertEquals('parameter', $funcDef->parameters['parameter']->sub->name); + }, + ]; } } diff --git a/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php b/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php new file mode 100644 index 0000000..5e8f271 --- /dev/null +++ b/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php @@ -0,0 +1,82 @@ + fn(?SubAttributeReflect $sub) => $this->sub = $sub, + ]; + } + + public function caseAttribute(): string + { + return ComponentAttribute::class; + } + + public function methodAttribute(): string + { + return ComponentAttribute::class; + } + + public function parameterAttribute(): string + { + return ComponentAttribute::class; + } + + public function propertyAttribute(): string + { + return ComponentAttribute::class; + } + + public function constantAttribute(): string + { + return ComponentAttribute::class; + } +} diff --git a/tests/SubattributeReflection/ClassWithAllFeaturesForSubAttribReflection.php b/tests/SubattributeReflection/ClassWithAllFeaturesForSubAttribReflection.php new file mode 100644 index 0000000..e9c62c0 --- /dev/null +++ b/tests/SubattributeReflection/ClassWithAllFeaturesForSubAttribReflection.php @@ -0,0 +1,30 @@ + fn(?SubAttributeReflect $sub) => $this->sub = $sub, + ]; + } + + public function setParameters(array $parameters): void + { + $this->parameters = $parameters; + } + + public function includeParametersByDefault(): bool + { + return false; + } + + public function parameterAttribute(): string + { + return __CLASS__; + } +} diff --git a/tests/SubattributeReflection/EnumForSubAttrib.php b/tests/SubattributeReflection/EnumForSubAttrib.php new file mode 100644 index 0000000..1af4cc9 --- /dev/null +++ b/tests/SubattributeReflection/EnumForSubAttrib.php @@ -0,0 +1,14 @@ + fn(?SubAttributeReflect $sub) => $this->sub = $sub, + ]; + } + + public function parameterAttribute(): string + { + return ComponentAttribute::class; + } + +} diff --git a/tests/SubattributeReflection/SubAttributeReflect.php b/tests/SubattributeReflection/SubAttributeReflect.php new file mode 100644 index 0000000..af3426c --- /dev/null +++ b/tests/SubattributeReflection/SubAttributeReflect.php @@ -0,0 +1,33 @@ +name = $subject->getName(); + } +} From 4dfb5d464f8e1eeac7f765a81b026594c924a407 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Mon, 14 Jul 2025 11:17:00 -0500 Subject: [PATCH 4/4] Optimize imports. --- tests/Attributes/ClassWithOwnSubAttributes.php | 1 - tests/Attributes/ClassWithSubSubAttributeLevelOne.php | 3 ++- tests/Attributes/ClassWithSubSubAttributeLevelTwo.php | 1 - tests/Attributes/ClassWithSubSubAttributeLevelTwoMulti.php | 1 - tests/Attributes/ClassWithSubSubAttributes.php | 2 +- tests/Attributes/ScopedClassMulti.php | 1 - tests/ClassAnalyzerTest.php | 2 -- tests/FunctionAnalyzerCacheTestMethods.php | 5 ----- tests/FunctionAnalyzerTest.php | 3 --- tests/InterfaceAttributes/Alias.php | 1 - tests/InterfaceAttributes/Names.php | 1 + .../ClassWithPropertySubAttributesUsingReflection.php | 2 +- tests/Records/ClassWithSubAttributes.php | 2 +- tests/ReflectTest.php | 1 - .../SubattributeReflection/ClassAllFeaturesForSubAttrib.php | 2 -- 15 files changed, 6 insertions(+), 22 deletions(-) diff --git a/tests/Attributes/ClassWithOwnSubAttributes.php b/tests/Attributes/ClassWithOwnSubAttributes.php index 7f672aa..87b1e9b 100644 --- a/tests/Attributes/ClassWithOwnSubAttributes.php +++ b/tests/Attributes/ClassWithOwnSubAttributes.php @@ -6,7 +6,6 @@ use Attribute; use Crell\AttributeUtils\HasSubAttributes; -use Crell\AttributeUtils\ParseProperties; #[Attribute(Attribute::TARGET_CLASS)] class ClassWithOwnSubAttributes implements HasSubAttributes diff --git a/tests/Attributes/ClassWithSubSubAttributeLevelOne.php b/tests/Attributes/ClassWithSubSubAttributeLevelOne.php index 80a6a6e..06f1722 100644 --- a/tests/Attributes/ClassWithSubSubAttributeLevelOne.php +++ b/tests/Attributes/ClassWithSubSubAttributeLevelOne.php @@ -4,8 +4,9 @@ namespace Crell\AttributeUtils\Attributes; -use \Attribute; +use Attribute; use Crell\AttributeUtils\HasSubAttributes; + use function Crell\fp\amap; use function Crell\fp\prop; diff --git a/tests/Attributes/ClassWithSubSubAttributeLevelTwo.php b/tests/Attributes/ClassWithSubSubAttributeLevelTwo.php index f7e73ad..7ec1797 100644 --- a/tests/Attributes/ClassWithSubSubAttributeLevelTwo.php +++ b/tests/Attributes/ClassWithSubSubAttributeLevelTwo.php @@ -5,7 +5,6 @@ namespace Crell\AttributeUtils\Attributes; use Attribute; -use Crell\AttributeUtils\HasSubAttributes; #[Attribute(Attribute::TARGET_CLASS)] class ClassWithSubSubAttributeLevelTwo diff --git a/tests/Attributes/ClassWithSubSubAttributeLevelTwoMulti.php b/tests/Attributes/ClassWithSubSubAttributeLevelTwoMulti.php index ae5da0d..776038c 100644 --- a/tests/Attributes/ClassWithSubSubAttributeLevelTwoMulti.php +++ b/tests/Attributes/ClassWithSubSubAttributeLevelTwoMulti.php @@ -5,7 +5,6 @@ namespace Crell\AttributeUtils\Attributes; use Attribute; -use Crell\AttributeUtils\HasSubAttributes; use Crell\AttributeUtils\Multivalue; #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] diff --git a/tests/Attributes/ClassWithSubSubAttributes.php b/tests/Attributes/ClassWithSubSubAttributes.php index 13c626e..7a4dc72 100644 --- a/tests/Attributes/ClassWithSubSubAttributes.php +++ b/tests/Attributes/ClassWithSubSubAttributes.php @@ -4,7 +4,7 @@ namespace Crell\AttributeUtils\Attributes; -use \Attribute; +use Attribute; use Crell\AttributeUtils\HasSubAttributes; #[Attribute(Attribute::TARGET_CLASS)] diff --git a/tests/Attributes/ScopedClassMulti.php b/tests/Attributes/ScopedClassMulti.php index f227bb1..a72669a 100644 --- a/tests/Attributes/ScopedClassMulti.php +++ b/tests/Attributes/ScopedClassMulti.php @@ -5,7 +5,6 @@ namespace Crell\AttributeUtils\Attributes; use Attribute; -use Crell\AttributeUtils\Attributes\Reflect\CollectMethods; use Crell\AttributeUtils\Attributes\Reflect\CollectProperties; use Crell\AttributeUtils\ParseProperties; use Crell\AttributeUtils\SupportsScopes; diff --git a/tests/ClassAnalyzerTest.php b/tests/ClassAnalyzerTest.php index 28b38e2..c1f3ce1 100644 --- a/tests/ClassAnalyzerTest.php +++ b/tests/ClassAnalyzerTest.php @@ -15,7 +15,6 @@ use Crell\AttributeUtils\Attributes\ClassWithReflection; use Crell\AttributeUtils\Attributes\ClassWithSubSubAttributes; use Crell\AttributeUtils\Attributes\ClosureSubAttributeMain; -use Crell\AttributeUtils\Attributes\ConfigurableClassWithProperties; use Crell\AttributeUtils\Attributes\FinalizableClassAttribute; use Crell\AttributeUtils\Attributes\GenericClass; use Crell\AttributeUtils\Attributes\InheritableClassAttributeMain; @@ -45,7 +44,6 @@ use Crell\AttributeUtils\Records\ClassWithInterface; use Crell\AttributeUtils\Records\ClassWithMethodsAndProperties; use Crell\AttributeUtils\Records\ClassWithPropertiesWithReflection; -use Crell\AttributeUtils\Records\ClassWithPropertySubAttributesUsingReflection; use Crell\AttributeUtils\Records\ClassWithRecursiveSubAttributes; use Crell\AttributeUtils\Records\ClassWithScopes; use Crell\AttributeUtils\Records\ClassWithScopesMulti; diff --git a/tests/FunctionAnalyzerCacheTestMethods.php b/tests/FunctionAnalyzerCacheTestMethods.php index bd21d08..3732478 100644 --- a/tests/FunctionAnalyzerCacheTestMethods.php +++ b/tests/FunctionAnalyzerCacheTestMethods.php @@ -4,13 +4,8 @@ namespace Crell\AttributeUtils; -use Crell\AttributeUtils\Attributes\ClassWithProperties; use Crell\AttributeUtils\Attributes\Functions\IncludesReflection; use Crell\AttributeUtils\Attributes\Functions\SubParent; -use Crell\AttributeUtils\Attributes\ScopedClass; -use Crell\AttributeUtils\Records\ClassWithDefaultFields; -use Crell\AttributeUtils\Records\ClassWithScopes; -use Crell\AttributeUtils\Records\Point; use PHPUnit\Framework\Attributes\Test; #[IncludesReflection] diff --git a/tests/FunctionAnalyzerTest.php b/tests/FunctionAnalyzerTest.php index 29e46f9..0a7460e 100644 --- a/tests/FunctionAnalyzerTest.php +++ b/tests/FunctionAnalyzerTest.php @@ -10,10 +10,7 @@ use Crell\AttributeUtils\Attributes\Functions\RequiredArg; use Crell\AttributeUtils\Attributes\Functions\SubChild; use Crell\AttributeUtils\Attributes\Functions\SubParent; -use Crell\AttributeUtils\SubattributeReflection\ClassAllFeaturesForSubAttrib; -use Crell\AttributeUtils\SubattributeReflection\ClassWithAllFeaturesForSubAttribReflection; use Crell\AttributeUtils\SubattributeReflection\ComponentAttribute; -use Crell\AttributeUtils\SubattributeReflection\EnumForSubAttrib; use Crell\AttributeUtils\SubattributeReflection\FuncAllFeaturesForSubAttrib; use Crell\AttributeUtils\SubattributeReflection\SubAttributeReflect; use PHPUnit\Framework\Attributes\DataProvider; diff --git a/tests/InterfaceAttributes/Alias.php b/tests/InterfaceAttributes/Alias.php index 7f45c0e..9bec66c 100644 --- a/tests/InterfaceAttributes/Alias.php +++ b/tests/InterfaceAttributes/Alias.php @@ -5,7 +5,6 @@ namespace Crell\AttributeUtils\InterfaceAttributes; use Attribute; -use Crell\AttributeUtils\Multivalue; #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] class Alias implements Name diff --git a/tests/InterfaceAttributes/Names.php b/tests/InterfaceAttributes/Names.php index e8821ee..b2cd857 100644 --- a/tests/InterfaceAttributes/Names.php +++ b/tests/InterfaceAttributes/Names.php @@ -6,6 +6,7 @@ use Attribute; use Crell\AttributeUtils\HasSubAttributes; + use function Crell\fp\method; #[Attribute(Attribute::TARGET_CLASS)] diff --git a/tests/Records/ClassWithPropertySubAttributesUsingReflection.php b/tests/Records/ClassWithPropertySubAttributesUsingReflection.php index bcd59b0..11572e4 100644 --- a/tests/Records/ClassWithPropertySubAttributesUsingReflection.php +++ b/tests/Records/ClassWithPropertySubAttributesUsingReflection.php @@ -5,8 +5,8 @@ namespace Crell\AttributeUtils\Records; use Crell\AttributeUtils\Attributes\ConfigurableClassWithProperties; -use Crell\AttributeUtils\Attributes\PropertySubAttributeWithReflection; use Crell\AttributeUtils\Attributes\ConfigurablePropertyWithSubAttributes; +use Crell\AttributeUtils\Attributes\PropertySubAttributeWithReflection; #[ConfigurableClassWithProperties(propertyAttribute: ConfigurablePropertyWithSubAttributes::class)] class ClassWithPropertySubAttributesUsingReflection diff --git a/tests/Records/ClassWithSubAttributes.php b/tests/Records/ClassWithSubAttributes.php index 7cff442..2d43be7 100644 --- a/tests/Records/ClassWithSubAttributes.php +++ b/tests/Records/ClassWithSubAttributes.php @@ -5,8 +5,8 @@ namespace Crell\AttributeUtils\Records; use Crell\AttributeUtils\Attributes\ClassWithPropertiesWithSubAttributes; -use Crell\AttributeUtils\Attributes\MultiSubAttribute; use Crell\AttributeUtils\Attributes\ConfigurablePropertyWithSubAttributes; +use Crell\AttributeUtils\Attributes\MultiSubAttribute; use Crell\AttributeUtils\Attributes\PropertySubAttribute; #[ClassWithPropertiesWithSubAttributes] diff --git a/tests/ReflectTest.php b/tests/ReflectTest.php index d3bdbe8..ffde114 100644 --- a/tests/ReflectTest.php +++ b/tests/ReflectTest.php @@ -16,7 +16,6 @@ use Crell\AttributeUtils\TypeDef\BackedSuit; use Crell\AttributeUtils\TypeDef\Suit; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; diff --git a/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php b/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php index 5e8f271..01a99d9 100644 --- a/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php +++ b/tests/SubattributeReflection/ClassAllFeaturesForSubAttrib.php @@ -8,13 +8,11 @@ use Crell\AttributeUtils\Attributes\Reflect\CollectClassConstants; use Crell\AttributeUtils\Attributes\Reflect\CollectEnumCases; use Crell\AttributeUtils\Attributes\Reflect\CollectMethods; -use Crell\AttributeUtils\Attributes\Reflect\CollectParameters; use Crell\AttributeUtils\Attributes\Reflect\CollectProperties; use Crell\AttributeUtils\HasSubAttributes; use Crell\AttributeUtils\ParseClassConstants; use Crell\AttributeUtils\ParseEnumCases; use Crell\AttributeUtils\ParseMethods; -use Crell\AttributeUtils\ParseParameters; use Crell\AttributeUtils\ParseProperties; #[Attribute(Attribute::TARGET_CLASS)]