Ejemplo n.º 1
0
 /**
  * Standard constructor
  */
 public function __construct(Repository $repository, $namespace)
 {
     $this->repository = $repository;
     $this->class = new PhpClass($this->repository->class->class, $namespace, false);
     $this->class->addExtends($this->repository->class->getFullyQualifiedClassname(true));
     $this->class->setClassComment($this->repository->class->classComment);
 }
Ejemplo n.º 2
0
 /**
  * Class to extend
  * @return string
  */
 private function getClassExtends()
 {
     if ($this->isMultiton()) {
         $this->class->addUses('\\Bond\\Repository\\Multiton as RM');
         $this->class->addExtends('RM');
     } else {
         $this->class->addUses('\\Bond\\Repository as R');
         $this->class->addExtends('R');
     }
 }
Ejemplo n.º 3
0
    public function testSomething()
    {
        $class = new PhpClass('Spanner', 'Fish', false);
        $class->addUses('Goat', ['Monkey', 'Bananna']);
        $class->addExtends('Wibble');
        $class->addImplements('FunTime');
        $class->classComponents[] = new FunctionDeclaration('hello', 'public function hello(){ return "hello"; }');
        $class->classComponents[] = new FunctionDeclaration('goodbye', 'public function goodbye(){ return "goodbye"; }');
        $class->classComponents[] = new FunctionDeclaration('__construct', 'public function __construct(){}');
        $class->classComponents[] = new FunctionDeclaration('multiLineDeclaration', <<<'PHP'
/**
 * Some multiline comment
 */
public function multiLineDeclaration ()
{
    return array(
        'monkey' => 'goat',
    );
}
PHP
);
        $class->classComponents[] = new VariableDeclaration('size', 'public $size = "big";');
        $class->classComponents[] = new VariableDeclaration('age', 'public $age;');
        $class->classComponents[] = new ClassConstant('t-rex', 'const T_REX = 100;');
        $php = $class->render();
        $php = new Php($class->render());
        $isValid = $php->isValid($error);
        //        echo $class->render()->addLineNumbers();
    }
Ejemplo n.º 4
0
    /**
     * Standard constructor
     */
    public function __construct(Entity $entity, $namespace)
    {
        $this->entity = $entity;
        $this->class = new PhpClass($this->entity->class->class, $namespace, false);
        $this->class->addExtends($this->entity->class->getFullyQualifiedClassname(true));
        $this->class->setClassComment($this->entity->class->classComment);
        $this->class->addUses('Symfony\\Component\\Validator\\Mapping\\ClassMetadata');
        $this->class->classComponents[] = new FunctionDeclaration('loadValidatorMetadata', (new Format(<<<'PHP'
                /**
                 * Symfony Validator Metadata.
                 * WARNING! Workaround. Symfony validator uses its own inheritance mechanism. This unusual setup is designed to short circuit that.
                 *
                 * @param ClassMetadata $metadata
                 * @return void
                 */
                public static function loadValidatorMetadata( ClassMetadata $metadata )
                {
                    parent::_loadValidatorMetaData( $metadata );
                }
PHP
))->deindent());
    }
Ejemplo n.º 5
0
 /**
  * Get class extends
  */
 protected function getClassExtends()
 {
     $this->class->addUses('Bond\\Entity\\Base');
     $this->class->addExtends('Base');
 }