Skip to content

Commit c876d0c

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: 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 8dc0625 + 191419a commit c876d0c

14 files changed

+325
-325
lines changed

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
/**
@@ -620,7 +620,7 @@ public function evaluate($xpath)
620620
throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
621621
}
622622

623-
$data = array();
623+
$data = [];
624624
$domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
625625

626626
foreach ($this->nodes as $node) {
@@ -641,7 +641,7 @@ public function evaluate($xpath)
641641
*
642642
* Example:
643643
*
644-
* $crawler->filter('h1 a')->extract(array('_text', 'href'));
644+
* $crawler->filter('h1 a')->extract(['_text', 'href']);
645645
*
646646
* @param array $attributes An array of attributes
647647
*
@@ -652,9 +652,9 @@ public function extract($attributes)
652652
$attributes = (array) $attributes;
653653
$count = \count($attributes);
654654

655-
$data = array();
655+
$data = [];
656656
foreach ($this->nodes as $node) {
657-
$elements = array();
657+
$elements = [];
658658
foreach ($attributes as $attribute) {
659659
if ('_text' === $attribute) {
660660
$elements[] = $node->nodeValue;
@@ -787,7 +787,7 @@ public function link($method = 'get')
787787
*/
788788
public function links()
789789
{
790-
$links = array();
790+
$links = [];
791791
foreach ($this->nodes as $node) {
792792
if (!$node instanceof \DOMElement) {
793793
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -828,7 +828,7 @@ public function image()
828828
*/
829829
public function images()
830830
{
831-
$images = array();
831+
$images = [];
832832
foreach ($this as $node) {
833833
if (!$node instanceof \DOMElement) {
834834
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -922,7 +922,7 @@ public static function xpathLiteral($s)
922922
}
923923

924924
$string = $s;
925-
$parts = array();
925+
$parts = [];
926926
while (true) {
927927
if (false !== $pos = strpos($string, "'")) {
928928
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
@@ -968,7 +968,7 @@ private function filterRelativeXPath($xpath)
968968
*/
969969
private function relativize(string $xpath): string
970970
{
971-
$expressions = array();
971+
$expressions = [];
972972

973973
// An expression which will never match to replace expressions which cannot match in the crawler
974974
// We cannot simply drop
@@ -1086,7 +1086,7 @@ public function getIterator()
10861086
*/
10871087
protected function sibling($node, $siblingDir = 'nextSibling')
10881088
{
1089-
$nodes = array();
1089+
$nodes = [];
10901090

10911091
$currentNode = $this->getNode(0);
10921092
do {
@@ -1101,7 +1101,7 @@ protected function sibling($node, $siblingDir = 'nextSibling')
11011101
/**
11021102
* @throws \InvalidArgumentException
11031103
*/
1104-
private function createDOMXPath(\DOMDocument $document, array $prefixes = array()): \DOMXPath
1104+
private function createDOMXPath(\DOMDocument $document, array $prefixes = []): \DOMXPath
11051105
{
11061106
$domxpath = new \DOMXPath($document);
11071107

@@ -1140,7 +1140,7 @@ private function findNamespacePrefixes(string $xpath): array
11401140
return array_unique($matches['prefix']);
11411141
}
11421142

1143-
return array();
1143+
return [];
11441144
}
11451145

11461146
/**

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)