Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b4613e

Browse files
committed
minor EasyCorp#1418 Config for php cs fixer v2 (ogizanagi, javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Config for php cs fixer v2 Php-cs-fixer v2 has been released a week ago. Commits ------- a124629 Removed the PSR-4 rule ed71285 Review rules and allow risky to be executed 29c1851 Defined some new syntax rules 03deb24 Config for php cs fixer v2
2 parents d68b5e6 + a124629 commit 4b4613e

32 files changed

Lines changed: 268 additions & 254 deletions

.php_cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$finder = Symfony\CS\Finder::create()
3+
$finder = PhpCsFixer\Finder::create()
44
->in(__DIR__)
55
->ignoreDotFiles(true)
66
->ignoreVCS(true)
@@ -9,8 +9,22 @@ $finder = Symfony\CS\Finder::create()
99
->name('*.php')
1010
;
1111

12-
return Symfony\CS\Config::create()
12+
return PhpCsFixer\Config::create()
1313
->setUsingCache(true)
14-
->fixers(array('-unalign_double_arrow', '-phpdoc_short_description'))
15-
->finder($finder)
14+
->setRiskyAllowed(true)
15+
->setFinder($finder)
16+
->setRules(array(
17+
'@Symfony' => true,
18+
'array_syntax' => array('syntax' => 'long'),
19+
'binary_operator_spaces' => array(
20+
'align_double_arrow' => false,
21+
),
22+
'combine_consecutive_unsets' => true,
23+
'no_useless_else' => true,
24+
'no_useless_return' => true,
25+
'ordered_imports' => true,
26+
'php_unit_strict' => true,
27+
'phpdoc_summary' => false,
28+
'strict_comparison' => true,
29+
))
1630
;

Controller/AdminController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
use Symfony\Component\Form\FormBuilder;
2929
use Symfony\Component\Form\FormBuilderInterface;
3030
use Symfony\Component\Form\FormInterface;
31+
use Symfony\Component\HttpFoundation\JsonResponse;
3132
use Symfony\Component\HttpFoundation\RedirectResponse;
3233
use Symfony\Component\HttpFoundation\Request;
3334
use Symfony\Component\HttpFoundation\Response;
34-
use Symfony\Component\HttpFoundation\JsonResponse;
3535

3636
/**
3737
* The controller used to render all the default EasyAdmin actions.

DataCollector/EasyAdminDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace JavierEguiluz\Bundle\EasyAdminBundle\DataCollector;
1313

14+
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
1415
use Symfony\Component\HttpFoundation\Request;
1516
use Symfony\Component\HttpFoundation\Response;
1617
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
17-
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
1818
use Symfony\Component\VarDumper\Cloner\VarCloner;
1919
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
2020
use Symfony\Component\Yaml\Yaml;

DependencyInjection/EasyAdminExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace JavierEguiluz\Bundle\EasyAdminBundle\DependencyInjection;
1313

14+
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1416
use Symfony\Component\DependencyInjection\ContainerInterface;
17+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1518
use Symfony\Component\DependencyInjection\Reference;
1619
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17-
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
19-
use Symfony\Component\Config\FileLocator;
2020

2121
/**
2222
* Resolves all the backend configuration values and most of the entities

Form/Type/EasyAdminFormType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace JavierEguiluz\Bundle\EasyAdminBundle\Form\Type;
1313

14-
use JavierEguiluz\Bundle\EasyAdminBundle\Form\Type\Configurator\TypeConfiguratorInterface;
1514
use JavierEguiluz\Bundle\EasyAdminBundle\Configuration\ConfigManager;
15+
use JavierEguiluz\Bundle\EasyAdminBundle\Form\Type\Configurator\TypeConfiguratorInterface;
1616
use JavierEguiluz\Bundle\EasyAdminBundle\Form\Util\LegacyFormHelper;
1717
use Symfony\Component\Form\AbstractType;
1818
use Symfony\Component\Form\FormBuilderInterface;

Tests/Configuration/ConfigManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function ($filePath) {
8484

8585
private function isTestCompatible($filePath)
8686
{
87-
if (2 != Kernel::MAJOR_VERSION || 3 != Kernel::MINOR_VERSION) {
87+
if (2 !== Kernel::MAJOR_VERSION || 3 !== Kernel::MINOR_VERSION) {
8888
return true;
8989
}
9090

Tests/Controller/ActionTargetTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,42 @@ public function testListViewActions()
2626
{
2727
$crawler = $this->requestListView();
2828

29-
$this->assertEquals('_top', $crawler->filter('.global-actions form button[type="submit"]')->attr('formtarget'));
30-
$this->assertEquals('custom_target', $crawler->filter('.button-action a:contains("Add Category")')->attr('target'));
29+
$this->assertSame('_top', $crawler->filter('.global-actions form button[type="submit"]')->attr('formtarget'));
30+
$this->assertSame('custom_target', $crawler->filter('.button-action a:contains("Add Category")')->attr('target'));
3131

32-
$this->assertEquals('_blank', $crawler->filter('table a:contains("Edit")')->attr('target'));
33-
$this->assertEquals('_parent', $crawler->filter('table a:contains("Custom action")')->attr('target'));
34-
$this->assertEquals('_self', $crawler->filter('table a:contains("Another custom action")')->attr('target'));
35-
$this->assertEquals('_self', $crawler->filter('table a:contains("Delete")')->attr('target'));
36-
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
32+
$this->assertSame('_blank', $crawler->filter('table a:contains("Edit")')->attr('target'));
33+
$this->assertSame('_parent', $crawler->filter('table a:contains("Custom action")')->attr('target'));
34+
$this->assertSame('_self', $crawler->filter('table a:contains("Another custom action")')->attr('target'));
35+
$this->assertSame('_self', $crawler->filter('table a:contains("Delete")')->attr('target'));
36+
$this->assertSame('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
3737
}
3838

3939
public function testEditViewActions()
4040
{
4141
$crawler = $this->requestEditView();
4242

43-
$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
44-
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
45-
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
46-
$this->assertEquals('_blank', $crawler->filter('#modal-delete-button')->attr('formtarget'));
43+
$this->assertSame('_parent', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
44+
$this->assertSame('_blank', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
45+
$this->assertSame('_blank', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
46+
$this->assertSame('_blank', $crawler->filter('#modal-delete-button')->attr('formtarget'));
4747
}
4848

4949
public function testShowViewActions()
5050
{
5151
$crawler = $this->requestShowView();
5252

53-
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Edit")')->attr('target'));
54-
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
55-
$this->assertEquals('custom_target', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
56-
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
57-
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
53+
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Edit")')->attr('target'));
54+
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
55+
$this->assertSame('custom_target', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
56+
$this->assertSame('_self', $crawler->filter('.form-actions a:contains("Delete")')->attr('target'));
57+
$this->assertSame('_self', $crawler->filter('#modal-delete-button')->attr('formtarget'));
5858
}
5959

6060
public function testNewViewActions()
6161
{
6262
$crawler = $this->requestNewView();
6363

64-
$this->assertEquals('_top', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
65-
$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
64+
$this->assertSame('_top', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target'));
65+
$this->assertSame('_parent', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target'));
6666
}
6767
}

Tests/Controller/AutocompleteTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function testAutocompleteText()
5555
// the results are the first 10 parent categories
5656
$response = json_decode($this->client->getResponse()->getContent(), true);
5757
foreach (range(1, 10) as $i) {
58-
$this->assertEquals($i, $response['results'][$i - 1]['id']);
59-
$this->assertEquals('Parent Category #'.$i, $response['results'][$i - 1]['text']);
58+
$this->assertSame($i, $response['results'][$i - 1]['id']);
59+
$this->assertSame('Parent Category #'.$i, $response['results'][$i - 1]['text']);
6060
}
6161
}
6262

Tests/Controller/BackendErrorsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testUndefinedEntityError()
2929
'view' => 'list',
3030
));
3131

32-
$this->assertEquals(500, $this->client->getResponse()->getStatusCode());
32+
$this->assertSame(500, $this->client->getResponse()->getStatusCode());
3333
$this->assertContains('Entity "InexistentEntity" is not managed by EasyAdmin.', $crawler->filter('head title')->text());
3434
}
3535
}

Tests/Controller/CustomMenuTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ public function testCustomBackendHomepage()
2626
{
2727
$this->client->request('GET', '/admin/');
2828

29-
$this->assertEquals(
29+
$this->assertSame(
3030
'/admin/?action=list&entity=Category&menuIndex=0&submenuIndex=3',
3131
$this->client->getResponse()->headers->get('location')
3232
);
3333

3434
$crawler = $this->client->followRedirect();
3535

36-
$this->assertEquals(
36+
$this->assertSame(
3737
'Products',
3838
trim($crawler->filter('.sidebar-menu li.active.submenu-active a')->text())
3939
);
4040

41-
$this->assertEquals(
41+
$this->assertSame(
4242
'Categories',
4343
trim($crawler->filter('.sidebar-menu .treeview-menu li.active a')->text())
4444
);
@@ -86,13 +86,13 @@ public function testMenuIcons()
8686
{
8787
$crawler = $this->getBackendHomepage();
8888

89-
$this->assertEquals(
89+
$this->assertSame(
9090
'fa fa-shopping-basket',
9191
$crawler->filter('.sidebar-menu li:contains("Products") i')->attr('class'),
9292
'First level menu item with custom icon'
9393
);
9494

95-
$this->assertEquals(
95+
$this->assertSame(
9696
'fa fa-chevron-circle-right',
9797
$crawler->filter('.sidebar-menu li:contains("Images") i')->attr('class'),
9898
'First level menu item with default icon'
@@ -104,13 +104,13 @@ public function testMenuIcons()
104104
'First level menu item without icon'
105105
);
106106

107-
$this->assertEquals(
107+
$this->assertSame(
108108
'fa fa-th-list',
109109
$crawler->filter('.sidebar-menu .treeview-menu li:contains("List Products") i')->attr('class'),
110110
'Second level menu item with custom icon'
111111
);
112112

113-
$this->assertEquals(
113+
$this->assertSame(
114114
'fa fa-chevron-right',
115115
$crawler->filter('.sidebar-menu .treeview-menu li:contains("Add Product") i')->attr('class'),
116116
'Second level menu item with default icon'
@@ -127,17 +127,17 @@ public function testMenuTargets()
127127
{
128128
$crawler = $this->getBackendHomepage();
129129

130-
$this->assertEquals(
130+
$this->assertSame(
131131
'_blank',
132132
$crawler->filter('.sidebar-menu li:contains("Project Home") a')->attr('target')
133133
);
134134

135-
$this->assertEquals(
135+
$this->assertSame(
136136
'_self',
137137
$crawler->filter('.sidebar-menu li:contains("Documentation") a')->attr('target')
138138
);
139139

140-
$this->assertEquals(
140+
$this->assertSame(
141141
'arbitrary_value',
142142
$crawler->filter('.sidebar-menu li:contains("Report Issues") a')->attr('target')
143143
);
@@ -147,25 +147,25 @@ public function testMenuUrls()
147147
{
148148
$crawler = $this->getBackendHomepage();
149149

150-
$this->assertEquals(
150+
$this->assertSame(
151151
'#',
152152
$crawler->filter('.sidebar-menu li:contains("Products") a')->attr('href'),
153153
'First level menu, empty item'
154154
);
155155

156-
$this->assertEquals(
156+
$this->assertSame(
157157
'/admin/?entity=Image&action=list&menuIndex=1&submenuIndex=-1',
158158
$crawler->filter('.sidebar-menu li:contains("Images") a')->attr('href'),
159159
'First level menu, default link'
160160
);
161161

162-
$this->assertEquals(
162+
$this->assertSame(
163163
'/admin/?entity=Purchase&action=list&menuIndex=2&submenuIndex=-1&sortField=deliveryDate',
164164
$crawler->filter('.sidebar-menu li:contains("Purchases") a')->attr('href'),
165165
'First level menu, customized link'
166166
);
167167

168-
$this->assertEquals(
168+
$this->assertSame(
169169
'https://github.com/javiereguiluz/EasyAdminBundle',
170170
$crawler->filter('.sidebar-menu li:contains("Project Home") a')->attr('href'),
171171
'First level menu, absolute URL'
@@ -182,24 +182,24 @@ public function testMenuItemTypes()
182182
$menuConfig = $backendConfig['design']['menu'];
183183

184184
foreach ($menuConfig as $i => $itemConfig) {
185-
$this->assertEquals($expectedTypesMainMenu[$i], $itemConfig['type']);
185+
$this->assertSame($expectedTypesMainMenu[$i], $itemConfig['type']);
186186
}
187187

188188
foreach ($menuConfig[0]['children'] as $i => $itemConfig) {
189-
$this->assertEquals($expectedTypesSubMenu[$i], $itemConfig['type']);
189+
$this->assertSame($expectedTypesSubMenu[$i], $itemConfig['type']);
190190
}
191191
}
192192

193193
public function testExternalRoutesDontIncludeIndexParameters()
194194
{
195195
$crawler = $this->getBackendHomepage();
196196

197-
$this->assertEquals(
197+
$this->assertSame(
198198
'/custom-route?custom_parameter=Lorem+Ipsum',
199199
$crawler->filter('.sidebar-menu li:contains("Custom External Route") a')->attr('href')
200200
);
201201

202-
$this->assertEquals(
202+
$this->assertSame(
203203
'/admin/?menuIndex=9&submenuIndex=-1',
204204
$crawler->filter('.sidebar-menu li:contains("Custom Internal Route") a')->attr('href')
205205
);

0 commit comments

Comments
 (0)