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

Commit

Permalink
Fix global variables inside ClassMethod, refs #298
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Jan 15, 2017
1 parent 7f5500d commit 64a2881
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Compiler/GlobalVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ public function getSymbolType()
{
return 'global-variable';
}

/**
* {@inheritdoc}
*/
public function isGlobal()
{
return true;
}
}
2 changes: 2 additions & 0 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public function clearSymbols()
{
unset($this->symbols);
$this->symbols = [];

$this->initGlobals();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Definition/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function compile(Context $context)
$symbols = $context->getSymbols();
if (count($symbols) > 0) {
foreach ($symbols as $name => $variable) {
if ($variable->isUnused()) {
if (!$variable->isGlobal() && $variable->isUnused()) {
$context->warning(
'unused-' . $variable->getSymbolType(),
sprintf(
Expand Down
10 changes: 10 additions & 0 deletions src/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,14 @@ public function __debugInfo()
];
}
//@codeCoverageIgnoreEnd

/**
* Is global variable?
*
* @return bool
*/
public function isGlobal()
{
return false;
}
}

0 comments on commit 64a2881

Please sign in to comment.