Beispiel #1
0
 /**
  * Builds a new function instance.
  *
  * @param string $name The function name.
  *
  * @return PHP_Depend_Code_Function The function instance.
  */
 public function buildFunction($name)
 {
     $this->checkBuilderState();
     // Debug function creation
     PHP_Depend_Util_Log::debug('Creating: PHP_Depend_Code_Function(' . $name . ')');
     // Create new function
     $function = new PHP_Depend_Code_Function($name);
     $function->setSourceFile($this->defaultFile);
     return $function;
 }
Beispiel #2
0
 /**
  * Tests that build interface updates the source file information for null
  * values.
  *
  * @return void
  */
 public function testSetSourceFileInformationForNullValue()
 {
     $item = new PHP_Depend_Code_Function('func');
     $file = new PHP_Depend_Code_File(__FILE__);
     $this->assertNull($item->getSourceFile());
     $item->setSourceFile($file);
     $this->assertSame($file, $item->getSourceFile());
 }
Beispiel #3
0
 /**
  * Creates a ready to use function fixture.
  *
  * @param string $name Optional function name.
  *
  * @return PHP_Depend_Code_Function
  * @since 1.0.2
  */
 protected function createFunctionFixture($name = null)
 {
     $name = $name ? $name : get_class($this);
     $function = new PHP_Depend_Code_Function($name);
     $function->setSourceFile(new PHP_Depend_Code_File($GLOBALS['argv'][0]));
     $function->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     $function->addChild(new PHP_Depend_Code_ASTFormalParameters());
     return $function;
 }
Beispiel #4
0
 /**
  * testBuilderCreatesExpectedIdentifierForSecondFunction
  *
  * @return void
  */
 public function testBuilderCreatesExpectedIdentifierForSecondFunction()
 {
     $file = new PHP_Depend_Code_File(__FILE__);
     $file->setUuid('FooBar');
     $function1 = new PHP_Depend_Code_Function(__FUNCTION__);
     $function1->setSourceFile($file);
     $function2 = new PHP_Depend_Code_Function(__CLASS__);
     $function2->setSourceFile($file);
     $builder = new PHP_Depend_Util_UuidBuilder();
     $builder->forFunction($function1);
     $this->assertRegExp('/^FooBar\\-[a-z0-9]{11}\\-00$/', $builder->forFunction($function2));
 }
Beispiel #5
0
 /**
  * Creates an abstract item instance.
  *
  * @return PHP_Depend_Code_AbstractItem
  */
 protected function createItem()
 {
     $function = new PHP_Depend_Code_Function(__FUNCTION__);
     $function->setSourceFile(new PHP_Depend_Code_File(__FILE__));
     $function->setContext($this->getMock('PHP_Depend_Builder_Context'));
     return $function;
 }