|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Patsura Dmitry https://github.com/ovr <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace PHPSA\Analyzer; |
|
7
|
|
|
|
|
8
|
|
|
use PHPSA\Analyzer; |
|
9
|
|
|
use Webiny\Component\EventManager\EventManager; |
|
10
|
|
|
use PHPSA\Analyzer\Pass as AnalyzerPass; |
|
11
|
|
|
|
|
12
|
|
|
class Factory |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param EventManager $eventManager |
|
16
|
|
|
* @return Analyzer |
|
17
|
|
|
*/ |
|
18
|
1 |
|
public static function factory(EventManager $eventManager) |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
1 |
|
$analyzer = new Analyzer($eventManager); |
|
21
|
1 |
|
$analyzer->registerExpressionPasses( |
|
22
|
|
|
[ |
|
23
|
|
|
// Another |
|
24
|
1 |
|
new AnalyzerPass\Expression\ErrorSuppression(), |
|
25
|
1 |
|
new AnalyzerPass\Expression\VariableVariableUsage(), |
|
26
|
1 |
|
new AnalyzerPass\Expression\Casts(), |
|
27
|
|
|
// Arrays |
|
28
|
1 |
|
new AnalyzerPass\Expression\ArrayShortDefinition(), |
|
29
|
1 |
|
new AnalyzerPass\Expression\ArrayDuplicateKeys(), |
|
30
|
|
|
// Function call |
|
31
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\AliasCheck(), |
|
32
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\DebugCode(), |
|
33
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\RandomApiMigration(), |
|
34
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\UseCast(), |
|
35
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\DeprecatedIniOptions(), |
|
36
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\RegularExpressions(), |
|
37
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\ArgumentUnpacking(), |
|
38
|
1 |
|
new AnalyzerPass\Expression\FunctionCall\DeprecatedFunctions(), |
|
39
|
|
|
] |
|
40
|
1 |
|
); |
|
41
|
1 |
|
$analyzer->registerStatementPasses( |
|
42
|
|
|
[ |
|
43
|
1 |
|
new AnalyzerPass\Statement\DoNotUseGoto(), |
|
44
|
1 |
|
new AnalyzerPass\Statement\MissingBreakStatement(), |
|
45
|
1 |
|
new AnalyzerPass\Statement\MethodCannotReturn(), |
|
46
|
1 |
|
new AnalyzerPass\Statement\UnexpectedUseOfThis(), |
|
47
|
1 |
|
new AnalyzerPass\Statement\OldConstructor(), |
|
48
|
|
|
] |
|
49
|
1 |
|
); |
|
50
|
1 |
|
$analyzer->bind(); |
|
51
|
|
|
|
|
52
|
1 |
|
return $analyzer; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|