Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ClassTrackerVisitor | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
enterNode | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | /** |
3 | * Copyright (C) 2018 Kunal Mehta <legoktm@debian.org> |
4 | * |
5 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation, either version 3 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | namespace MediaWiki\Tool\PatchCoverage\Parser; |
20 | |
21 | use PhpParser\Node; |
22 | use PhpParser\NodeTraverser; |
23 | use PhpParser\NodeVisitorAbstract; |
24 | |
25 | /** |
26 | * Keeps track of all the classes and traits it sees |
27 | */ |
28 | class ClassTrackerVisitor extends NodeVisitorAbstract { |
29 | |
30 | /** |
31 | * @var array |
32 | */ |
33 | public $classes = []; |
34 | |
35 | /** |
36 | * @param Node $node |
37 | * |
38 | * @return int|void|null |
39 | */ |
40 | public function enterNode( Node $node ) { |
41 | if ( $node instanceof Node\Stmt\Class_ |
42 | || $node instanceof Node\Stmt\Trait_ |
43 | ) { |
44 | $this->classes[] = (string)$node->namespacedName; |
45 | return NodeTraverser::DONT_TRAVERSE_CHILDREN; |
46 | } |
47 | } |
48 | } |