Пример #1
0
 /**
  * @param  Prop   $prop
  * @param  string $namespace
  * @return string
  */
 protected static function getPhpDocHint(Prop $prop, $namespace)
 {
     if ($prop->hasMethod(Add::PREFIX) || $prop->hasMethod(Remove::PREFIX)) {
         return 'array ';
     }
     $hint = $prop->getPhpDocHint($namespace);
     return '' === $hint ? $hint : $hint . ' ';
 }
 /**
  * @param  Prop   $prop
  * @param  string $namespace
  * @return string
  */
 protected static function getPhpDocHint(Prop $prop, $namespace)
 {
     $hint = $prop->getPhpDocHint($namespace);
     if ('' === $hint) {
         return $hint;
     }
     if ('[]' === substr($hint, -2)) {
         return substr($hint, 0, -2) . ' ';
     }
     return $hint . ' ';
 }
Пример #3
0
 public function testRegisterMethods()
 {
     $prop = new Prop('test');
     $prop->method(Get::PREFIX);
     $prop->method(Is::PREFIX);
     $prop->method(Set::PREFIX);
     $this->assertTrue($prop->hasMethod(Get::PREFIX));
     $this->assertTrue($prop->hasMethod(Is::PREFIX));
     $this->assertTrue($prop->hasMethod(Set::PREFIX));
 }
Пример #4
0
 /**
  * @param  Prop       $property
  * @return static
  * @throws \Exception
  */
 protected final function _prop(Prop $property)
 {
     $name = $property->getName();
     if (!property_exists($this, $name)) {
         throw new \InvalidArgumentException("Property does not exists");
     }
     if (isset($this->__props[$name])) {
         throw new \Exception("Override Property is not allowed, to enhance stability!");
     }
     $this->__props[$name] = $property;
     return $this;
 }
Пример #5
0
 /**
  * @param  Prop   $prop
  * @param  string $namespace
  * @return string
  */
 protected static function getPhpDocHint(Prop $prop, $namespace)
 {
     $hint = $prop->getPhpDocHint($namespace);
     return '' !== $hint ? $hint . ' ' : '';
 }
Пример #6
0
 /**
  * @param  Prop   $prop
  * @param  string $namespace
  * @return string
  */
 public static function generatePhpDoc(Prop $prop, $namespace)
 {
     $name = $prop->getName();
     return '* @method $this ' . static::PREFIX . ucfirst($name) . '(' . static::getPhpDocHint($prop, $namespace) . '$' . $name . ')';
 }