Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Tokens\KV Class Reference

Represents a Key-value pair. More...

+ Inheritance diagram for Wikimedia\Parsoid\Tokens\KV:
+ Collaboration diagram for Wikimedia\Parsoid\Tokens\KV:

Public Member Functions

 __construct ( $k, $v, ?KVSourceRange $srcOffsets=null, ?string $ksrc=null, ?string $vsrc=null)
 
 keyOffset ()
 Return the key portion of the KV's source offsets, or else null if no source offsets are known.
 
 valueOffset ()
 Return the value portion of the KV's source offsets, or else null if no source offsets are known.
 
 jsonSerialize ()
 

Static Public Member Functions

static lookupKV (?array $kvs, string $key)
 Lookup a string key in a KV array and return the first matching KV object.
 
static lookup (?array $kvs, string $key)
 Lookup a string key (first occurrence) in a KV array and return the value of the KV object.
 

Public Attributes

 $k
 
 $v
 
 $srcOffsets
 
 $ksrc
 
 $vsrc
 

Detailed Description

Represents a Key-value pair.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Parsoid\Tokens\KV::__construct ( $k,
$v,
?KVSourceRange $srcOffsets = null,
?string $ksrc = null,
?string $vsrc = null )
Parameters
string|Token|array<Token|string>$k Commonly a string, but where the key might be templated, this can be an array of tokens even.
string|Token|array<Token|string>|KV[]$v The value: string, token, of an array of tokens
?KVSourceRange$srcOffsetswikitext source offsets
?string$ksrc
?string$vsrc

Member Function Documentation

◆ keyOffset()

Wikimedia\Parsoid\Tokens\KV::keyOffset ( )

Return the key portion of the KV's source offsets, or else null if no source offsets are known.

Returns
SourceRange|null

◆ lookup()

static Wikimedia\Parsoid\Tokens\KV::lookup ( ?array $kvs,
string $key )
static

Lookup a string key (first occurrence) in a KV array and return the value of the KV object.

Parameters
KV[] | null$kvs
string$key
Returns
string|Token|Token[]|null

◆ lookupKV()

static Wikimedia\Parsoid\Tokens\KV::lookupKV ( ?array $kvs,
string $key )
static

Lookup a string key in a KV array and return the first matching KV object.

Parameters
KV[] | null$kvs
string$key
Returns
?KV

◆ valueOffset()

Wikimedia\Parsoid\Tokens\KV::valueOffset ( )

Return the value portion of the KV's source offsets, or else null if no source offsets are known.

Returns
SourceRange|null

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