class SS_ConfigStaticManifest_Parser (View source)

A parser that processes a PHP file, using PHP's built in parser to get a string of tokens, then processing them to find the static class variables, their access levels & values

We can't do this using TokenisedRegularExpression because we need to keep track of state as we process the token list (when we enter and leave a namespace or class, when we see an access level keyword, etc)

Properties

protected $info
protected $statics
protected $path
protected $tokens
protected $length
protected $pos

Methods

public
__construct($path)

No description

public
getInfo()

No description

public
getStatics()

No description

protected
null
next(bool $ignoreWhitespace = true)

Get the next token to process, incrementing the pointer

protected
null
lastToken(bool $ignoreWhitespace = true)

Get the previous token processed. Does not decrement the pointer

protected
null|string
nextString(bool $ignoreWhitespace = true)

Get the next set of tokens that form a string to process, incrementing the pointer

public
parse()

Parse the given file to find the static variables declared in it, along with their access & values

public
parseStatic($access, $class)

During parsing we've found a "static" keyword. Parse out the variable names and value assignments that follow.

Details

__construct($path)

No description

Parameters

$path

getInfo()

No description

getStatics()

No description

protected null next(bool $ignoreWhitespace = true)

Get the next token to process, incrementing the pointer

Parameters

bool $ignoreWhitespace
  • if true will skip any whitespace tokens & only return non-whitespace ones

Return Value

null

| mixed - Either the next token or null if there isn't one

protected null lastToken(bool $ignoreWhitespace = true)

Get the previous token processed. Does not decrement the pointer

Parameters

bool $ignoreWhitespace
  • if true will skip any whitespace tokens & only return non-whitespace ones

Return Value

null

| mixed - Either the previous token or null if there isn't one

protected null|string nextString(bool $ignoreWhitespace = true)

Get the next set of tokens that form a string to process, incrementing the pointer

Parameters

bool $ignoreWhitespace
  • if true will skip any whitespace tokens & only return non-whitespace ones

Return Value

null|string
  • Either the next string or null if there isn't one

parse()

Parse the given file to find the static variables declared in it, along with their access & values

parseStatic($access, $class)

During parsing we've found a "static" keyword. Parse out the variable names and value assignments that follow.

Seperated out from parse partially so that we can recurse if there are multiple statics being declared in a comma seperated list

Parameters

$access
$class