Documentation

CommandsMatcher extends AbstractMatcher
in package

A Psy Command tab completion Matcher.

This matcher provides completion for all registered Psy Command names and aliases.

Tags
author

Marc Garcia markcial@gmail.com

Table of Contents

CONSTANT_SYNTAX  = '^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$'
Syntax types
MISC_OPERATORS  = '+-*/^|&'
T_AND_EQUAL  = 'T_AND_EQUAL'
T_BOOLEAN_AND  = 'T_BOOLEAN_AND'
T_BOOLEAN_OR  = 'T_BOOLEAN_OR'
T_CLONE  = 'T_CLONE'
T_DOUBLE_COLON  = 'T_DOUBLE_COLON'
T_ENCAPSED_AND_WHITESPACE  = 'T_ENCAPSED_AND_WHITESPACE'
T_INCLUDE  = 'T_INCLUDE'
T_INCLUDE_ONCE  = 'T_INCLUDE_ONCE'
T_NEW  = 'T_NEW'
T_NS_SEPARATOR  = 'T_NS_SEPARATOR'
T_OBJECT_OPERATOR  = 'T_OBJECT_OPERATOR'
T_OPEN_TAG  = 'T_OPEN_TAG'
Token values
T_REQUIRE  = 'T_REQUIRE'
T_REQUIRE_ONCE  = 'T_REQUIRE_ONCE'
T_STRING  = 'T_STRING'
T_VARIABLE  = 'T_VARIABLE'
T_WHITESPACE  = 'T_WHITESPACE'
VAR_SYNTAX  = '^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$'
$commands  : array<string|int, string>
__construct()  : mixed
CommandsMatcher constructor.
getMatches()  : array<string|int, mixed>
Provide tab completion matches for readline input.
hasMatched()  : bool
Check whether this matcher can provide completions for $tokens.
hasSyntax()  : bool
Check whether $token matches a given syntax pattern.
hasToken()  : bool
Check whether $token type is present in $coll.
isOperator()  : bool
Check whether $token is an operator.
needCompleteClass()  : mixed
setCommands()  : mixed
Set Commands for completion.
startsWith()  : bool
Check whether $word starts with $prefix.
tokenIs()  : bool
Check whether $token type is $which.
getInput()  : string
Get current readline input word.
getNamespaceAndClass()  : string
Get current namespace and class (if any) from readline input.
isCommand()  : bool
Check whether a command $name is defined.
matchCommand()  : bool
Check whether input matches a defined command.

Constants

CONSTANT_SYNTAX

Syntax types

public mixed CONSTANT_SYNTAX = '^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$'

T_ENCAPSED_AND_WHITESPACE

public mixed T_ENCAPSED_AND_WHITESPACE = 'T_ENCAPSED_AND_WHITESPACE'

T_OBJECT_OPERATOR

public mixed T_OBJECT_OPERATOR = 'T_OBJECT_OPERATOR'

VAR_SYNTAX

public mixed VAR_SYNTAX = '^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$'

Properties

Methods

__construct()

CommandsMatcher constructor.

public __construct(array<string|int, Command$commands) : mixed
Parameters
$commands : array<string|int, Command>
Return values
mixed

getMatches()

Provide tab completion matches for readline input.

public getMatches(array<string|int, mixed> $tokens[, array<string|int, mixed> $info = [] ]) : array<string|int, mixed>
Parameters
$tokens : array<string|int, mixed>

information substracted with get_token_all

$info : array<string|int, mixed> = []

readline_info object

Return values
array<string|int, mixed>

The matches resulting from the query

hasMatched()

Check whether this matcher can provide completions for $tokens.

public hasMatched(array<string|int, mixed> $tokens) : bool
Parameters
$tokens : array<string|int, mixed>

Tokenized readline input

Return values
bool

hasSyntax()

Check whether $token matches a given syntax pattern.

public static hasSyntax(mixed $token[, string $syntax = self::VAR_SYNTAX ]) : bool
Parameters
$token : mixed

A PHP token (see token_get_all)

$syntax : string = self::VAR_SYNTAX

A syntax pattern (default: variable pattern)

Return values
bool

hasToken()

Check whether $token type is present in $coll.

public static hasToken(array<string|int, mixed> $coll, mixed $token) : bool
Parameters
$coll : array<string|int, mixed>

A list of token types

$token : mixed

A PHP token (see token_get_all)

Return values
bool

isOperator()

Check whether $token is an operator.

public static isOperator(mixed $token) : bool
Parameters
$token : mixed

A PHP token (see token_get_all)

Return values
bool

needCompleteClass()

public static needCompleteClass(mixed $token) : mixed
Parameters
$token : mixed
Return values
mixed

setCommands()

Set Commands for completion.

public setCommands(array<string|int, Command$commands) : mixed
Parameters
$commands : array<string|int, Command>
Return values
mixed

startsWith()

Check whether $word starts with $prefix.

public static startsWith(string $prefix, string $word) : bool
Parameters
$prefix : string
$word : string
Return values
bool

tokenIs()

Check whether $token type is $which.

public static tokenIs(mixed $token, string $which) : bool
Parameters
$token : mixed

A PHP token (see token_get_all)

$which : string

A PHP token type

Return values
bool

getInput()

Get current readline input word.

protected getInput(array<string|int, mixed> $tokens) : string
Parameters
$tokens : array<string|int, mixed>

Tokenized readline input (see token_get_all)

Return values
string

getNamespaceAndClass()

Get current namespace and class (if any) from readline input.

protected getNamespaceAndClass(array<string|int, mixed> $tokens) : string
Parameters
$tokens : array<string|int, mixed>

Tokenized readline input (see token_get_all)

Return values
string

isCommand()

Check whether a command $name is defined.

protected isCommand(string $name) : bool
Parameters
$name : string
Return values
bool

matchCommand()

Check whether input matches a defined command.

protected matchCommand(string $name) : bool
Parameters
$name : string
Return values
bool

Search results