Documentation

KeywordsMatcher extends AbstractMatcher
in package

A PHP keyword tab completion Matcher.

This matcher provides completion for all function-like PHP keywords.

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]*$'
$keywords  : mixed
$mandatoryStartKeywords  : mixed
getKeywords()  : array<string|int, mixed>
Get all (completable) PHP keywords.
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.
isKeyword()  : bool
Check whether $keyword is a (completable) PHP keyword.
isOperator()  : bool
Check whether $token is an operator.
needCompleteClass()  : mixed
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.

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

$keywords

protected mixed $keywords = ['array', 'clone', 'declare', 'die', 'echo', 'empty', 'eval', 'exit', 'include', 'include_once', 'isset', 'list', 'print', 'require', 'require_once', 'unset']

$mandatoryStartKeywords

protected mixed $mandatoryStartKeywords = ['die', 'echo', 'print', 'unset']

Methods

getKeywords()

Get all (completable) PHP keywords.

public getKeywords() : array<string|int, mixed>
Return values
array<string|int, 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

isKeyword()

Check whether $keyword is a (completable) PHP keyword.

public isKeyword(string $keyword) : bool
Parameters
$keyword : string
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

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

Search results