Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432076
Alternatives.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
Alternatives.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Phan\Language\FQSEN
;
/**
* This trait allows an FQSEN to have an alternate ID for when
* there are multiple colliding definitions of the same name.
* An alternate ID will be appended to a name such as in
* `\Name\Space\class,1` or `\Name\Space\class::function,1`
* or when composed as `\Name\Space\class,1::function,1`.
*/
trait
Alternatives
{
/**
* Implementers must have a getName() method
*/
abstract
public
function
getName
():
string
;
/**
* Implementers should use the \Phan\Memoize trait
*/
abstract
protected
function
memoizeFlushAll
():
void
;
/**
* @var int
* An alternate ID for the element for use when
* there are multiple definitions of the element
*/
protected
$alternate_id
=
0
;
/**
* @return int
* An alternate identifier associated with this
* FQSEN or zero if none if this is not an
* alternative.
*/
public
function
getAlternateId
():
int
{
return
$this
->
alternate_id
;
}
/**
* @return string
* Get the name of this element with its alternate id
* attached
*/
public
function
getNameWithAlternateId
():
string
{
if
(
$this
->
alternate_id
)
{
return
"{$this->getName()},{$this->alternate_id}"
;
}
return
$this
->
getName
();
}
/**
* @return bool
* True if this is an alternate
*/
public
function
isAlternate
():
bool
{
return
(
0
!==
$this
->
alternate_id
);
}
/**
* @return static
* A FQSEN with the given alternate_id set
*/
abstract
public
function
withAlternateId
(
int
$alternate_id
);
/**
* @return static
* Get the canonical (non-alternate) FQSEN associated
* with this FQSEN
*/
public
function
getCanonicalFQSEN
()
{
if
(
$this
->
alternate_id
===
0
)
{
return
$this
;
}
return
$this
->
withAlternateId
(
0
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:24 (1 d, 12 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
26/0c/d003ea600490c48ef83f1ea53df0
Default Alt Text
Alternatives.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment