Esempio n. 1
0
 public function testSimpleClassToString()
 {
     $file = new PhpFileComponent('Foo');
     $class = new PhpClassComponent('Foo', true, 'stdClass');
     $class->addAnnotationBlock('@var string')->addConstant('FOO', 'theValue')->addAnnotationBlock('@var string')->addConstant('BAR', 'theOtherValue')->addAnnotationBlock(new PhpAnnotationElement('var', 'int'))->addProperty('bar', 1)->addAnnotationBlock(new PhpAnnotationElement('var', 'bool'))->addPropertyElement(new PhpPropertyElement('sample', true))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useful'), new PhpAnnotationElement('date', '2012-03-01'), '@return mixed'))->addMethod('getMyValue', array(new PhpFunctionParameterElement('asString', true), 'unusedParameter'))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useless'), new PhpAnnotationElement('date', '2012-03-01'), '@return void'))->addMethod('uselessMethod', array(new PhpFunctionParameterElement('uselessParameter', null), 'unusedParameter'));
     $file->setNamespace('My\\Testing\\NamespaceName')->addUse('My\\Testing\\ParentNamespace\\Model')->addUse('My\\Testing\\ParentNamespace\\Repository')->addUse('My\\Testing\\ParentNamespace\\Generator')->addUse('My\\Testing\\ParentNamespace\\Foo', 'FooType', true)->addClassComponent($class);
     $this->assertSameContent(__FUNCTION__, $file);
 }
Esempio n. 2
0
 /**
  * @param PhpMethodElement $method
  * @return PhpInterface
  */
 public function addMethodElement(PhpMethodElement $method)
 {
     if ($method->getHasBody()) {
         $method->setHasBody(false);
     }
     return parent::addMethodElement($method);
 }
 /**
  * @param PhpClass $class
  */
 protected function defineStringMethod(PhpClass $class)
 {
     $class->addAnnotationBlockElement($this->getToStringMethodAnnotationBlock());
     $class->addMethodElement($this->getToStringMethod());
     return $this;
 }
Esempio n. 4
0
 public function testSimpleToString()
 {
     $class = new PhpClassComponent('Foo', true, 'stdClass');
     $class->addAnnotationBlock('@var string')->addConstant('FOO', 'theValue')->addAnnotationBlock('@var string')->addConstant('BAR', 'theOtherValue')->addAnnotationBlock(new PhpAnnotationElement('var', 'int'))->addProperty('bar', 1)->addAnnotationBlock(array('- documentation: The ID of the contact that performed the action, if available. May be blank for anonymous activity.', new PhpAnnotationElement('var', 'bool')))->addPropertyElement(new PhpPropertyElement('sample', true))->addAnnotationBlock(new PhpAnnotationElement('var', 'string'))->addPropertyElement(new PhpPropertyElement('noValue', PhpPropertyElement::NO_VALUE))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useful'), new PhpAnnotationElement('date', '2012-03-01'), '@return mixed'))->addMethod('getMyValue', array(new PhpFunctionParameterElement('asString', true), 'unusedParameter'))->addAnnotationBlock(array(new PhpAnnotationElement(PhpAnnotationElement::NO_NAME, 'This method is very useless'), new PhpAnnotationElement('date', '2012-03-01'), '@return void'))->addMethod('uselessMethod', array(new PhpFunctionParameterElement('uselessParameter', null), 'unusedParameter'));
     $this->assertSameContent(__FUNCTION__, $class);
 }
Esempio n. 5
0
 /**
  * @param PhpClassComponent $class
  * @return PhpFile
  */
 public function addClassComponent(PhpClassComponent $class)
 {
     $this->mainElement->addChild($class->toString());
     return $this;
 }