Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6102561
Expectation.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
Expectation.php
View Options
<?php
namespace
Wikimedia\WikiPEG
;
class
Expectation
implements
\JsonSerializable
{
/** @var string */
public
$type
;
/** @var string|null */
public
$value
;
/** @var string */
public
$description
;
/**
* @param array{type:string,value?:?string,description:string} $info
* The expectation array, which comes from the generated code, with keys:
* - type: The failed node type
* - value: The actual string which failed to match, may be absent for some node types
* - description: A readable description of the value
*/
public
function
__construct
(
$info
)
{
$this
->
type
=
$info
[
'type'
];
$this
->
value
=
$info
[
'value'
]
??
null
;
$this
->
description
=
$info
[
'description'
];
}
/**
* Compare two Expectation objects, and return a value less than, equal to,
* or greater than zero, depending on whether $a is less than, equal to, or
* greater than $b respectively.
*
* This is used to sort expectations before combining them into SyntaxError
* descriptions.
*
* @param Expectation $a
* @param Expectation $b
* @return int
*/
public
static
function
compare
(
Expectation
$a
,
Expectation
$b
)
{
return
$a
->
type
<=>
$b
->
type
?:
$a
->
value
<=>
$b
->
value
?:
$a
->
description
<=>
$b
->
description
;
}
/**
* Emit a JSON serialization similar to JS, for testing
* @return array
*/
#[\ReturnTypeWillChange]
public
function
jsonSerialize
():
array
{
return
[
'type'
=>
$this
->
type
,
'value'
=>
$this
->
value
,
'description'
=>
$this
->
description
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 6 2026, 10:10 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4d/f9/c54c5f8ff3c7737417c959a2f0cd
Default Alt Text
Expectation.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment