Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
[Compiler] Initial support for getFullyQualifiedNodeName
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Dec 28, 2016
1 parent f35e6f7 commit ea46d3e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ public function getFunctionNS($name, $namespace = null)
return false;
}

/**
* @param string $name
* @return ClassDefinition|null
*/
public function getClass($name)
{
if (isset($this->classes[$name])) {
return $this->classes[$name];
}

return null;
}

/**
* @param string $name
* @return TraitDefinition|null
Expand Down
11 changes: 10 additions & 1 deletion src/Compiler/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,17 @@ public function declareVariable(Node\Expr\Variable $expr, $value = null, $type =
*/
public function getFullyQualifiedNodeName(Node\Name\FullyQualified $expr)
{
$this->context->debug('Unimplemented FullyQualified', $expr);
$compiler = $this->context->getApplication()->compiler;

$classDefinition = $compiler->getClass($expr->toString());
if ($classDefinition) {
return new CompiledExpression(
CompiledExpression::OBJECT,
$classDefinition
);
}

$this->context->debug('Unimplemented FullyQualified', $expr);
return new CompiledExpression();
}

Expand Down
8 changes: 8 additions & 0 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,12 @@ public function getEventManager()
{
return $this->eventManager;
}

/**
* @return Application
*/
public function getApplication()
{
return $this->application;
}
}

0 comments on commit ea46d3e

Please sign in to comment.