Exemplo n.º 1
0
 /**
  * @group ZF-6444
  */
 public function testPropertyWillLoadFromReflection()
 {
     $reflectionClass = new \Zend\Reflection\ReflectionClass('\\ZendTest\\CodeGenerator\\PHP\\TestAsset\\TestClassWithManyProperties');
     // test property 1
     $reflProp = $reflectionClass->getProperty('_bazProperty');
     $cgProp = PHP\PHPProperty::fromReflection($reflProp);
     $this->assertEquals('_bazProperty', $cgProp->getName());
     $this->assertEquals(array(true, false, true), $cgProp->getDefaultValue()->getValue());
     $this->assertEquals('private', $cgProp->getVisibility());
     $reflProp = $reflectionClass->getProperty('_bazStaticProperty');
     // test property 2
     $cgProp = PHP\PHPProperty::fromReflection($reflProp);
     $this->assertEquals('_bazStaticProperty', $cgProp->getName());
     $this->assertEquals(\ZendTest\CodeGenerator\PHP\TestAsset\TestClassWithManyProperties::FOO, $cgProp->getDefaultValue()->getValue());
     $this->assertTrue($cgProp->isStatic());
     $this->assertEquals('private', $cgProp->getVisibility());
 }
Exemplo n.º 2
0
 /**
  * @param  string $method
  * @return \Zend\Reflection\ReflectionParameter
  */
 private function _getFirstReflectionParameter($method)
 {
     $reflClass = new \Zend\Reflection\ReflectionClass('\\ZendTest\\CodeGenerator\\Php\\TestAsset\\ParameterClass');
     $method = $reflClass->getMethod($method);
     $params = $method->getParameters();
     return array_shift($params);
 }
Exemplo n.º 3
0
 /**
  * Generate map of public class attributes
  *
  * @param  string $typename type name
  * @param  DOMElement $typexml target XML element
  * @return void
  */
 protected function _addClassAttributes($typename, \DOMElement $typexml)
 {
     // Do not try to autoload here because _phpTypeToAS should
     // have already attempted to load this class
     if (!class_exists($typename, false)) {
         return;
     }
     $rc = new \Zend\Reflection\ReflectionClass($typename);
     foreach ($rc->getProperties() as $prop) {
         if (!$prop->isPublic()) {
             continue;
         }
         $propxml = $this->_xml->createElement('property');
         $propxml->setAttribute('name', $prop->getName());
         $type = $this->_registerType($this->_getPropertyType($prop));
         $propxml->setAttribute('type', $type);
         $typexml->appendChild($propxml);
     }
 }