コード例 #1
0
ファイル: ClassTest.php プロジェクト: rouffj/pdepend
 /**
  * Creates an abstract item instance.
  *
  * @return PHP_Depend_Code_AbstractItem
  */
 protected function createItem()
 {
     $class = new PHP_Depend_Code_Class(__CLASS__);
     $class->setSourceFile(new PHP_Depend_Code_File(__FILE__));
     $class->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     $class->setContext($this->getMock('PHP_Depend_Builder_Context'));
     return $class;
 }
コード例 #2
0
ファイル: ClassTest.php プロジェクト: kingsj/core
 /**
  * testGetEndLineReturnsEndLineOfLastToken
  *
  * @return void
  * @group pdepend
  * @group pdepend::code
  * @group unittest
  */
 public function testGetEndLineReturnsEndLineOfLastToken()
 {
     $cache = $this->getMock('PHP_Depend_Util_Cache_Driver');
     $cache->expects($this->once())->method('type')->will($this->returnValue($cache));
     $class = new PHP_Depend_Code_Class(__CLASS__);
     $class->setCache($cache)->setTokens(array(new PHP_Depend_Token(1, 'a', 23, 42, 0, 0), new PHP_Depend_Token(2, 'b', 17, 32, 0, 0)));
     self::assertEquals(32, $class->getEndLine());
 }
コード例 #3
0
ファイル: Default.php プロジェクト: kingsj/core
 /**
  * Builds a new class instance or reuses a previous created class.
  *
  * Where possible you should give a qualified class name, that is prefixed
  * with the package identifier.
  *
  * <code>
  *   $builder->buildClass('php::depend::Parser');
  * </code>
  *
  * To determine the correct class, this method implements the following
  * algorithm.
  *
  * <ol>
  *   <li>Check for an exactly matching instance and reuse it.</li>
  *   <li>Check for a class 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 class is in the default package, if this
  *   is true, reuse the first class instance and ignore the default package.
  *   </li>
  *   <li>Create a new instance for the specified package.</li>
  * </ol>
  *
  * @param string $name The class name.
  *
  * @return PHP_Depend_Code_Class The created class object.
  */
 public function buildClass($name)
 {
     $this->checkBuilderState();
     $class = new PHP_Depend_Code_Class($this->extractTypeName($name));
     $class->setCache($this->cache)->setContext($this->context)->setSourceFile($this->defaultFile);
     return $class;
 }
コード例 #4
0
ファイル: AbstractTest.php プロジェクト: rouffj/pdepend
 /**
  * Creates a ready to use class fixture.
  *
  * @param string $name Optional class name.
  *
  * @return PHP_Depend_Code_Class
  * @since 1.0.2
  */
 protected function createClassFixture($name = null)
 {
     $name = $name ? $name : get_class($this);
     $class = new PHP_Depend_Code_Class($name);
     $class->setSourceFile(new PHP_Depend_Code_File($GLOBALS['argv'][0]));
     $class->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     $class->setContext($this->getMock('PHP_Depend_Builder_Context'));
     return $class;
 }