Digger Simple PHP Code Parser.
More...
Digger Simple PHP Code Parser.
Parse source code of php-file and returns a hash array of code structure.
- Version
- 3.0
- Author
- Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru
- Copyright
- (c) 2015, SAD-Systems
Example of usage:
require_once 'autoload.php';
use digger\cradle\common\SimpleCodeParser;
static getClassMethods |
( |
|
$data | ) |
|
|
static |
To find all methods of class into a source code of a given class
- Parameters
-
string | $data | Text data contains a class source code. |
- Returns
- array Array structure:
array(
"method1" => array(
"type" => static | abstract | "",
"scope" => private | protected | private ,
"params" => "parameters of methods"
)
"method2" => array( ... ),
...
)
static getFirstBraceBlock |
( |
|
$data, |
|
|
|
$stripped = true |
|
) |
| |
|
static |
Get the first brace block contains "{ ...some data... }"
- Parameters
-
string | $data | Text data contains a class source code. |
boolean | $stripped | If TRUE: the first and the last braces wil be stripped from result. |
- Returns
- string Data placed inside two braces ( { ...some data... } ).
static getFirstBraceBlockPos |
( |
|
$data | ) |
|
|
static |
Get the first brace block positions contains { ...some data... }
- Parameters
-
string | $data | Text data contains a class source code. |
- Returns
- array Array structure:
array ( startPosition, endPosition )
static getFunctions |
( |
|
$data | ) |
|
|
static |
To find all functions into a source code
- Parameters
-
string | $data | Text data contains a source code. |
- Returns
- array Array structure:
array(
"function1" => "parameters of function",
"function2" => "parameters of function",
...
)
static getNamespaces |
( |
|
$data | ) |
|
|
static |
To split a source code into parts of namespases
- Parameters
-
string | $data | Text data contains a source code. |
- Returns
- array Array structure:
array(
"" => "...code inside the GLOBAL namespace...",
"namespace1" => "...code inside the namespace1...",
"namespace2" => "...code inside the namespace2...",
...
)
static getObjects |
( |
|
$data | ) |
|
|
static |
To find all objects (classes and functions) into a source code
- Parameters
-
string | $data | Text data contains a source code. |
- Returns
- array Array structure:
array(
"classes" => array(
"class1" => array(
"method1" => array(
"type" => static | ...,
"scope" => private | protected | ... ,
"params" => "parameters of methods"
),
...
)
),
"functions" => array (
"function1" => "parameters of function",
...
)
)
static parseCode |
( |
|
$data | ) |
|
|
static |
To parse a source code. It is a main method to use.
- Parameters
-
string | $data | Text data contains a source code. |
- Returns
- array Array structure:
array(
"namespace1" => array(
"classes" => array(
"class1" => array(
"method1" => array(
"type" => static | ...,
"scope" => private | protected | ... ,
"params" => "parameters of methods"
),
...
)
),
"functions" => array (
"function1" => "parameters of function",
...
)
),
...
)
static stripComments |
( |
|
$data | ) |
|
|
static |
To strip input text data (code) of comments
- Parameters
-
string | $data | Text data contains a source code. |
- Returns
- string text Data without code comments (such as^ /* ... and //... ).
The documentation for this class was generated from the following file: