module php/reflect/common/main
imports
php/reflect/common/environment
php/reflect/common/function
php/reflect/common/class
/**
* Strategies that both versions of the environment have
* in common to create the environment
*
*/
strategies
collect-all-skip-classes(s) =
collect-all(s, union, skip-class)
match-function-decl =
?FunctionDecl(_,_,_)
<+ ?FunctionDeclRef(_,_,_)
match-class-decl =
?Class(_,_,_,_)
rules
skip-class :
Class(_,_,_,_) -> []
skip-class :
Class(_,_,_,_,_) -> []
strategies
/**
* Initialization of an environment. If there was an option
* for a specific release the environment is made for
* this release. Otherwise it uses the PHP4Environment.
*
* @param doc The main document on which the environment has to be filled.
* @type _ -> PHPEnvironment
*/
init-php-environment(|doc) =
if <get-config> "version" => "PHP5"
then init-php5-environment(|doc)
else init-php4-environment(|doc)
end
/**
* Fills the current PHP environment with the extra document. It
* analyzes the AST and caches the decleration of several things.
* This strategy can be used instead of a specific one for a version.
*
* @param doc The main document on which the environment has to be filled.
* @type _ -> PHPEnvironment
*/
fill-php-environment(|doc) =
( env := <get-php5-environment>
; fill-php5-environment(|env,doc)
)
<+
( env := <get-php4-environment>
; fill-php4-environment(|env,doc)
)
rules
/**
* Sets the current PHP environment. This environment can be extracted
* by get-php-environment.
*
* @param environment The PHPEnvironment to store
*/
set-php-environment(|environment) =
table-hashtable
; hashtable-put(|"PHP-Environment",environment)
/**
* Catches the current environment. Fails if there is
* none.
*/
get-php-environment =
table-hashtable
; hashtable-get(|"PHP-Environment")
/**
* Cleans the php-environment.
*/
clean-php-environment =
table-hashtable
; hashtable-remove(|"PHP-Environment")