コード例 #1
0
 /**
  * @param ContextInterface $context
  *
  * @return bool
  */
 public function appliesToContext(ContextInterface $context)
 {
     if (!$context instanceof PropertyContext) {
         return false;
     }
     $property = $context->getProperty();
     if (!preg_match($this->regex, $property->getName())) {
         return false;
     }
     return $this->subRule->appliesToContext($context);
 }
コード例 #2
0
ファイル: GetterAssembler.php プロジェクト: phpro/soap-client
 /**
  * @param ContextInterface|PropertyContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $property = $context->getProperty();
     try {
         $methodName = Normalizer::generatePropertyMethod('get', $property->getName());
         $class->removeMethod($methodName);
         $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => sprintf('return $this->%s;', $property->getName()), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => $property->getType()]]])]));
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
コード例 #3
0
 /**
  * @param ContextInterface|PropertyContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $property = $context->getProperty();
     try {
         // It's not possible to overwrite a property in zend-code yet!
         if ($class->hasProperty($property->getName())) {
             return;
         }
         $class->addPropertyFromGenerator(PropertyGenerator::fromArray(['name' => $property->getName(), 'visibility' => PropertyGenerator::VISIBILITY_PROTECTED, 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'var', 'description' => $property->getType()]]])]));
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }