コード例 #1
0
ファイル: Default.php プロジェクト: noelg/pdepend
 /**
  * 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 PHP_Depend_Code_Interface The created interface object.
  */
 public function buildInterface($name)
 {
     $this->checkBuilderState();
     $interfaceName = $this->extractTypeName($name);
     $packageName = $this->extractPackageName($name);
     $interface = new PHP_Depend_Code_Interface($interfaceName);
     $interface->setSourceFile($this->defaultFile);
     $this->storeInterface($interfaceName, $packageName, $interface);
     return $interface;
 }
コード例 #2
0
ファイル: Xml.php プロジェクト: KingNoosh/Teknik
 /**
  * Visits a code interface object.
  *
  * @param PHP_Depend_Code_Interface $interface The context code interface.
  *
  * @return void
  * @see PHP_Depend_VisitorI::visitInterface()
  */
 public function visitInterface(PHP_Depend_Code_Interface $interface)
 {
     if (!$interface->isUserDefined()) {
         return;
     }
     $doc = $this->abstractClasses->ownerDocument;
     $classXml = $doc->createElement('Class');
     $classXml->setAttribute('sourceFile', (string) $interface->getSourceFile());
     $classXml->appendChild($doc->createTextNode($interface->getName()));
     $this->abstractClasses->appendChild($classXml);
 }
コード例 #3
0
 /**
  * Visits a code interface object.
  *
  * @param PHP_Depend_Code_Interface $interface The context code interface.
  *
  * @return void
  * @see PHP_Depend_VisitorI::visitInterface()
  */
 public function visitInterface(PHP_Depend_Code_Interface $interface)
 {
     $this->visits[] = $interface->getName();
     parent::visitInterface($interface);
 }
コード例 #4
0
ファイル: Default.php プロジェクト: kingsj/core
 /**
  * This method will persist an interface instance for later reuse.
  *
  * @param string                    $interfaceName The local interface name.
  * @param string                    $packageName   The package name
  * @param PHP_Depend_Code_Interface $interface     The context interface.
  *
  * @return void
  * @@since 0.9.5
  */
 protected function storeInterface($interfaceName, $packageName, PHP_Depend_Code_Interface $interface)
 {
     $interfaceName = strtolower($interfaceName);
     if (!isset($this->_interfaces[$interfaceName][$packageName])) {
         $this->_interfaces[$interfaceName][$packageName] = array();
     }
     $this->_interfaces[$interfaceName][$packageName][$interface->getUUID()] = $interface;
     $package = $this->buildPackage($packageName);
     $package->addType($interface);
 }
コード例 #5
0
ファイル: Parser.php プロジェクト: noelg/phpmd
 /**
  * Visits an interface node.
  *
  * @param PHP_Depend_Code_Interface $node The current interface node.
  *
  * @return void
  * @see PHP_Depend_VisitorI::visitInterface()
  */
 public function visitInterface(PHP_Depend_Code_Interface $node)
 {
     if (!$node->isUserDefined()) {
         return;
     }
     $this->_apply(new PHP_PMD_Node_Interface($node));
     parent::visitInterface($node);
 }
コード例 #6
0
ファイル: AnalyzerTest.php プロジェクト: kingsj/core
 /**
  * testVisitClassCountsInterfacesThatAreNotUserDefined
  *
  * @return void
  * @covers PHP_Depend_Metrics_NodeCount_Analyzer
  * @group pdepend
  * @group pdepend::metrics
  * @group pdepend::metrics::nodecount
  * @group unittest
  */
 public function testVisitClassCountsInterfacesThatAreNotUserDefined()
 {
     $userDefined = new PHP_Depend_Code_Interface('Manuel');
     $userDefined->setUserDefined();
     $package = new PHP_Depend_Code_Package('PHP_Depend');
     $package->addType($userDefined);
     $analyzer = new PHP_Depend_Metrics_NodeCount_Analyzer();
     $analyzer->analyze(new PHP_Depend_Code_NodeIterator(array($package)));
     $metrics = $analyzer->getNodeMetrics($package);
     $this->assertEquals(1, $metrics['noi']);
 }
コード例 #7
0
ファイル: InterfaceTest.php プロジェクト: rouffj/pdepend
 /**
  * Creates an abstract item instance.
  *
  * @return PHP_Depend_Code_Interface
  */
 protected function createItem()
 {
     $interface = new PHP_Depend_Code_Interface(__CLASS__);
     $interface->setSourceFile(new PHP_Depend_Code_File(__FILE__));
     $interface->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     $interface->setContext($this->getMock('PHP_Depend_Builder_Context'));
     return $interface;
 }
コード例 #8
0
ファイル: InterfaceTest.php プロジェクト: noelg/pdepend
 /**
  * Tests the returned modifiers of an interface.
  *
  * @return void
  * @covers PHP_Depend_Code_Interface
  * @covers PHP_Depend_Code_AbstractClassOrInterface
  * @group pdepend
  * @group pdepend::code
  * @group unittest
  */
 public function testInterfaceReturnsExpectedModifiers()
 {
     $interface = new PHP_Depend_Code_Interface('Foo');
     $this->assertSame(PHP_Depend_ConstantsI::IS_IMPLICIT_ABSTRACT, $interface->getModifiers());
 }
コード例 #9
0
ファイル: UuidBuilderTest.php プロジェクト: KingNoosh/Teknik
 /**
  * testBuilderCreatesCaseInSensitiveInterfaceIdentifiers
  *
  * @return void
  */
 public function testBuilderCreatesCaseInSensitiveInterfaceIdentifiers()
 {
     $file = new PHP_Depend_Code_File(__FILE__);
     $file->setUuid(__FUNCTION__);
     $interface0 = new PHP_Depend_Code_Interface(__FUNCTION__);
     $interface0->setSourceFile($file);
     $interface1 = new PHP_Depend_Code_Interface(strtolower(__FUNCTION__));
     $interface1->setSourceFile($file);
     $builder0 = new PHP_Depend_Util_UuidBuilder();
     $builder1 = new PHP_Depend_Util_UuidBuilder();
     self::assertEquals($builder0->forClassOrInterface($interface0), $builder1->forClassOrInterface($interface1));
 }
コード例 #10
0
ファイル: AbstractTest.php プロジェクト: rouffj/pdepend
 /**
  * Creates a ready to use interface fixture.
  *
  * @param string $name Optional interface name.
  *
  * @return PHP_Depend_Code_Interface
  * @since 1.0.2
  */
 protected function createInterfaceFixture($name = null)
 {
     $name = $name ? $name : get_class($this);
     $interface = new PHP_Depend_Code_Interface($name);
     $interface->setSourceFile(new PHP_Depend_Code_File($GLOBALS['argv'][0]));
     $interface->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     return $interface;
 }
コード例 #11
0
ファイル: Analyzer.php プロジェクト: yusufchang/app
 /**
  * Visits a code interface object.
  *
  * @param PHP_Depend_Code_Interface $interface The context code interface.
  *
  * @return void
  * @see PHP_Depend_VisitorI::visitInterface()
  */
 public function visitInterface(PHP_Depend_Code_Interface $interface)
 {
     if (false === $interface->isUserDefined()) {
         return;
     }
     $this->fireStartInterface($interface);
     // Update global class count
     ++$this->_noi;
     // Update parent package
     $packageUUID = $interface->getPackage()->getUUID();
     ++$this->_nodeMetrics[$packageUUID][self::M_NUMBER_OF_INTERFACES];
     $this->_nodeMetrics[$interface->getUUID()] = array(self::M_NUMBER_OF_METHODS => 0);
     foreach ($interface->getMethods() as $method) {
         $method->accept($this);
     }
     $this->fireEndInterface($interface);
 }
コード例 #12
0
ファイル: InterfaceTest.php プロジェクト: kingsj/core
 /**
  * Creates an abstract item instance.
  *
  * @return PHP_Depend_Code_AbstractItem
  */
 protected function createItem()
 {
     $interface = new PHP_Depend_Code_Interface(__CLASS__);
     $interface->setContext($this->getMock('PHP_Depend_Builder_Context'));
     return $interface;
 }