adapt rector rules for chained builder->add

This commit is contained in:
2023-06-16 15:26:49 +02:00
parent 3fb97c3945
commit c52ba06ea0
2 changed files with 188 additions and 36 deletions

View File

@@ -0,0 +1,111 @@
<?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)
])
->anotherCall('test')
->add('baz', TextType::class, [
'label' => 'OrNiCar',
'data' => 'Castor'
])
->baz('foo');
}
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'
])
->anotherCall('test')
->add('baz', TextType::class, [
'label' => 'OrNiCar'
])
->baz('foo');
}
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.
}
}
?>