[export][rector] rector rules to add get form default data on export, aggregator, direct export

This commit is contained in:
Julien Fastré 2023-06-05 16:41:55 +02:00
parent 02afcb30d4
commit d5ee158caa
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
4 changed files with 314 additions and 1 deletions

View File

@ -11,6 +11,9 @@ declare(strict_types=1);
namespace Utils\Rector\Rector;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Export\DirectExportInterface;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FilterInterface;
use PhpParser\Node;
use Rector\Core\Rector\AbstractRector;
@ -43,7 +46,12 @@ class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector extends Abstra
return null;
}
if (!$this->classAnalyzer->hasImplements($node, FilterInterface::class)) {
if (
!$this->classAnalyzer->hasImplements($node, FilterInterface::class)
&& !$this->classAnalyzer->hasImplements($node, AggregatorInterface::class)
&& !$this->classAnalyzer->hasImplements($node, ExportInterface::class)
&& !$this->classAnalyzer->hasImplements($node, DirectExportInterface::class)
) {
return null;
}

View File

@ -0,0 +1,133 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\ExportInterface;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements ExportInterface
{
public function buildForm(FormBuilderInterface $builder)
{
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
public function getAllowedFormattersTypes()
{
// TODO: Implement getAllowedFormattersTypes() method.
}
public function getDescription()
{
// TODO: Implement getDescription() method.
}
public function getLabels($key, array $values, $data)
{
// TODO: Implement getLabels() method.
}
public function getQueryKeys($data)
{
// TODO: Implement getQueryKeys() method.
}
public function getResult($query, $data)
{
// TODO: Implement getResult() method.
}
public function getType()
{
// TODO: Implement getType() method.
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
// TODO: Implement initiateQuery() method.
}
public function requiredRole(): string
{
// TODO: Implement requiredRole() method.
}
public function supportsModifiers()
{
// TODO: Implement supportsModifiers() method.
}
}
?>
-----
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\ExportInterface;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements ExportInterface
{
public function buildForm(FormBuilderInterface $builder)
{
}
public function getFormDefaultData(): array
{
return [];
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
public function getAllowedFormattersTypes()
{
// TODO: Implement getAllowedFormattersTypes() method.
}
public function getDescription()
{
// TODO: Implement getDescription() method.
}
public function getLabels($key, array $values, $data)
{
// TODO: Implement getLabels() method.
}
public function getQueryKeys($data)
{
// TODO: Implement getQueryKeys() method.
}
public function getResult($query, $data)
{
// TODO: Implement getResult() method.
}
public function getType()
{
// TODO: Implement getType() method.
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
// TODO: Implement initiateQuery() method.
}
public function requiredRole(): string
{
// TODO: Implement requiredRole() method.
}
public function supportsModifiers()
{
// TODO: Implement supportsModifiers() method.
}
}
?>

View File

@ -0,0 +1,77 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\DirectExportInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
class MyClass implements DirectExportInterface
{
public function generate(array $acl, array $data = []): Response
{
// TODO: Implement generate() method.
}
public function getDescription(): string
{
// TODO: Implement getDescription() method.
}
public function requiredRole(): string
{
// TODO: Implement requiredRole() method.
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
}
?>
-----
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\DirectExportInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Response;
class MyClass implements DirectExportInterface
{
public function generate(array $acl, array $data = []): Response
{
// TODO: Implement generate() method.
}
public function getDescription(): string
{
// TODO: Implement getDescription() method.
}
public function requiredRole(): string
{
// TODO: Implement requiredRole() method.
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
public function getFormDefaultData(): array
{
return [];
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
}
?>

View File

@ -0,0 +1,95 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\AggregatorInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements AggregatorInterface
{
public function getLabels($key, array $values, $data)
{
// TODO: Implement getLabels() method.
}
public function getQueryKeys($data)
{
// TODO: Implement getQueryKeys() method.
}
public function buildForm(FormBuilderInterface $builder)
{
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
public function addRole(): ?string
{
// TODO: Implement addRole() method.
}
public function alterQuery(QueryBuilder $qb, $data)
{
// TODO: Implement alterQuery() method.
}
public function applyOn()
{
// TODO: Implement applyOn() method.
}
}
?>
-----
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\AggregatorInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements AggregatorInterface
{
public function getLabels($key, array $values, $data)
{
// TODO: Implement getLabels() method.
}
public function getQueryKeys($data)
{
// TODO: Implement getQueryKeys() method.
}
public function buildForm(FormBuilderInterface $builder)
{
}
public function getFormDefaultData(): array
{
return [];
}
public function getTitle()
{
// TODO: Implement getTitle() method.
}
public function addRole(): ?string
{
// TODO: Implement addRole() method.
}
public function alterQuery(QueryBuilder $qb, $data)
{
// TODO: Implement alterQuery() method.
}
public function applyOn()
{
// TODO: Implement applyOn() method.
}
}
?>