1 | <?php |
||
16 | class Scanner |
||
17 | { |
||
18 | /** |
||
19 | * @var \PHPSemVerChecker\Registry\Registry |
||
20 | */ |
||
21 | protected $registry; |
||
22 | /** |
||
23 | * @var \PhpParser\Parser |
||
24 | */ |
||
25 | protected $parser; |
||
26 | /** |
||
27 | * @var \PhpParser\NodeTraverser |
||
28 | */ |
||
29 | protected $traverser; |
||
30 | |||
31 | 5 | public function __construct() |
|
32 | { |
||
33 | 5 | $this->registry = new Registry(); |
|
34 | 5 | $this->parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); |
|
35 | 5 | $this->traverser = new NodeTraverser(); |
|
36 | |||
37 | $visitors = [ |
||
38 | 5 | new NameResolver(), |
|
39 | 5 | new ClassVisitor($this->registry), |
|
40 | 5 | new InterfaceVisitor($this->registry), |
|
41 | 5 | new FunctionVisitor($this->registry), |
|
42 | 5 | new TraitVisitor($this->registry), |
|
43 | ]; |
||
44 | |||
45 | 5 | foreach ($visitors as $visitor) { |
|
46 | 5 | $this->traverser->addVisitor($visitor); |
|
47 | } |
||
48 | 5 | } |
|
49 | |||
50 | /** |
||
51 | * @param string $file |
||
52 | */ |
||
53 | 5 | public function scan($file) |
|
67 | |||
68 | /** |
||
69 | * @return \PHPSemVerChecker\Registry\Registry |
||
70 | */ |
||
71 | 1 | public function getRegistry() |
|
75 | } |
||
76 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.