@@ -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 /**
0 commit comments