-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from kasimi/lang-keys
Scan all array literals for language keys
- Loading branch information
Showing
5 changed files
with
97 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* | ||
* EPV :: The phpBB Forum Extension Pre Validator. | ||
* | ||
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com> | ||
* @license GNU General Public License, version 2 (GPL-2.0) | ||
* | ||
*/ | ||
namespace Phpbb\Epv\Tests; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Expr\Array_; | ||
use PhpParser\Node\Expr\ArrayItem; | ||
use PhpParser\Node\Scalar\String_; | ||
use PhpParser\NodeVisitorAbstract; | ||
|
||
class ArrayKeyVisitor extends NodeVisitorAbstract | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $keys; | ||
|
||
/** | ||
* @param array $nodes | ||
* @return void|null|Node[] | ||
*/ | ||
public function beforeTraverse(array $nodes) | ||
{ | ||
$this->keys = []; | ||
} | ||
|
||
/** | ||
* @param Node $node | ||
* @return void|null|int|Node | ||
*/ | ||
public function enterNode(Node $node) | ||
{ | ||
if ($node instanceof Array_) | ||
{ | ||
foreach ($node->items as $item) | ||
{ | ||
/** @var ArrayItem $item */ | ||
if ($item->key instanceof String_) | ||
{ | ||
$this->keys[] = $item->key->value; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function get_array_keys() | ||
{ | ||
return $this->keys; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters