Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7403147
VariablesMatcher.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
VariablesMatcher.php
View Options
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2023 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Psy\TabCompletion\Matcher
;
/**
* A variable name tab completion Matcher.
*
* This matcher provides completion for variable names in the current Context.
*
* @author Marc Garcia <markcial@gmail.com>
*/
class
VariablesMatcher
extends
AbstractContextAwareMatcher
{
/**
* {@inheritdoc}
*/
public
function
getMatches
(
array
$tokens
,
array
$info
=
[]):
array
{
$var
=
\str_replace
(
'$'
,
''
,
$this
->
getInput
(
$tokens
));
return
\array_filter
(
\array_keys
(
$this
->
getVariables
()),
function
(
$variable
)
use
(
$var
)
{
return
AbstractMatcher
::
startsWith
(
$var
,
$variable
);
});
}
/**
* {@inheritdoc}
*/
public
function
hasMatched
(
array
$tokens
):
bool
{
$token
=
\array_pop
(
$tokens
);
switch
(
true
)
{
case
self
::
hasToken
([
self
::
T_OPEN_TAG
,
self
::
T_VARIABLE
],
$token
):
case
\is_string
(
$token
)
&&
$token
===
'$'
:
case
self
::
isOperator
(
$token
):
return
true
;
}
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 18:27 (19 h, 33 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
08/d3/60f048361513e1f23b781c8bccc3
Default Alt Text
VariablesMatcher.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment