Skip to content

Commit

Permalink
Improve auto-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
jakejackson1 committed Mar 21, 2024
1 parent e4b11dc commit a9da950
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/DOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ abstract class DOM implements Query, IteratorAggregate, Countable
*
* @param mixed $document
* A document-like object.
* @param string|null $string
* @param string|null $selector
* A CSS 3 Selector
* @param array $options
* An associative array of options.
*
* @throws Exception
* @see qp()
*/
public function __construct($document = null, $string = null, $options = [])
public function __construct($document = null, $selector = null, $options = [])
{
$string = is_string($string) ? trim($string) : '';
$selector = is_string($selector) ? trim($selector) : '';
$this->options = $options + Options::get() + $this->options;

$parser_flags = $options['parser_flags'] ?? self::DEFAULT_PARSER_FLAGS;
Expand Down Expand Up @@ -163,12 +163,12 @@ public function __construct($document = null, $string = null, $options = [])
}

// Do a find if the second param was set.
if (strlen($string) > 0) {
if (strlen($selector) > 0) {
// We don't issue a find because that creates a new DOMQuery.
//$this->find($string);

$query = new DOMTraverser($this->matches);
$query->find($string);
$query->find($selector);
$this->setMatches($query->matches());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/qp_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@
*
* @param mixed $document
* A document in one of the forms listed above.
* @param string|null $string
* @param string|null $selector
* A CSS 3 selector.
* @param array $options
* An associative array of options. Currently supported options are listed above.
*
* @return mixed|DOMQuery
* Or possibly another QueryPath-like object if you overrode QueryPath_class.
*/
function qp($document = null, $string = null, array $options = [])
function qp($document = null, $selector = null, array $options = [])
{
return QueryPath::with($document, $string, $options);
return QueryPath::with($document, $selector, $options);
}

/**
Expand Down

0 comments on commit a9da950

Please sign in to comment.