module php/reflect/version5/php5-environment
imports
  php/reflect/oo/classes

signature
  constructors
    PHP5Environment : ClassName

strategies
  /**
   * Succeeds if the current term is an instance of PHP Environment.
   */
  instanceof-PHPEnvironment =
    instanceof-PHP5Environment

  instanceof-PHP5Environment =
    classes_instanceof(|PHP5Environment())

/**
 * Stratego class support for PHP Environment
 */
strategies

  /**
   * Constructs a new PHP5 Environment.
   *
   * @type  _ -> Environment Object
   */
  new-php5-environment =
      <classes_get-class> PHP5Environment()
    ; classes_new-instance
    ; classes_set-instance-field(|"function-table", <new-hashtable>)
    ; classes_set-instance-field(|"classes-table" , <new-hashtable>)
    ; classes_set-instance-field(|"interface-table" , <new-hashtable>)
    ; classes_set-instance-field(|"files-table" , <new-hashtable>)        
    ; classes_set-instance-field(|"filenames-table", <new-hashtable>)
        
strategies
  /**
   * Returns all interfaces.
   *
   * @type PHP5Environment Object -> List(Interfaces Object)
   */
  get-interfaces = instanceof-PHP5Environment;
    classes_get-instance-field(|"interface-table")
    ; hashtable-values

  /**
   * @param Name of the class (String)
   * @type  PHP5Environment Object -> PHP5Environment Object
   */
  get-interface(|name) = instanceof-PHP5Environment;
    classes_get-instance-field(|"interface-table")
    ; hashtable-get(|name)

  /**
   * @param Class Object
   * @type PHP5Environment Object -> PHP5Environment Object
   */
  add-interface(|interface) = instanceof-PHP5Environment;
    where(
        classes_get-instance-field(|"interface-table")
      ; where(name := <get-name> interface)
      ; hashtable-put(|name, interface)
    )