-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from saschanowak/feature/flow-annotations-to-at…
…tributes FEATURE: Add flow annotations to attribute set
- Loading branch information
Showing
25 changed files
with
730 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare (strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; | ||
use Rector\Php80\ValueObject\AnnotationToAttribute; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\After'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\AfterReturning'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\AfterThrowing'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Around'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Aspect'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Autowiring'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Before'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\CompileStatic'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Entity'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\FlushesCaches'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Identity'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\IgnoreValidation'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Inject'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\InjectConfiguration'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Internal'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Introduce'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Lazy'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\MapRequestBody'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Pointcut'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Proxy'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Scope'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Session'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Signal'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\SkipCsrfProtection'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Transient'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\Validate'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\ValidationGroups'), | ||
new AnnotationToAttribute('Neos\\Flow\\Annotations\\ValueObject'), | ||
]); | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
tests/Rules/AnnotationToAttribute/AnnotationToAttributeTest.php
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Rector\Tests\Rules\AnnotationToAttribute; | ||
|
||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class AnnotationToAttributeTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $fileInfo): void | ||
{ | ||
$this->doTestFile($fileInfo); | ||
} | ||
|
||
/** | ||
* @return \Iterator<string> | ||
*/ | ||
public function provideData(): \Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
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,87 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Aop\JoinPointInterface; | ||
use Neos\Flow\Aop\PointcutFilterInterface; | ||
|
||
/** | ||
* @Flow\Aspect | ||
*/ | ||
class SomeAspect | ||
{ | ||
/** | ||
* @Flow\Around("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function around(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
/** | ||
* @Flow\Before("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function before(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
/** | ||
* @Flow\AfterReturning("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function afterReturning(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
/** | ||
* @Flow\AfterThrowing("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function afterThrowing(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
/** | ||
* @Flow\After("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function after(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
/** | ||
* @Flow\Pointcut("method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())") | ||
*/ | ||
public function pointcut(PointcutFilterInterface $joinPoint) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Aop\JoinPointInterface; | ||
use Neos\Flow\Aop\PointcutFilterInterface; | ||
|
||
#[Flow\Aspect] | ||
class SomeAspect | ||
{ | ||
#[Flow\Around('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function around(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
#[Flow\Before('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function before(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
#[Flow\AfterReturning('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function afterReturning(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
#[Flow\AfterThrowing('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function afterThrowing(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
#[Flow\After('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function after(JoinPointInterface $joinPoint) | ||
{ | ||
} | ||
#[Flow\Pointcut('method(Neos\Flow\ResourceManagement\ResourceManager->getPublicPackageResourceUri())')] | ||
public function pointcut(PointcutFilterInterface $joinPoint) | ||
{ | ||
} | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
tests/Rules/AnnotationToAttribute/Fixture/autowiring.php.inc
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,33 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @Flow\Autowiring(false) | ||
*/ | ||
class SomeClass | ||
{ | ||
/** | ||
* @Flow\Autowiring(enabled=false) | ||
*/ | ||
public function someAction(Resource $resource, string $resourceType = ''): void | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
#[Flow\Autowiring(false)] | ||
class SomeClass | ||
{ | ||
#[Flow\Autowiring(enabled: false)] | ||
public function someAction(Resource $resource, string $resourceType = ''): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
tests/Rules/AnnotationToAttribute/Fixture/compilestatic.php.inc
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,29 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
/** | ||
* @Flow\CompileStatic | ||
*/ | ||
public function someAction(): void | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
#[Flow\CompileStatic] | ||
public function someAction(): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
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,23 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @Flow\Entity() | ||
*/ | ||
class SomeClass | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
#[Flow\Entity] | ||
class SomeClass | ||
{ | ||
} | ||
|
||
?> |
23 changes: 23 additions & 0 deletions
23
tests/Rules/AnnotationToAttribute/Fixture/entitywithrepository.php.inc
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,23 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
/** | ||
* @Flow\Entity(repositoryClass=FooRepository::class, readOnly=true) | ||
*/ | ||
class SomeClass | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
#[Flow\Entity(repositoryClass: FooRepository::class, readOnly: true)] | ||
class SomeClass | ||
{ | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
tests/Rules/AnnotationToAttribute/Fixture/flushescaches.php.inc
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,29 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
/** | ||
* @Flow\FlushesCaches | ||
*/ | ||
public function someCommand(): void | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
#[Flow\FlushesCaches] | ||
public function someCommand(): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
25 changes: 25 additions & 0 deletions
25
tests/Rules/AnnotationToAttribute/Fixture/identity.php.inc
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,25 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
/** | ||
* @Flow\Identity | ||
*/ | ||
protected string $foo; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
#[Flow\Identity] | ||
protected string $foo; | ||
} | ||
|
||
?> |
39 changes: 39 additions & 0 deletions
39
tests/Rules/AnnotationToAttribute/Fixture/ignorevalidation.php.inc
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,39 @@ | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
/** | ||
* @Flow\IgnoreValidation | ||
*/ | ||
protected $foo; | ||
|
||
/** | ||
* @Flow\IgnoreValidation(argumentName="resource") | ||
* @Flow\IgnoreValidation(argumentName="resourceType") | ||
*/ | ||
public function someAction(Resource $resource, string $resourceType = ''): void | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
|
||
class SomeClass | ||
{ | ||
#[Flow\IgnoreValidation] | ||
protected $foo; | ||
|
||
#[Flow\IgnoreValidation(argumentName: 'resource')] | ||
#[Flow\IgnoreValidation(argumentName: 'resourceType')] | ||
public function someAction(Resource $resource, string $resourceType = ''): void | ||
{ | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.