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