diff --git a/config/set/flow-annotations-to-attributes.php b/config/set/flow-annotations-to-attributes.php new file mode 100644 index 0000000..63c2f7b --- /dev/null +++ b/config/set/flow-annotations-to-attributes.php @@ -0,0 +1,39 @@ +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'), + ]); +}; diff --git a/src/NeosRectorSets.php b/src/NeosRectorSets.php index f1f8e3c..8db4038 100644 --- a/src/NeosRectorSets.php +++ b/src/NeosRectorSets.php @@ -8,4 +8,6 @@ class NeosRectorSets implements SetListInterface { public const CONTENTREPOSITORY_9_0 = __DIR__ . '/../config/set/contentrepository-90.php'; + + public const ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../config/set/flow-annotations-to-attributes.php'; } diff --git a/tests/Rules/AnnotationToAttribute/AnnotationToAttributeTest.php b/tests/Rules/AnnotationToAttribute/AnnotationToAttributeTest.php new file mode 100644 index 0000000..4c0cec1 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/AnnotationToAttributeTest.php @@ -0,0 +1,31 @@ +doTestFile($fileInfo); + } + + /** + * @return \Iterator + */ + public function provideData(): \Iterator + { + return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Rules/AnnotationToAttribute/Fixture/aspect.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/aspect.php.inc new file mode 100644 index 0000000..8f0b5a4 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/aspect.php.inc @@ -0,0 +1,87 @@ +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) + { + } +} + +?> +----- +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) + { + } +} + +?> diff --git a/tests/Rules/AnnotationToAttribute/Fixture/autowiring.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/autowiring.php.inc new file mode 100644 index 0000000..6b2e5d3 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/autowiring.php.inc @@ -0,0 +1,33 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/compilestatic.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/compilestatic.php.inc new file mode 100644 index 0000000..5a42940 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/compilestatic.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/entity.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/entity.php.inc new file mode 100644 index 0000000..c5dc239 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/entity.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/entitywithrepository.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/entitywithrepository.php.inc new file mode 100644 index 0000000..23d1d4d --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/entitywithrepository.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/flushescaches.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/flushescaches.php.inc new file mode 100644 index 0000000..7fd8a44 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/flushescaches.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/identity.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/identity.php.inc new file mode 100644 index 0000000..3aa9598 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/identity.php.inc @@ -0,0 +1,25 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/ignorevalidation.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/ignorevalidation.php.inc new file mode 100644 index 0000000..d3c34ca --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/ignorevalidation.php.inc @@ -0,0 +1,39 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/inject.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/inject.php.inc new file mode 100644 index 0000000..7f8cdee --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/inject.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/injectconfiguration.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/injectconfiguration.php.inc new file mode 100644 index 0000000..ca375e0 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/injectconfiguration.php.inc @@ -0,0 +1,25 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/internal.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/internal.php.inc new file mode 100644 index 0000000..09a2784 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/internal.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/lazy.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/lazy.php.inc new file mode 100644 index 0000000..7ed6414 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/lazy.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/maprequestbody.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/maprequestbody.php.inc new file mode 100644 index 0000000..77d7d6b --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/maprequestbody.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/proxy.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/proxy.php.inc new file mode 100644 index 0000000..7bd5402 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/proxy.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/scope.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/scope.php.inc new file mode 100644 index 0000000..c1b62fc --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/scope.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/session.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/session.php.inc new file mode 100644 index 0000000..4590a5d --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/session.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/signal.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/signal.php.inc new file mode 100644 index 0000000..e15d869 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/signal.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/skipcsrfprotection.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/skipcsrfprotection.php.inc new file mode 100644 index 0000000..a0f23e1 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/skipcsrfprotection.php.inc @@ -0,0 +1,29 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/transient.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/transient.php.inc new file mode 100644 index 0000000..741908f --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/transient.php.inc @@ -0,0 +1,25 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/Fixture/validate.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/validate.php.inc new file mode 100644 index 0000000..82cafe1 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/validate.php.inc @@ -0,0 +1,39 @@ + +----- + 0, 'maximum' => 40])] + protected $foo; + + #[Flow\Validate(type: 'StringLength', options: ['minimum' => 0, 'maximum' => 40])] + #[Flow\Validate(argumentName: 'resource', type: 'NotEmpty')] + public function someAction(Resource $resource, string $resourceType = ''): void + { + } +} + +?> diff --git a/tests/Rules/AnnotationToAttribute/Fixture/value_object.php.inc b/tests/Rules/AnnotationToAttribute/Fixture/value_object.php.inc new file mode 100644 index 0000000..2d87361 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/Fixture/value_object.php.inc @@ -0,0 +1,23 @@ + +----- + diff --git a/tests/Rules/AnnotationToAttribute/config/configured_rule.php b/tests/Rules/AnnotationToAttribute/config/configured_rule.php new file mode 100644 index 0000000..5a6f864 --- /dev/null +++ b/tests/Rules/AnnotationToAttribute/config/configured_rule.php @@ -0,0 +1,11 @@ +sets([ + \Neos\Rector\NeosRectorSets::ANNOTATIONS_TO_ATTRIBUTES + ]); +};