Skip to content

Commit 4105e02

Browse files
committed
Merge branch '4.2' into short-array-master
* 4.2: fixed CS fixed CS fixed tests fixed CS fixed CS 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 de43e70 + d847676 commit 4105e02

14 files changed

+297
-297
lines changed

AbstractUriElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(\DOMElement $node, string $currentUri = null, ?strin
4747
$this->currentUri = $currentUri;
4848

4949
$elementUriIsRelative = null === parse_url(trim($this->getRawUri()), PHP_URL_SCHEME);
50-
$baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), array('http', 'file'));
50+
$baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']);
5151
if ($elementUriIsRelative && !$baseUriIsAbsolute) {
5252
throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the %s class ("%s" was passed).', __CLASS__, $this->currentUri));
5353
}
@@ -146,7 +146,7 @@ protected function canonicalizePath($path)
146146
$path .= '/';
147147
}
148148

149-
$output = array();
149+
$output = [];
150150

151151
foreach (explode('/', $path) as $segment) {
152152
if ('..' === $segment) {

Crawler.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Crawler implements \Countable, \IteratorAggregate
3030
/**
3131
* @var array A map of manually registered namespaces
3232
*/
33-
private $namespaces = array();
33+
private $namespaces = [];
3434

3535
/**
3636
* @var string The base href value
@@ -45,7 +45,7 @@ class Crawler implements \Countable, \IteratorAggregate
4545
/**
4646
* @var \DOMElement[]
4747
*/
48-
private $nodes = array();
48+
private $nodes = [];
4949

5050
/**
5151
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
@@ -92,7 +92,7 @@ public function getBaseHref()
9292
*/
9393
public function clear()
9494
{
95-
$this->nodes = array();
95+
$this->nodes = [];
9696
$this->document = null;
9797
}
9898

@@ -208,7 +208,7 @@ public function addHtmlContent($content, $charset = 'UTF-8')
208208

209209
$this->addDocument($dom);
210210

211-
$base = $this->filterRelativeXPath('descendant-or-self::base')->extract(array('href'));
211+
$base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);
212212

213213
$baseHref = current($base);
214214
if (\count($base) && !empty($baseHref)) {
@@ -363,7 +363,7 @@ public function eq($position)
363363
*/
364364
public function each(\Closure $closure)
365365
{
366-
$data = array();
366+
$data = [];
367367
foreach ($this->nodes as $i => $node) {
368368
$data[] = $closure($this->createSubCrawler($node), $i);
369369
}
@@ -395,7 +395,7 @@ public function slice($offset = 0, $length = null)
395395
*/
396396
public function reduce(\Closure $closure)
397397
{
398-
$nodes = array();
398+
$nodes = [];
399399
foreach ($this->nodes as $i => $node) {
400400
if (false !== $closure($this->createSubCrawler($node), $i)) {
401401
$nodes[] = $node;
@@ -487,7 +487,7 @@ public function parents()
487487
}
488488

489489
$node = $this->getNode(0);
490-
$nodes = array();
490+
$nodes = [];
491491

492492
while ($node = $node->parentNode) {
493493
if (XML_ELEMENT_NODE === $node->nodeType) {
@@ -528,7 +528,7 @@ public function children(/* string $selector = null */)
528528

529529
$node = $this->getNode(0)->firstChild;
530530

531-
return $this->createSubCrawler($node ? $this->sibling($node) : array());
531+
return $this->createSubCrawler($node ? $this->sibling($node) : []);
532532
}
533533

534534
/**
@@ -632,7 +632,7 @@ public function evaluate($xpath)
632632
throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
633633
}
634634

635-
$data = array();
635+
$data = [];
636636
$domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
637637

638638
foreach ($this->nodes as $node) {
@@ -653,7 +653,7 @@ public function evaluate($xpath)
653653
*
654654
* Example:
655655
*
656-
* $crawler->filter('h1 a')->extract(array('_text', 'href'));
656+
* $crawler->filter('h1 a')->extract(['_text', 'href']);
657657
*
658658
* @param array $attributes An array of attributes
659659
*
@@ -664,9 +664,9 @@ public function extract($attributes)
664664
$attributes = (array) $attributes;
665665
$count = \count($attributes);
666666

667-
$data = array();
667+
$data = [];
668668
foreach ($this->nodes as $node) {
669-
$elements = array();
669+
$elements = [];
670670
foreach ($attributes as $attribute) {
671671
if ('_text' === $attribute) {
672672
$elements[] = $node->nodeValue;
@@ -801,7 +801,7 @@ public function link($method = 'get')
801801
*/
802802
public function links()
803803
{
804-
$links = array();
804+
$links = [];
805805
foreach ($this->nodes as $node) {
806806
if (!$node instanceof \DOMElement) {
807807
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -842,7 +842,7 @@ public function image()
842842
*/
843843
public function images()
844844
{
845-
$images = array();
845+
$images = [];
846846
foreach ($this as $node) {
847847
if (!$node instanceof \DOMElement) {
848848
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -936,7 +936,7 @@ public static function xpathLiteral($s)
936936
}
937937

938938
$string = $s;
939-
$parts = array();
939+
$parts = [];
940940
while (true) {
941941
if (false !== $pos = strpos($string, "'")) {
942942
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
@@ -982,7 +982,7 @@ private function filterRelativeXPath($xpath)
982982
*/
983983
private function relativize(string $xpath): string
984984
{
985-
$expressions = array();
985+
$expressions = [];
986986

987987
// An expression which will never match to replace expressions which cannot match in the crawler
988988
// We cannot simply drop
@@ -1100,7 +1100,7 @@ public function getIterator()
11001100
*/
11011101
protected function sibling($node, $siblingDir = 'nextSibling')
11021102
{
1103-
$nodes = array();
1103+
$nodes = [];
11041104

11051105
$currentNode = $this->getNode(0);
11061106
do {
@@ -1115,7 +1115,7 @@ protected function sibling($node, $siblingDir = 'nextSibling')
11151115
/**
11161116
* @throws \InvalidArgumentException
11171117
*/
1118-
private function createDOMXPath(\DOMDocument $document, array $prefixes = array()): \DOMXPath
1118+
private function createDOMXPath(\DOMDocument $document, array $prefixes = []): \DOMXPath
11191119
{
11201120
$domxpath = new \DOMXPath($document);
11211121

@@ -1154,7 +1154,7 @@ private function findNamespacePrefixes(string $xpath): array
11541154
return array_unique($matches['prefix']);
11551155
}
11561156

1157-
return array();
1157+
return [];
11581158
}
11591159

11601160
/**

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));

0 commit comments

Comments
 (0)