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