mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
DX: apply rector rulesset up to PHP72
This commit is contained in:
@@ -192,9 +192,7 @@ class CreateFieldsOnGroupCommand extends Command
|
||||
|
||||
foreach ($languages as $lang) {
|
||||
//todo replace with service to find lang when available
|
||||
$names[] = (isset($cf->getName()[$lang])) ?
|
||||
$cf->getName()[$lang] :
|
||||
'Not available in this language';
|
||||
$names[] = $cf->getName()[$lang] ?? 'Not available in this language';
|
||||
}
|
||||
|
||||
if ($this->validator->validate($cf)) {
|
||||
@@ -249,9 +247,7 @@ class CreateFieldsOnGroupCommand extends Command
|
||||
|
||||
foreach ($languages as $lang) {
|
||||
//todo replace with service to find lang when available
|
||||
$row[] = (isset($customFieldGroup->getName()[$lang])) ?
|
||||
$customFieldGroup->getName()[$lang] :
|
||||
'Not available in this language';
|
||||
$row[] = $customFieldGroup->getName()[$lang] ?? 'Not available in this language';
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
@@ -294,7 +294,7 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
public function render($value, CustomField $customField, $documentType = 'html')
|
||||
{
|
||||
//extract the data. They are under a _choice key if they are stored with allow_other
|
||||
$data = (isset($value['_choices'])) ? $value['_choices'] : $value;
|
||||
$data = $value['_choices'] ?? $value;
|
||||
$selected = (is_array($data)) ? $data : [$data];
|
||||
$choices = $customField->getOptions()[self::CHOICES];
|
||||
|
||||
|
@@ -104,7 +104,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface
|
||||
$manager->persist($parent);
|
||||
|
||||
//Load children
|
||||
$expected_nb_children = mt_rand(10, 50);
|
||||
$expected_nb_children = random_int(10, 50);
|
||||
|
||||
for ($i = 0; $i < $expected_nb_children; ++$i) {
|
||||
$companyName = $this->fakerFr->company;
|
||||
@@ -144,7 +144,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface
|
||||
$manager->persist($parent);
|
||||
|
||||
//Load children
|
||||
$expected_nb_children = mt_rand(10, 50);
|
||||
$expected_nb_children = random_int(10, 50);
|
||||
|
||||
for ($i = 0; $i < $expected_nb_children; ++$i) {
|
||||
$manager->persist($this->createChildOption($parent, [
|
||||
|
@@ -25,7 +25,7 @@ class Configuration implements ConfigurationInterface
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_custom_fields');
|
||||
$rootNode = $treeBuilder->getRootNode('chill_custom_fields');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
||||
$classInfo = 'The class which may receive custom fields';
|
||||
$nameInfo = 'The name which will appears in the user interface. May be translatable';
|
||||
|
@@ -119,7 +119,7 @@ class CustomFieldType extends AbstractType
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomField',
|
||||
'data_class' => \Chill\CustomFieldsBundle\Entity\CustomField::class,
|
||||
]);
|
||||
|
||||
$resolver->setRequired(['type', 'group_widget'])
|
||||
|
@@ -38,7 +38,7 @@ class ChoicesListType extends AbstractType
|
||||
$formData = $form->getData();
|
||||
|
||||
if (null === $formData['slug']) {
|
||||
$slug = uniqid(mt_rand(), true);
|
||||
$slug = uniqid(random_int(0, mt_getrandmax()), true);
|
||||
|
||||
$data['slug'] = $slug;
|
||||
$event->setData($data);
|
||||
|
@@ -49,7 +49,7 @@ class CustomFieldType extends AbstractType
|
||||
{
|
||||
$resolver
|
||||
->setRequired(['group'])
|
||||
->addAllowedTypes('group', ['Chill\CustomFieldsBundle\Entity\CustomFieldsGroup']);
|
||||
->addAllowedTypes('group', [\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
|
@@ -49,7 +49,7 @@ class CustomFieldsHelper
|
||||
public function isEmptyValue(array $fields, CustomField $customField)
|
||||
{
|
||||
$slug = $customField->getSlug();
|
||||
$rawValue = (isset($fields[$slug])) ? $fields[$slug] : null;
|
||||
$rawValue = $fields[$slug] ?? null;
|
||||
$customFieldType = $this->provider->getCustomFieldByType($customField->getType());
|
||||
|
||||
$deserializedValue = $customFieldType->deserialize($rawValue, $customField);
|
||||
@@ -71,7 +71,7 @@ class CustomFieldsHelper
|
||||
public function renderCustomField(array $fields, CustomField $customField, $documentType = 'html')
|
||||
{
|
||||
$slug = $customField->getSlug();
|
||||
$rawValue = (isset($fields[$slug])) ? $fields[$slug] : null;
|
||||
$rawValue = $fields[$slug] ?? null;
|
||||
$customFieldType = $this->provider->getCustomFieldByType($customField->getType());
|
||||
|
||||
return $customFieldType->render($rawValue, $customField, $documentType);
|
||||
|
@@ -52,7 +52,7 @@ final class CustomFieldsGroupControllerTest extends WebTestCase
|
||||
// Fill in the form and submit it
|
||||
$form = $crawler->selectButton('Créer')->form([
|
||||
'custom_fields_group[name][fr]' => 'Test',
|
||||
'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person',
|
||||
'custom_fields_group[entity]' => \Chill\PersonBundle\Entity\Person::class,
|
||||
]);
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
|
@@ -34,12 +34,12 @@ trait CustomFieldTestHelper
|
||||
$kernel = static::$kernel;
|
||||
|
||||
//check a kernel is accessible
|
||||
$customFieldsGroup = $this->createMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
|
||||
$customFieldsGroup = $this->createMock(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class);
|
||||
$customFieldsGroup->expects($this->once())
|
||||
->method('getActiveCustomFields')
|
||||
->will($this->returnValue([$field]));
|
||||
|
||||
$request = $this->createMock('Symfony\Component\HttpFoundation\Request');
|
||||
$request = $this->createMock(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->expects($this->any())
|
||||
->method('getLocale')
|
||||
->will($this->returnValue($locale));
|
||||
|
@@ -41,11 +41,11 @@ final class CustomFieldsTextTest extends WebTestCase
|
||||
$customField = $this->customFieldProvider->getCustomFieldByType('text');
|
||||
|
||||
$this->assertInstanceOf(
|
||||
'Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface',
|
||||
\Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface::class,
|
||||
$customField
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'Chill\CustomFieldsBundle\CustomFields\CustomFieldText',
|
||||
\Chill\CustomFieldsBundle\CustomFields\CustomFieldText::class,
|
||||
$customField
|
||||
);
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase
|
||||
// set locale to fr
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend('Symfony\Component\HttpFoundation\Request');
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
self::$kernel->getContainer()->get('request_stack')
|
||||
->push($request->reveal());
|
||||
|
@@ -48,7 +48,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase
|
||||
// set locale to fr
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend('Symfony\Component\HttpFoundation\Request');
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
self::$kernel->getContainer()->get('request_stack')
|
||||
->push($request->reveal());
|
||||
|
Reference in New Issue
Block a user