Skip to content

Commit 5d5d9ef

Browse files
Leverage PHP8's get_debug_type()
1 parent 7ac0cd5 commit 5d5d9ef

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Crawler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function add($node)
122122
} elseif (\is_string($node)) {
123123
$this->addContent($node);
124124
} elseif (null !== $node) {
125-
throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', \is_object($node) ? \get_class($node) : \gettype($node)));
125+
throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', get_debug_type($node)));
126126
}
127127
}
128128

@@ -802,7 +802,7 @@ public function link(string $method = 'get')
802802
$node = $this->getNode(0);
803803

804804
if (!$node instanceof \DOMElement) {
805-
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
805+
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node)));
806806
}
807807

808808
return new Link($node, $this->baseHref, $method);
@@ -820,7 +820,7 @@ public function links()
820820
$links = [];
821821
foreach ($this->nodes as $node) {
822822
if (!$node instanceof \DOMElement) {
823-
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
823+
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_debug_type($node)));
824824
}
825825

826826
$links[] = new Link($node, $this->baseHref, 'get');
@@ -845,7 +845,7 @@ public function image()
845845
$node = $this->getNode(0);
846846

847847
if (!$node instanceof \DOMElement) {
848-
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
848+
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node)));
849849
}
850850

851851
return new Image($node, $this->baseHref);
@@ -861,7 +861,7 @@ public function images()
861861
$images = [];
862862
foreach ($this as $node) {
863863
if (!$node instanceof \DOMElement) {
864-
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', \get_class($node)));
864+
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_debug_type($node)));
865865
}
866866

867867
$images[] = new Image($node, $this->baseHref);
@@ -886,7 +886,7 @@ public function form(array $values = null, string $method = null)
886886
$node = $this->getNode(0);
887887

888888
if (!$node instanceof \DOMElement) {
889-
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', \get_class($node)));
889+
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_debug_type($node)));
890890
}
891891

892892
$form = new Form($node, $this->uri, $method, $this->baseHref);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"require": {
1919
"php": "^7.2.5",
2020
"symfony/polyfill-ctype": "~1.8",
21-
"symfony/polyfill-mbstring": "~1.0"
21+
"symfony/polyfill-mbstring": "~1.0",
22+
"symfony/polyfill-php80": "^1.15"
2223
},
2324
"require-dev": {
2425
"symfony/css-selector": "^4.4|^5.0",

0 commit comments

Comments
 (0)