Skip to content

Commit 7328d26

Browse files
committed
Fix code style errors in FilterHelper
1 parent a08a3d8 commit 7328d26

File tree

4 files changed

+46
-60
lines changed

4 files changed

+46
-60
lines changed

src/Model/Behavior/FilteredBehavior.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
declare(strict_types=1);
3-
42
namespace Filter\Model\Behavior;
53

64
use ArrayObject;
@@ -129,7 +127,7 @@ protected function addFieldToFilter(Table $Table, Query $Query, $values, $field,
129127
$configurationFieldName = $field;
130128

131129
if (strpos($field, '.') !== false) {
132-
[$configurationModelName, $configurationFieldName] = explode('.', $field);
130+
list($configurationModelName, $configurationFieldName) = explode('.', $field);
133131
}
134132

135133
if (!isset($values[$configurationModelName][$configurationFieldName]) && isset($fieldOptions['default'])) {
@@ -173,7 +171,7 @@ protected function addFieldToFilter(Table $Table, Query $Query, $values, $field,
173171

174172
if (isset($fieldOptions['filterField'])) {
175173
if (strpos($fieldOptions['filterField'], '.') !== false) {
176-
[$filterModelName, $filterFieldName] = explode('.', $fieldOptions['filterField']);
174+
list($filterModelName, $filterFieldName) = explode('.', $fieldOptions['filterField']);
177175

178176
if ($filterModelName != $Table->getAlias()) {
179177
$filterModelName = 'Filter' . $filterModelName;

src/View/Helper/FilterHelper.php

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,88 +14,80 @@
1414
MPL <http://www.mozilla.org/MPL/MPL-1.1.html>
1515
LGPL <http://www.gnu.org/licenses/lgpl.html>
1616
GPL <http://www.gnu.org/licenses/gpl.html>
17-
*/
17+
*/
1818

1919
class FilterHelper extends Helper
2020
{
2121
/**
2222
* @param string $modelName
23-
* @param mixed[] $options
23+
* @param array<mixed> $options
2424
* @return string
2525
*/
2626
public function filterForm($modelName, $options)
2727
{
2828
$view =& $this->_View;
2929

30-
$output = $view->element
31-
(
32-
'filter_form_begin',
33-
array
34-
(
30+
$output = $view->element(
31+
'filter_form_begin',
32+
[
3533
'plugin' => 'Filter',
3634
'modelName' => $modelName,
37-
'options' => $options
38-
),
39-
array('plugin' => 'Filter')
40-
);
41-
42-
$output .= $view->element
43-
(
44-
'filter_form_fields',
45-
array('plugin' => 'Filter'),
46-
array('plugin' => 'Filter')
47-
);
48-
49-
$output .= $view->element
50-
(
51-
'filter_form_end',
52-
array('plugin' => 'Filter'),
53-
array('plugin' => 'Filter')
54-
);
35+
'options' => $options,
36+
],
37+
['plugin' => 'Filter']
38+
);
39+
40+
$output .= $view->element(
41+
'filter_form_fields',
42+
['plugin' => 'Filter'],
43+
['plugin' => 'Filter']
44+
);
45+
46+
$output .= $view->element(
47+
'filter_form_end',
48+
['plugin' => 'Filter'],
49+
['plugin' => 'Filter']
50+
);
5551

5652
return $output;
5753
}
5854

5955
/**
6056
* @param string $modelName
61-
* @param mixed[] $options
57+
* @param array<mixed> $options
6258
* @return string
6359
*/
6460
public function beginForm($modelName, $options)
6561
{
6662
$view =& $this->_View;
67-
$output = $view->element
68-
(
69-
'filter_form_begin',
70-
array
71-
(
63+
$output = $view->element(
64+
'filter_form_begin',
65+
[
7266
'plugin' => 'Filter',
7367
'modelName' => $modelName,
74-
'options' => $options
75-
),
76-
array('plugin' => 'Filter')
77-
);
68+
'options' => $options,
69+
],
70+
['plugin' => 'Filter']
71+
);
7872

7973
return $output;
8074
}
8175

8276
/**
83-
* @param string[] $fields
77+
* @param array<string> $fields
8478
* @return string
8579
*/
86-
public function inputFields($fields = array())
80+
public function inputFields($fields = [])
8781
{
8882
$view =& $this->_View;
89-
$output = $view->element
90-
(
91-
'filter_form_fields',
92-
array
93-
(
83+
$output = $view->element(
84+
'filter_form_fields',
85+
[
9486
'plugin' => 'Filter',
95-
'includeFields' => $fields
96-
),
97-
array('plugin' => 'Filter')
98-
);
87+
'includeFields' => $fields,
88+
],
89+
['plugin' => 'Filter']
90+
);
9991

10092
return $output;
10193
}
@@ -106,12 +98,11 @@ public function inputFields($fields = array())
10698
public function endForm()
10799
{
108100
$view = $this->_View;
109-
$output = $view->element
110-
(
111-
'filter_form_end',
112-
array(),
113-
array('plugin' => 'Filter')
114-
);
101+
$output = $view->element(
102+
'filter_form_end',
103+
[],
104+
['plugin' => 'Filter']
105+
);
115106

116107
return $output;
117108
}

tests/TestCase/Model/Behavior/FilteredBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ public function testBeforeDataFilterCallbackCancel()
914914

915915
$expected =
916916
[
917-
['id' => 1, 'title' => 'Testing Doc', 'document_category_id' => 1, 'owner_id' => 1, 'is_private' => 0,],
917+
['id' => 1, 'title' => 'Testing Doc', 'document_category_id' => 1, 'owner_id' => 1, 'is_private' => 0],
918918
['id' => 2, 'title' => 'Imaginary Spec', 'document_category_id' => 1, 'owner_id' => 1, 'is_private' => 0],
919919
['id' => 3, 'title' => 'Nonexistant data', 'document_category_id' => 1, 'owner_id' => 1, 'is_private' => 0],
920920
['id' => 4, 'title' => 'Illegal explosives DIY', 'document_category_id' => 1, 'owner_id' => 1, 'is_private' => 1],

tests/bootstrap.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
3-
declare(strict_types=1);
4-
52
use Cake\Datasource\ConnectionManager;
63

74
/**

0 commit comments

Comments
 (0)