Exemple #1
0
 /**
  * Returns the modifier method prefix
  *
  * @param Method $method
  *
  * @return string
  */
 private function getModifiersString(Method $method)
 {
     $modifiers = array();
     if ($method->isAbstract()) {
         $modifiers[] = 'abstract';
     }
     if ($method->isFinal()) {
         $modifiers[] = 'final';
     }
     $modifiers[] = $method->getVisibility();
     if ($method->isStatic()) {
         $modifiers[] = 'static';
     }
     return implode(' ', $modifiers);
 }
Exemple #2
0
 /**
  * @param \ReflectionMethod $method
  * @return \Phpy\Method\Method
  */
 public function method(\ReflectionMethod $method)
 {
     $phpyMethod = new Method($method->getName());
     $phpyMethod->setStatic($method->isStatic())->setFinal($method->isFinal())->setAbstract($method->isAbstract());
     if ($method->isPublic()) {
         $phpyMethod->setVisibility('public');
     } elseif ($method->isProtected()) {
         $phpyMethod->setVisibility('protected');
     } else {
         $phpyMethod->setVisibility('private');
     }
     foreach ($method->getParameters() as $refParameter) {
         $phpyMethod->addParameter($this->parameter($refParameter));
     }
     return $phpyMethod;
 }
 public function testRealizeRequestBodyIfMethodIsNotAbstract()
 {
     $this->method->setAbstract(false);
     $this->funcRealizerMock->expects($this->any())->method('realize')->with($this->anything(), true);
     $this->methodRealizer->realize($this->method);
 }
Exemple #4
0
 /**
  * Add a method to the class
  *
  * @param Method $method
  * @throws \InvalidArgumentException
  * @return MetaClass The current instance
  */
 public function addMethod(Method $method)
 {
     if ($this->hasMethod($method->getName())) {
         throw new \InvalidArgumentException('Class already has a method named ' . $method->getName());
     }
     $this->methods[] = $method;
     return $this;
 }
Exemple #5
0
 public function testAbstractCanBeSetToFalseIfFinalIsTrueAndViceVersa()
 {
     $this->method->setFinal(true)->setAbstract(false);
     $this->method->setFinal(false)->setAbstract(true)->setFinal(false);
 }