Propel API
Class

PropelPHPParser

class PropelPHPParser

Service class for parsing PHP code strings and editing them

Methods

__construct(string $code, boolean $isAddPhp = false)

Parser constructor

string getCode()

Get the modified code

mixed findMethod(string $methodName)

Parse the code looking for a method definition, and returns the code if found

mixed removeMethod(string $methodName)

Parse the code looking for a method definition, and removes the code if found

mixed replaceMethod(string $methodName, string $newCode)

Parse the code looking for a method definition, and replaces the code if found

mixed addMethodAfter(string $methodName, string $newCode)

Parse the code looking for a method definition, and adds the code after if found

mixed addMethodBefore(string $methodName, string $newCode)

Parse the code looking for a method definition, and adds the code before if found

Details

at line 45
public __construct(string $code, boolean $isAddPhp = false)

Parser constructor

Parameters

string $code PHP code to parse
boolean $isAddPhp Whether the supplied code needs a supplementary '<?php ' to be seen as code by the tokenizer.

at line 56
public string getCode()

Get the modified code

Return Value

string PHP code

at line 78
public mixed findMethod(string $methodName)

Parse the code looking for a method definition, and returns the code if found

Parameters

string $methodName The name of the method to find, e.g. 'getAuthor'

Return Value

mixed false if not found, or the method code string if found

at line 155
public mixed removeMethod(string $methodName)

Parse the code looking for a method definition, and removes the code if found

Parameters

string $methodName The name of the method to find, e.g. 'getAuthor'

Return Value

mixed false if not found, or the method code string if found

at line 172
public mixed replaceMethod(string $methodName, string $newCode)

Parse the code looking for a method definition, and replaces the code if found

Parameters

string $methodName The name of the method to find, e.g. 'getAuthor'
string $newCode The code to use in place of the old method definition

Return Value

mixed false if not found, or the method code string if found

at line 189
public mixed addMethodAfter(string $methodName, string $newCode)

Parse the code looking for a method definition, and adds the code after if found

Parameters

string $methodName The name of the method to find, e.g. 'getAuthor'
string $newCode The code to add to the class

Return Value

mixed false if not found, or the method code string if found

at line 206
public mixed addMethodBefore(string $methodName, string $newCode)

Parse the code looking for a method definition, and adds the code before if found

Parameters

string $methodName The name of the method to find, e.g. 'getAuthor'
string $newCode The code to add to the class

Return Value

mixed false if not found, or the method code string if found