Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4118605
TestTokenHandler.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
TestTokenHandler.php
View Options
<?php
namespace
Wikimedia\RemexHtml\Tokenizer
;
/**
* A TokenHandler which collects events from the Tokenizer and generates an
* array compatible with the html5lib tokenizer tests.
*/
class
TestTokenHandler
implements
TokenHandler
{
private
$tokens
=
[];
public
function
getTokens
()
{
return
$this
->
tokens
;
}
public
function
startDocument
(
Tokenizer
$tokenizer
,
$fns
,
$fn
)
{
}
public
function
endDocument
(
$pos
)
{
}
public
function
error
(
$text
,
$pos
)
{
$this
->
tokens
[]
=
'ParseError'
;
}
public
function
characters
(
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
)
{
$this
->
tokens
[]
=
[
'Character'
,
substr
(
$text
,
$start
,
$length
)
];
}
public
function
startTag
(
$name
,
Attributes
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
)
{
$attrArray
=
$attrs
->
getValues
();
if
(
$selfClose
)
{
$this
->
tokens
[]
=
[
'StartTag'
,
$name
,
$attrArray
,
$selfClose
];
}
else
{
$this
->
tokens
[]
=
[
'StartTag'
,
$name
,
$attrArray
];
}
}
public
function
endTag
(
$name
,
$sourceStart
,
$sourceLength
)
{
$this
->
tokens
[]
=
[
'EndTag'
,
$name
];
}
public
function
doctype
(
$name
,
$public
,
$system
,
$quirks
,
$sourceStart
,
$sourceLength
)
{
$this
->
tokens
[]
=
[
'DOCTYPE'
,
$name
,
$public
,
$system
,
!
$quirks
];
}
public
function
comment
(
$text
,
$sourceStart
,
$sourceLength
)
{
$this
->
tokens
[]
=
[
'Comment'
,
$text
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 02:53 (2 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9e/fe/a4aadefe904343309f05d0530c0c
Default Alt Text
TestTokenHandler.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment