Skip to content

Commit d46bb0e

Browse files
committed
switched array() to []
1 parent 311f666 commit d46bb0e

15 files changed

+323
-323
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, $currentUri, $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) {

Crawler.php

Lines changed: 18 additions & 18 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) {
@@ -513,7 +513,7 @@ public function children()
513513

514514
$node = $this->getNode(0)->firstChild;
515515

516-
return $this->createSubCrawler($node ? $this->sibling($node) : array());
516+
return $this->createSubCrawler($node ? $this->sibling($node) : []);
517517
}
518518

519519
/**
@@ -605,7 +605,7 @@ public function evaluate($xpath)
605605
throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
606606
}
607607

608-
$data = array();
608+
$data = [];
609609
$domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
610610

611611
foreach ($this->nodes as $node) {
@@ -637,9 +637,9 @@ public function extract($attributes)
637637
$attributes = (array) $attributes;
638638
$count = \count($attributes);
639639

640-
$data = array();
640+
$data = [];
641641
foreach ($this->nodes as $node) {
642-
$elements = array();
642+
$elements = [];
643643
foreach ($attributes as $attribute) {
644644
if ('_text' === $attribute) {
645645
$elements[] = $node->nodeValue;
@@ -780,7 +780,7 @@ public function link($method = 'get')
780780
*/
781781
public function links()
782782
{
783-
$links = array();
783+
$links = [];
784784
foreach ($this->nodes as $node) {
785785
if (!$node instanceof \DOMElement) {
786786
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -821,7 +821,7 @@ public function image()
821821
*/
822822
public function images()
823823
{
824-
$images = array();
824+
$images = [];
825825
foreach ($this as $node) {
826826
if (!$node instanceof \DOMElement) {
827827
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
@@ -915,7 +915,7 @@ public static function xpathLiteral($s)
915915
}
916916

917917
$string = $s;
918-
$parts = array();
918+
$parts = [];
919919
while (true) {
920920
if (false !== $pos = strpos($string, "'")) {
921921
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
@@ -965,7 +965,7 @@ private function filterRelativeXPath($xpath)
965965
*/
966966
private function relativize($xpath)
967967
{
968-
$expressions = array();
968+
$expressions = [];
969969

970970
// An expression which will never match to replace expressions which cannot match in the crawler
971971
// We cannot simply drop
@@ -1083,7 +1083,7 @@ public function getIterator()
10831083
*/
10841084
protected function sibling($node, $siblingDir = 'nextSibling')
10851085
{
1086-
$nodes = array();
1086+
$nodes = [];
10871087

10881088
do {
10891089
if ($node !== $this->getNode(0) && 1 === $node->nodeType) {
@@ -1102,7 +1102,7 @@ protected function sibling($node, $siblingDir = 'nextSibling')
11021102
*
11031103
* @throws \InvalidArgumentException
11041104
*/
1105-
private function createDOMXPath(\DOMDocument $document, array $prefixes = array())
1105+
private function createDOMXPath(\DOMDocument $document, array $prefixes = [])
11061106
{
11071107
$domxpath = new \DOMXPath($document);
11081108

@@ -1149,7 +1149,7 @@ private function findNamespacePrefixes($xpath)
11491149
return array_unique($matches['prefix']);
11501150
}
11511151

1152-
return array();
1152+
return [];
11531153
}
11541154

11551155
/**

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

@@ -261,7 +261,7 @@ protected function initialize()
261261
*/
262262
private function buildOptionValue(\DOMElement $node)
263263
{
264-
$option = array();
264+
$option = [];
265265

266266
$defaultDefaultValue = 'select' === $this->node->nodeName ? '' : 'on';
267267
$defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : $defaultDefaultValue;
@@ -301,7 +301,7 @@ public function containsOption($optionValue, $options)
301301
*/
302302
public function availableOptionValues()
303303
{
304-
$values = array();
304+
$values = [];
305305

306306
foreach ($this->options as $option) {
307307
$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: 5 additions & 5 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) {
@@ -169,7 +169,7 @@ private static function create($base, array $values)
169169
*
170170
* @return array The list of fields as array((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);
@@ -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)