-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the InheritsAttributes attribute
- Loading branch information
Showing
10 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace olvlvl\ComposerAttributeCollector; | ||
|
||
use Attribute; | ||
|
||
/** | ||
* Use this attribute when a class inherits attributes from traits or parents and is ignored by the collector. | ||
*/ | ||
#[Attribute(Attribute::TARGET_CLASS)] | ||
final class InheritsAttributes | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Acme\Attribute\Routing; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
final class UrlGetter | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Acme\PSR4; | ||
|
||
use Acme\PSR4\Routing\UrlTrait; | ||
use olvlvl\ComposerAttributeCollector\InheritsAttributes; | ||
|
||
#[InheritsAttributes] | ||
class InheritedAttributeSample | ||
{ | ||
use UrlTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Acme\PSR4\Routing; | ||
|
||
use Acme\Attribute\Routing\UrlGetter; | ||
|
||
trait UrlTrait | ||
{ | ||
#[UrlGetter] | ||
public function get_url(): string | ||
{ | ||
return '/url'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
<?php | ||
|
||
/* | ||
* (c) Olivier Laviale <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace tests\olvlvl\ComposerAttributeCollector; | ||
|
||
use Acme\Attribute\ActiveRecord\Boolean; | ||
|
@@ -21,6 +14,7 @@ | |
use Acme\Attribute\Permission; | ||
use Acme\Attribute\Resource; | ||
use Acme\Attribute\Route; | ||
use Acme\Attribute\Routing\UrlGetter; | ||
use Acme\Attribute\Subscribe; | ||
use Acme\PSR4\Presentation\ArticleController; | ||
use Composer\IO\NullIO; | ||
|
@@ -44,9 +38,6 @@ final class PluginTest extends TestCase | |
{ | ||
private static bool $initialized = false; | ||
|
||
/** | ||
* @throws ReflectionException | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
@@ -184,6 +175,12 @@ public static function provideTargetMethods(): array | |
[ new Subscribe(), 'Acme\PSR4\SubscriberB::onEventA' ], | ||
] | ||
], | ||
[ | ||
UrlGetter::class, | ||
[ | ||
[ new UrlGetter(), 'Acme\PSR4\InheritedAttributeSample::get_url' ] | ||
] | ||
], | ||
|
||
]; | ||
} | ||
|