Skip to content

Commit b9e4d94

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents 508847e + 32cb577 commit b9e4d94

14 files changed

+308
-308
lines changed

AbstractUriElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class AbstractUriElement
4242
*/
4343
public function __construct(\DOMElement $node, string $currentUri, ?string $method = 'GET')
4444
{
45-
if (!\in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
45+
if (!\in_array(strtolower(substr($currentUri, 0, 4)), ['http', 'file'])) {
4646
throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
4747
}
4848

@@ -144,7 +144,7 @@ protected function canonicalizePath($path)
144144
$path .= '/';
145145
}
146146

147-
$output = array();
147+
$output = [];
148148

149149
foreach (explode('/', $path) as $segment) {
150150
if ('..' === $segment) {

Field/ChoiceFormField.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ChoiceFormField extends FormField
4545
public function hasValue()
4646
{
4747
// don't send a value for unchecked checkboxes
48-
if (\in_array($this->type, array('checkbox', 'radio')) && null === $this->value) {
48+
if (\in_array($this->type, ['checkbox', 'radio']) && null === $this->value) {
4949
return false;
5050
}
5151

@@ -211,7 +211,7 @@ protected function initialize()
211211
}
212212

213213
$this->value = null;
214-
$this->options = array();
214+
$this->options = [];
215215
$this->multiple = false;
216216

217217
if ('input' == $this->node->nodeName) {
@@ -226,7 +226,7 @@ protected function initialize()
226226
$this->type = 'select';
227227
if ($this->node->hasAttribute('multiple')) {
228228
$this->multiple = true;
229-
$this->value = array();
229+
$this->value = [];
230230
$this->name = str_replace('[]', '', $this->name);
231231
}
232232

@@ -257,7 +257,7 @@ protected function initialize()
257257
*/
258258
private function buildOptionValue(\DOMElement $node): array
259259
{
260-
$option = array();
260+
$option = [];
261261

262262
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
263263
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
@@ -297,7 +297,7 @@ public function containsOption($optionValue, $options)
297297
*/
298298
public function availableOptionValues()
299299
{
300-
$values = array();
300+
$values = [];
301301

302302
foreach ($this->options as $option) {
303303
$values[] = $option['value'];

Field/FileFormField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class FileFormField extends FormField
2727
*/
2828
public function setErrorCode($error)
2929
{
30-
$codes = array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION);
30+
$codes = [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION];
3131
if (!\in_array($error, $codes)) {
3232
throw new \InvalidArgumentException(sprintf('The error code %s is not valid.', $error));
3333
}
3434

35-
$this->value = array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0);
35+
$this->value = ['name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0];
3636
}
3737

3838
/**
@@ -75,7 +75,7 @@ public function setValue($value)
7575
$value = '';
7676
}
7777

78-
$this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size);
78+
$this->value = ['name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size];
7979
}
8080

8181
/**

Form.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setValues(array $values)
8787
*/
8888
public function getValues()
8989
{
90-
$values = array();
90+
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
9292
if ($field->isDisabled()) {
9393
continue;
@@ -108,11 +108,11 @@ public function getValues()
108108
*/
109109
public function getFiles()
110110
{
111-
if (!\in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
112-
return array();
111+
if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
112+
return [];
113113
}
114114

115-
$files = array();
115+
$files = [];
116116

117117
foreach ($this->fields->all() as $name => $field) {
118118
if ($field->isDisabled()) {
@@ -137,13 +137,13 @@ public function getFiles()
137137
*/
138138
public function getPhpValues()
139139
{
140-
$values = array();
140+
$values = [];
141141
foreach ($this->getValues() as $name => $value) {
142-
$qs = http_build_query(array($name => $value), '', '&');
142+
$qs = http_build_query([$name => $value], '', '&');
143143
if (!empty($qs)) {
144144
parse_str($qs, $expandedValue);
145145
$varName = substr($name, 0, \strlen(key($expandedValue)));
146-
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
146+
$values = array_replace_recursive($values, [$varName => current($expandedValue)]);
147147
}
148148
}
149149

@@ -164,9 +164,9 @@ public function getPhpValues()
164164
*/
165165
public function getPhpFiles()
166166
{
167-
$values = array();
167+
$values = [];
168168
foreach ($this->getFiles() as $name => $value) {
169-
$qs = http_build_query(array($name => $value), '', '&');
169+
$qs = http_build_query([$name => $value], '', '&');
170170
if (!empty($qs)) {
171171
parse_str($qs, $expandedValue);
172172
$varName = substr($name, 0, \strlen(key($expandedValue)));
@@ -182,7 +182,7 @@ function (&$value, $key) {
182182

183183
reset($expandedValue);
184184

185-
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
185+
$values = array_replace_recursive($values, [$varName => current($expandedValue)]);
186186
}
187187
}
188188

@@ -202,9 +202,9 @@ public function getUri()
202202
{
203203
$uri = parent::getUri();
204204

205-
if (!\in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
205+
if (!\in_array($this->getMethod(), ['POST', 'PUT', 'DELETE', 'PATCH'])) {
206206
$query = parse_url($uri, PHP_URL_QUERY);
207-
$currentParameters = array();
207+
$currentParameters = [];
208208
if ($query) {
209209
parse_str($query, $currentParameters);
210210
}
@@ -379,7 +379,7 @@ public function disableValidation()
379379
protected function setNode(\DOMElement $node)
380380
{
381381
$this->button = $node;
382-
if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) {
382+
if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image']))) {
383383
if ($node->hasAttribute('form')) {
384384
// if the node has the HTML5-compliant 'form' attribute, use it
385385
$formId = $node->getAttribute('form');
@@ -480,7 +480,7 @@ private function addField(\DOMElement $node)
480480
}
481481
} elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) {
482482
$this->set(new Field\FileFormField($node));
483-
} elseif ('input' == $nodeName && !\in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) {
483+
} elseif ('input' == $nodeName && !\in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image'])) {
484484
$this->set(new Field\InputFormField($node));
485485
} elseif ('textarea' == $nodeName) {
486486
$this->set(new Field\TextareaFormField($node));

FormFieldRegistry.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class FormFieldRegistry
2222
{
23-
private $fields = array();
23+
private $fields = [];
2424

2525
private $base;
2626

@@ -34,7 +34,7 @@ public function add(FormField $field)
3434
$target = &$this->fields;
3535
while ($segments) {
3636
if (!\is_array($target)) {
37-
$target = array();
37+
$target = [];
3838
}
3939
$path = array_shift($segments);
4040
if ('' === $path) {
@@ -133,7 +133,7 @@ public function set($name, $value)
133133
/**
134134
* Returns the list of field with their value.
135135
*
136-
* @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value)
136+
* @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value)
137137
*/
138138
public function all()
139139
{
@@ -167,9 +167,9 @@ private static function create($base, array $values)
167167
* @param string $base The name of the base field
168168
* @param array $output The initial values
169169
*
170-
* @return array The list of fields as array((string) Fully qualified name => (mixed) value)
170+
* @return array The list of fields as [string] Fully qualified name => (mixed) value)
171171
*/
172-
private function walk(array $array, $base = '', array &$output = array())
172+
private function walk(array $array, $base = '', array &$output = [])
173173
{
174174
foreach ($array as $k => $v) {
175175
$path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
@@ -186,7 +186,7 @@ private function walk(array $array, $base = '', array &$output = array())
186186
/**
187187
* Splits a field name into segments as a web browser would do.
188188
*
189-
* getSegments('base[foo][3][]') = array('base', 'foo, '3', '');
189+
* getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
190190
*
191191
* @param string $name The name of the field
192192
*
@@ -195,7 +195,7 @@ private function walk(array $array, $base = '', array &$output = array())
195195
private function getSegments($name)
196196
{
197197
if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
198-
$segments = array($m['base']);
198+
$segments = [$m['base']];
199199
while (!empty($m['extra'])) {
200200
$extra = $m['extra'];
201201
if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
@@ -208,6 +208,6 @@ private function getSegments($name)
208208
return $segments;
209209
}
210210

211-
return array($name);
211+
return [$name];
212212
}
213213
}

0 commit comments

Comments
 (0)