module php/reflect/version5/interface
imports
  php/reflect/oo/classes

/**
 * Stratego class support for functions
 */
signature
  constructors
    PHP5Interface : ClassName

strategies

  /**
   * Succeeds if the current term is an instance of PHP function
   */
  instanceof-PHPInterface =
    instanceof-PHP5Interface

  instanceof-PHP5Interface =
    classes_instanceof(|PHP5Interface())

strategies

  /**
   * Constructs a new interface.
   *
   * @type  _ -> Function Object
   */
  new-php5-interface(|ast) =
      <classes_get-class> PHP5Interface()
    ; classes_new-instance
    ; classes_set-instance-field(|"reference-ast", ast)

/**
 * Properties
 */
strategies

  /**
   * Returns the name of the interface
   *
   * @type Interface Object -> String
   */
  get-name = instanceof-PHP5Interface;
       get-reference-ast
    ; ?InterfaceDecl(<id>,_,_)

  /**
   * Returns the names of the functions in the interface
   *
   * @type Interface Object -> List(String)
   */
   get-function-names = instanceof-PHP5Interface;
      get-reference-ast
    ; collect-all( ?InterfaceFunction(_,<id>,_) <+ ?InterfaceFunctionRef(_,<id>,_))

   /**
    * Returns the parameters of the given function in this interface.
    *
   * @type String -> List(Param)
    */
   get-function-params(|name) = instanceof-PHP5Interface;
      get-reference-ast
    ; oncetd(   ?InterfaceFunction(_,name,params)
             <+ ?InterfaceFunctionRef(_,name,params)
             )
    ; !params

/**
 * AST representation
 */
strategies

  /** 
   * Returns the AST of the function.
   *
   * @type Function Object -> AST
   */
  get-ast = instanceof-PHP5Interface;
    get-reference-ast
    
  get-reference-ast = instanceof-PHP5Interface;
    classes_get-instance-field(|"reference-ast")  
    
  set-reference-ast(|refast) = instanceof-PHP5Interface;
    classes_set-instance-field(|"reference-ast", refast)