Zest
Fast, lightweight, extensible CSS selector engine for PHP
Loading...
Searching...
No Matches
Wikimedia\Zest\Zest Class Reference

Zest.php (https://github.com/wikimedia/zest.php) Copyright (c) 2019, C. More...

Static Public Member Functions

static array find (string $sel, $context, array $opts=[])
 Find elements matching a CSS selector underneath $context.
 
static bool matches ( $el, string $sel, array $opts=[])
 Determine whether an element matches the given selector.
 
static array< DOMElement > getElementsById ( $context, string $id, array $opts=[])
 Get descendants by ID.
 
static array< DOMElement > getElementsByTagName ( $context, string $tagName, array $opts=[])
 Get descendants by tag name.
 

Detailed Description

Zest.php (https://github.com/wikimedia/zest.php) Copyright (c) 2019, C.

Scott Ananian. (MIT licensed) PHP port based on:

Zest (https://github.com/chjj/zest) A css selector engine. Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed) Domino version based on Zest v0.1.3 with bugfixes applied.

Member Function Documentation

◆ find()

static array Wikimedia\Zest\Zest::find ( string $sel,
$context,
array $opts = [] )
static

Find elements matching a CSS selector underneath $context.

Parameters
string$selThe CSS selector string
DOMDocument | DOMDocumentFragment | DOMElement$contextThe scoping root for the search
array$optsAdditional match-context options (optional)
Returns
array Elements matching the CSS selector

◆ getElementsById()

static array< DOMElement > Wikimedia\Zest\Zest::getElementsById ( $context,
string $id,
array $opts = [] )
static

Get descendants by ID.

The PHP DOM doesn't provide this method for DOMElement, and the implementation in DOMDocument is broken.

Parameters
DOMDocument | DOMDocumentFragment | DOMElement$contextThe scoping root for the search
string$id
array$optsAdditional match-context options (optional)
Returns
array<DOMElement> A list of the elements with the given ID. When there are more than one, this method might return all of them or only the first one.

◆ getElementsByTagName()

static array< DOMElement > Wikimedia\Zest\Zest::getElementsByTagName ( $context,
string $tagName,
array $opts = [] )
static

Get descendants by tag name.

The PHP DOM doesn't provide this method for DOMElement, and the implementation in DOMDocument has performance issues.

Parameters
DOMDocument | DOMDocumentFragment | DOMElement$context
string$tagName
array$optsAdditional match-context options (optional)
Returns
array<DOMElement>

◆ matches()

static bool Wikimedia\Zest\Zest::matches ( $el,
string $sel,
array $opts = [] )
static

Determine whether an element matches the given selector.

Parameters
DOMNode$elThe element to be tested
string$selThe CSS selector string
array$optsAdditional match-context options (optional)
Returns
bool True iff the element matches the selector

The documentation for this class was generated from the following file: