[export][rector] first rector rule to add new method to filters

This commit is contained in:
2023-06-04 01:11:38 +02:00
parent cb0a6bbd21
commit 02afcb30d4
12 changed files with 700 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
/**
* @internal
* @coversNothing
*/
class ChillBundleAddFormDefaultDataOnExportFilterAggregatorRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData
*/
public function test(string $file): void
{
$this->doTestFile($file);
}
public function provideData(): \Iterator
{
return self::yieldFilesFromDirectory(__DIR__.'/Fixture');
}
public function provideConfigFilePath(): string
{
return __DIR__.'/config/config.php';
}
}

View File

@@ -0,0 +1,107 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('foo', PickRollingDateType::class, [
'label' => 'Test thing',
'data' => new RollingDate(RollingDate::T_TODAY)
]);
$builder->add('baz', TextType::class, [
'label' => 'OrNiCar',
'data' => 'Castor'
]);
}
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\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('foo', PickRollingDateType::class, [
'label' => 'Test thing'
]);
$builder->add('baz', TextType::class, [
'label' => 'OrNiCar'
]);
}
public function getFormDefaultData(): array
{
return ['foo' => new RollingDate(RollingDate::T_TODAY), 'baz' => 'Castor'];
}
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.
}
}
?>

View File

@@ -0,0 +1,105 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('foo', PickRollingDateType::class, [
'label' => 'Test thing',
]);
$builder->add('baz', TextType::class, [
'label' => 'OrNiCar',
]);
}
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\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('foo', PickRollingDateType::class, [
'label' => 'Test thing',
]);
$builder->add('baz', TextType::class, [
'label' => 'OrNiCar',
]);
}
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.
}
}
?>

View File

@@ -0,0 +1,96 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('test', PickRollingDateType::class, [
'label' => 'Test thing',
'data' => new RollingDate(RollingDate::T_TODAY)
]);
}
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\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('test', PickRollingDateType::class, [
'label' => 'Test thing'
]);
}
public function getFormDefaultData(): array
{
return ['test' => new RollingDate(RollingDate::T_TODAY)];
}
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.
}
}
?>

View File

@@ -0,0 +1,87 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\FilterInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
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\FilterInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
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.
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
namespace Utils\Rector\Tests\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector\Fixture;
use Chill\MainBundle\Export\FilterInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class MyClass implements FilterInterface
{
public function describeAction($data, $format = 'string')
{
// TODO: Implement describeAction() method.
}
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
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.
}
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
return static function (\Rector\Config\RectorConfig $rectorConfig): void {
$rectorConfig->rule(\Utils\Rector\Rector\ChillBundleAddFormDefaultDataOnExportFilterAggregatorRector::class);
};