Legacy
class Legacy extends Parser (View source)
The token parser for legacy (prior to concrete5 5.7) packages.
Properties
protected Strings | $stringValidator | The string validator service to be used to check the validity of handles. |
from Parser |
Methods
Determine if this parser can be used for the specified PHP tokens of the package controlller.php file.
Extract package details from the PHP tokens of the package controller.php file.
Get the regular expression that the controller class name must match (without the namespace).
Get the default minimum core version when the package doesn't specify it.
Extract the package handle from the fully-qualified class name.
Get the package handle.
Get the package version.
Get the package name.
Get the package description.
Get the minimum supported core version.
Get the minimum supported PHP version.
Get the value of a class property.
Get the return value of a class method.
Get token range of the body of a very simple class method (that is, containing only a "return something;").
Find the index of a token given its type.
Find the index of a text token given its contents.
Strip whitespaces and comments from a list of tokens.
Strip t() function calls at the beginning of a list of tokens tokens (if any).
Strip enclosing parenthesis ("(...)") (if any) in a list of tokens.
Skip to the next non-whitespace and non-comment token.
Get the actual PHP value described by a value token.
Decode the value of a T_CONSTANT_ENCAPSED_STRING token.
Details
in
Parser at line 24
__construct(Strings $stringValidator)
Initialize the instance.
bool
canParseTokens(array $tokens)
Determine if this parser can be used for the specified PHP tokens of the package controlller.php file.
in
Parser at line 47
PackageInfo
extractInfo(array $tokens)
Extract package details from the PHP tokens of the package controller.php file.
protected string
getControllerClassNameRegularExpression()
Get the regular expression that the controller class name must match (without the namespace).
protected string
getDefaultPackageMinimumCodeVersion()
Get the default minimum core version when the package doesn't specify it.
protected PackageInfo
getPackageHandleFromClassName(array $tokens, string $className, int $classStart)
Extract the package handle from the fully-qualified class name.
in
Parser at line 97
protected array[]
findControllerClass(array $tokens)
Find the package controller class.
protected string
getPackageHandle(array $tokens, string $className, int $classStart, int $classEnd)
Get the package handle.
protected string
getPackageVersion(array $tokens, string $className, int $classStart, int $classEnd)
Get the package version.
protected string
getPackageName(array $tokens, string $className, int $classStart, int $classEnd)
Get the package name.
protected string
getPackageDescription(array $tokens, string $className, int $classStart, int $classEnd)
Get the package description.
protected string
getPackageMinimumCodeVersion(array $tokens, string $className, int $classStart, int $classEnd)
Get the minimum supported core version.
protected string
getPackageMinimumPHPVersion(array $tokens, string $className, int $classStart, int $classEnd)
Get the minimum supported PHP version.
protected mixed
getPropertyValue(array $tokens, string $propertyName, int $classStart, int $classEnd)
Get the value of a class property.
protected mixed
getSimpleMethodReturnValue(array $tokens, string $methodName, int $classStart, int $classEnd)
Get the return value of a class method.
Get the value returned from a very simple class method (that is, containing only a "return something;").
protected int[]|null
getSimpleMethodBodyTokenRange(array $tokens, string $methodName, int $classStart, int $classEnd)
Get token range of the body of a very simple class method (that is, containing only a "return something;").
protected bool
isVersionValid(string|mixed $version)
Check if a version is valid.
protected int|null
findTypedToken(array $tokens, array $tokenIDs, int $startIndexInclusive = 0, int|null $endIndexExclusive = null)
Find the index of a token given its type.
protected int|null
findTextToken(array $tokens, array $tokenContent, int $startIndexInclusive = 0, int|null $endIndexExclusive = null)
Find the index of a text token given its contents.
protected array
stripNonCodeTokens(array $tokens, int $startIndexInclusive = 0, int|null $endIndexExclusive = null)
Strip whitespaces and comments from a list of tokens.
protected array
stripTFunctionCall(array $tokens)
Strip t() function calls at the beginning of a list of tokens tokens (if any).
protected array
stripEnclosingParenthesis(array $tokens)
Strip enclosing parenthesis ("(...)") (if any) in a list of tokens.
protected int|null
skipNonCodeTokens(array $tokens, int $startIndexInclusive = 0, int|null $endIndexExclusive = null)
Skip to the next non-whitespace and non-comment token.
protected mixed
decodeValueToken(array $token, string $associatedName)
Get the actual PHP value described by a value token.
protected string
decodeString(string $string)
Decode the value of a T_CONSTANT_ENCAPSED_STRING token.