Skip to content

Issue/211 deprecated php 8.1 notices #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/QueryPath/CSS/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct() {
$this->selectors[$this->groupIndex][] = $this->currSelector;
}

public function getIterator() {
public function getIterator(): \Traversable {
return new \ArrayIterator($this->selectors);
}

Expand All @@ -73,7 +73,7 @@ public function toArray() {
return $this->selectors;
}

public function count() {
public function count():int {
return count($this->selectors);
}

Expand Down
10 changes: 5 additions & 5 deletions src/QueryPath/DOMQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* was done for a few reasons:
* - The library has been refactored, and it made more sense to call the top
* level class QueryPath. This is not the top level class.
* - There have been requests for a JSONQuery class, which would be the
* - There have been requests for a JSONQuery class, which would be the
* natural complement of DOMQuery.
*/

Expand Down Expand Up @@ -96,8 +96,8 @@ class DOMQuery implements \QueryPath\Query, \IteratorAggregate, \Countable {
* An associative array of options.
* @see qp()
*/
public function __construct($document = NULL, $string = NULL, $options = array()) {
$string = trim($string);
public function __construct($document = NULL, $string = '', $options = array()) {
$string = trim( (string)$string );
$this->options = $options + Options::get() + $this->options;

$parser_flags = isset($options['parser_flags']) ? $options['parser_flags'] : self::DEFAULT_PARSER_FLAGS;
Expand Down Expand Up @@ -364,7 +364,7 @@ public function size() {
* @return int
* The number of matches in the DOMQuery.
*/
public function count() {
public function count(): int {
return $this->matches->count();
}

Expand Down Expand Up @@ -3985,7 +3985,7 @@ public function __call($name, $arguments) {
* @return Iterable
* Returns an iterator.
*/
public function getIterator() {
public function getIterator(): \Traversable {
$i = new QueryPathIterator($this->matches);
$i->options = $this->options;
return $i;
Expand Down
4 changes: 2 additions & 2 deletions src/QueryPath/QueryPathIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
class QueryPathIterator extends \IteratorIterator {
public $options = array();
private $qp = NULL;

public function current() {
public function current(): mixed {
if (!isset($this->qp)) {
$this->qp = \QueryPath::with(parent::current(), NULL, $this->options);
}
Expand Down