public function visitProperty(Property $node) { $prop = $node->props[0]; $p = new PhpProperty($prop->name); $p->setStatic($node->isStatic()); $p->setVisibility($this->getVisibility($node)); $this->parseValue($p, $prop); $this->parseMemberDocblock($p, $node->getDocComment()); $this->struct->setProperty($p); }
/** * @param Stmt\Property $node * * @return string */ public function convert(Stmt\Property $node) { foreach ($node->props as $key => $prop) { $prop->name = $this->reservedWordReplacer->replace($prop->name); $node->props[$key] = $prop; } if ($node->props[0]->default instanceof Expr\Array_ && $node->isStatic() === true) { $node->type = $node->type - Stmt\Class_::MODIFIER_STATIC; $this->dispatcher->moveToNonStaticVar($node->props[0]->name); $this->logger->logNode("Static attribute default array not supported in zephir, (see #188). Changed into non static. ", $node, $this->dispatcher->getMetadata()->getFullQualifiedNameClass()); } return $this->dispatcher->pModifiers($node->type) . $this->dispatcher->pCommaSeparated($node->props) . ';'; }
/** * @param PropertyNode $node * @param ReflectionClass $declaringClass * @return ReflectionProperty */ public static function createFromNode(PropertyNode $node, ReflectionClass $declaringClass) { $prop = new self(); $prop->name = $node->props[0]->name; $prop->declaringClass = $declaringClass; if ($node->isPrivate()) { $prop->visibility = self::IS_PRIVATE; } elseif ($node->isProtected()) { $prop->visibility = self::IS_PROTECTED; } else { $prop->visibility = self::IS_PUBLIC; } $prop->isStatic = $node->isStatic(); $prop->docBlockTypes = (new FindPropertyType())->__invoke($node, $prop); return $prop; }
/** * Is the property static? * * @return bool */ public function isStatic() { return $this->node->isStatic(); }
/** * {@inheritDoc} */ public function isStatic() { return $this->propertyTypeNode->isStatic(); }
/** * @param Property $node * * @return RefProperty */ private function createProperty(Property $node) { $ref = new RefProperty(); $ref->class = $this->class; $ref->name = $node->props[0]->name; $ref->default = $this->getValue($node->props[0]->default); if ($node->isPrivate()) { $ref->visibility = Visibility::IS_PRIVATE; } elseif ($node->isProtected()) { $ref->visibility = Visibility::IS_PROTECTED; } elseif ($node->isPublic()) { $ref->visibility = Visibility::IS_PUBLIC; } $ref->isStatic = $node->isStatic(); $ref->line = $node->getLine(); $ref->docComment = $this->createDocComment($node); return $ref; }
private function processProperty(NodeType\Property $node) { $property = $node->props[0]; $member = $this->unit->addMember($property->name); if ($node->props[0]->default) { $this->setVariableDefaultValue($member, $node->props[0]->default); } $visibility = 'public'; if ($node->isPrivate()) { $visibility = 'private'; } elseif ($node->isProtected()) { $visibility = 'protected'; } $member->setVisibility($visibility); $member->setStatic($node->isStatic()); $docComment = $node->getDocComment(); if ($docComment !== NULL) { $block = $this->docBlockParser->parse($docComment, $this->aliasMap); $member->setDocBlock($block); } $member->setLine($node->getLine()); }
/** * @param Node\Stmt\Property $node */ protected function parseClassPropertyNode(Node\Stmt\Property $node) { foreach ($node->props as $property) { $this->structuralElements[$this->currentStructuralElement->namespacedName->toString()]['properties'][] = ['name' => $property->name, 'startLine' => $node->getLine(), 'isPublic' => $node->isPublic(), 'isPrivate' => $node->isPrivate(), 'isStatic' => $node->isStatic(), 'isProtected' => $node->isProtected(), 'docComment' => $node->getDocComment() ? $node->getDocComment()->getText() : null]; } }
protected function getProperty(Property $node) { $prop = $node->props[0]; $p = new PhpProperty($prop->name); $default = $prop->default; if ($default !== null) { $p->setDefaultValue($this->getValue($default)); } $p->setStatic($node->isStatic()); $p->setVisibility($this->getVisibility($node)); $this->parseMemberDocblock($p, $node->getDocComment()); return $p; }
public function addProperty(PropertyNode $node) { foreach ($node->props as $prop) { $property = new ReflectionProperty($prop->name); $property->setStartLine((int) $node->getAttribute('startLine')); $property->setEndLine((int) $node->getAttribute('endLine')); $property->setDocComment((string) $node->getDocComment()); $property->setStatic((bool) $node->isStatic()); if (!is_null($prop->default)) { $value = $this->resolveValue($prop->default); $property->setDefault(strtolower(gettype($value)), $value); } if ($node->isPrivate()) { $property->setVisibility(ReflectionProperty::IS_PRIVATE); } elseif ($node->isProtected()) { $property->setVisibility(ReflectionProperty::IS_PROTECTED); } else { $property->setVisibility(ReflectionProperty::IS_PUBLIC); } $this->context->getReflection()->addProperty($property); } }