/** * @param Stmt\ClassMethod $node * * @return string */ public function convert(Stmt\ClassMethod $node) { $types = $this->typeFinder->getTypes($node, $this->dispatcher->getMetadata()); foreach ($node->params as $param) { if ($param->byRef === true) { $this->logger->logIncompatibility('reference', sprintf('Reference not supported in parametter (var "%s")', $param->name), $param, $this->dispatcher->getMetadata()->getClass()); } } if ($node->byRef) { $this->logger->logIncompatibility('reference', 'Reference not supported', $node, $this->dispatcher->getMetadata()->getClass()); } $this->dispatcher->setLastMethod($node->name); $stmt = $this->dispatcher->pModifiers($node->type) . 'function ' . $node->name . '('; $varsInMethodSign = array(); if (isset($types['params']) === true) { $params = array(); foreach ($types['params'] as $type) { $varsInMethodSign[] = $type['name']; $stringType = $this->printType($type); $params[] = (!empty($stringType) ? $stringType . ' ' : '') . '' . $type['name'] . ($type['default'] === null ? '' : ' = ' . $this->dispatcher->p($type['default'])); } $stmt .= implode(', ', $params); } $stmt .= ')'; $stmt .= $this->printReturn($node, $types); $stmt .= (null !== $node->stmts ? "\n{" . $this->printVars($node, $varsInMethodSign) . $this->dispatcher->pStmts($node->stmts) . "\n}" : ';') . "\n"; return $stmt; }
/** * @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; } return $this->dispatcher->pModifiers($node->type) . $this->dispatcher->pCommaSeparated($node->props) . ';'; }
/** * @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) . ';'; }
public function convert(Stmt\Class_ $node) { $this->classManipulator->registerClassImplements($node); $node->name = $this->reservedWordReplacer->replace($node->name); $addArrayPlusMethod = false; foreach ($this->nodeFetcher->foreachNodes($node->stmts) as $stmt) { if ($stmt['node'] instanceof AssignOp\Plus && $stmt['node']->expr instanceof Array_) { $addArrayPlusMethod = true; break; } } return $this->dispatcher->pModifiers($node->type) . 'class ' . $node->name . (null !== $node->extends ? ' extends ' . $this->dispatcher->p($node->extends) : '') . (!empty($node->implements) ? ' implements ' . $this->dispatcher->pCommaSeparated($node->implements) : '') . "\n" . '{' . $this->dispatcher->pStmts($node->stmts) . "\n" . ($addArrayPlusMethod === true ? $this->printArrayPlusMethod() : '') . '}'; }
/** * @param Stmt\ClassMethod $node * * @return string */ public function convert(Stmt\ClassMethod $node) { $types = $this->typeFinder->getTypes($node, $this->dispatcher->getMetadata()); $this->dispatcher->setLastMethod($node->name); $stmt = $this->dispatcher->pModifiers($node->type) . 'function ' . ($node->byRef ? '&' : '') . $node->name . '('; $varsInMethodSign = array(); if (isset($types['params']) === true) { $params = array(); foreach ($types['params'] as $type) { $varsInMethodSign[] = $type['name']; $stringType = $this->printType($type); $params[] = (!empty($stringType) ? $stringType . ' ' : '') . '' . $type['name'] . ($type['default'] === null ? '' : ' = ' . $this->dispatcher->p($type['default'])); } $stmt .= implode(', ', $params); } $stmt .= ')'; $stmt .= $this->printReturn($node, $types); $stmt .= (null !== $node->stmts ? "\n{" . $this->printVars($node, $varsInMethodSign) . $this->dispatcher->pStmts($node->stmts) . "\n}" : ';') . "\n"; return $stmt; }
public function convert(Stmt\Class_ $node) { $node->name = $this->reservedWordReplacer->replace($node->name); return $this->dispatcher->pModifiers($node->type) . 'class ' . $node->name . (null !== $node->extends ? ' extends ' . $this->dispatcher->p($node->extends) : '') . (!empty($node->implements) ? ' implements ' . $this->dispatcher->pCommaSeparated($node->implements) : '') . "\n" . '{' . $this->dispatcher->pStmts($node->stmts) . "\n" . '}'; }