Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4148968
TokenMatcher.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
TokenMatcher.php
View Options
<?php
/**
* @file
* @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
*/
namespace
Wikimedia\CSS\Grammar
;
use
Wikimedia\CSS\Objects\ComponentValueList
;
use
Wikimedia\CSS\Objects\Token
;
/**
* Matcher that matches a token of a particular type
* @see https://www.w3.org/TR/2019/CR-css-values-3-20190606/#component-types
*/
class
TokenMatcher
extends
Matcher
{
/** @var string One of the Token::T_* constants */
protected
$type
;
/** @var callable|null Something to call to further validate the token */
protected
$callback
=
null
;
/**
* @param string $type Token type to match
* @param callable|null $callback Something to call to further validate the token.
* bool callback( Token )
*/
public
function
__construct
(
$type
,
?
callable
$callback
=
null
)
{
$this
->
type
=
$type
;
$this
->
callback
=
$callback
;
}
/** @inheritDoc */
protected
function
generateMatches
(
ComponentValueList
$values
,
$start
,
array
$options
)
{
$cv
=
$values
[
$start
]
??
null
;
if
(
$cv
instanceof
Token
&&
$cv
->
type
()
===
$this
->
type
&&
(
!
$this
->
callback
||
call_user_func
(
$this
->
callback
,
$cv
)
)
)
{
yield
$this
->
makeMatch
(
$values
,
$start
,
$this
->
next
(
$values
,
$start
,
$options
)
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 18:59 (6 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
59/ea/f97a0b58368ba22a2789b639b772
Default Alt Text
TokenMatcher.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment