/** * Creates an abstract item instance. * * @return \PDepend\Source\AST\ASTInterface */ protected function createItem() { $interface = new ASTInterface(__CLASS__); $interface->setCompilationUnit(new ASTCompilationUnit(__FILE__)); $interface->setCache(new MemoryCacheDriver()); $interface->setContext($this->getMock('PDepend\\Source\\Builder\\BuilderContext')); return $interface; }
/** * Builds a new new interface instance. * * If there is an existing class instance for the given name, this method * checks if this class is part of the default namespace. If this is the * case this method will update all references to the new interface and it * removes the class instance. Otherwise it creates new interface instance. * * Where possible you should give a qualified interface name, that is * prefixed with the package identifier. * * <code> * $builder->buildInterface('php::depend::Parser'); * </code> * * To determine the correct interface, this method implements the following * algorithm. * * <ol> * <li>Check for an exactly matching instance and reuse it.</li> * <li>Check for a interface instance that belongs to the default package. * If such an instance exists, reuse it and replace the default package * with the newly given package information.</li> * <li>Check that the requested interface is in the default package, if * this is true, reuse the first interface instance and ignore the default * package. * </li> * <li>Create a new instance for the specified package.</li> * </ol> * * @param string $name The interface name. * @return \PDepend\Source\AST\ASTInterface */ public function buildInterface($name) { $this->checkBuilderState(); $interface = new ASTInterface($this->extractTypeName($name)); $interface->setCache($this->cache)->setContext($this->context)->setCompilationUnit($this->defaultCompilationUnit); return $interface; }
/** * Creates a ready to use interface fixture. * * @param string $name Optional interface name. * * @return \PDepend\Source\AST\ASTInterface * @since 1.0.2 */ protected function createInterfaceFixture($name = null) { $name = $name ? $name : get_class($this); $interface = new ASTInterface($name); $interface->setCompilationUnit(new ASTCompilationUnit($GLOBALS['argv'][0])); $interface->setCache(new MemoryCacheDriver()); return $interface; }