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 44
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 55
public string getCode()

Get the modified code

Return Value

string PHP code

at line 77
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 154
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 173
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 192
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 211
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