|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Code-Insight library. |
|
4
|
|
|
* For the full copyright and license information, please view |
|
5
|
|
|
* the LICENSE file that was distributed with this source code. |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
|
8
|
|
|
* @link https://github.com/console-helpers/code-insight |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\CodeInsight; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\BreakFilter; |
|
15
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\CheckerFactory; |
|
16
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\ClassChecker; |
|
17
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\ConstantChecker; |
|
18
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\FunctionChecker; |
|
19
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\InPortalClassChecker; |
|
20
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\HtmlReporter; |
|
21
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\JsonReporter; |
|
22
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\ReporterFactory; |
|
23
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\TextReporter; |
|
24
|
|
|
use ConsoleHelpers\CodeInsight\Cache\CacheFactory; |
|
25
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager; |
|
26
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory; |
|
27
|
|
|
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor; |
|
28
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
|
29
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
|
30
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
|
31
|
|
|
|
|
32
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
|
33
|
|
|
{ |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
34 |
|
public function __construct(array $values = array()) |
|
39
|
|
|
{ |
|
40
|
34 |
|
parent::__construct($values); |
|
41
|
|
|
|
|
42
|
34 |
|
$this['app_name'] = 'Code-Insight'; |
|
43
|
34 |
|
$this['app_version'] = '@git-version@'; |
|
44
|
|
|
|
|
45
|
34 |
|
$this['working_directory_sub_folder'] = '.code-insight'; |
|
46
|
|
|
|
|
47
|
34 |
|
$this['config_defaults'] = array( |
|
48
|
|
|
'cache.provider' => '', |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
$this['project_root_folder'] = function () { |
|
52
|
34 |
|
return dirname(dirname(__DIR__)); |
|
53
|
|
|
}; |
|
54
|
|
|
|
|
55
|
|
|
$this['migration_manager'] = function ($c) { |
|
|
|
|
|
|
56
|
34 |
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
|
57
|
34 |
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
|
58
|
34 |
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
|
59
|
34 |
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
|
60
|
|
|
|
|
61
|
34 |
|
return $migration_manager; |
|
62
|
|
|
}; |
|
63
|
|
|
|
|
64
|
|
|
$this['db_manager'] = function ($c) { |
|
65
|
|
|
return new DatabaseManager($c['migration_manager'], $c['working_directory']); |
|
66
|
|
|
}; |
|
67
|
|
|
|
|
68
|
|
|
$this['knowledge_base_factory'] = function ($c) { |
|
69
|
|
|
return new KnowledgeBaseFactory($c['db_manager']); |
|
70
|
|
|
}; |
|
71
|
|
|
|
|
72
|
|
|
$this['bc_checker_factory'] = function ($c) { |
|
73
|
|
|
$cache = $c['cache']; |
|
74
|
|
|
|
|
75
|
|
|
$factory = new CheckerFactory(); |
|
76
|
|
|
$factory->add(new ClassChecker($cache)); |
|
77
|
|
|
$factory->add(new FunctionChecker($cache)); |
|
78
|
|
|
$factory->add(new ConstantChecker($cache)); |
|
79
|
|
|
|
|
80
|
|
|
$factory->add(new InPortalClassChecker($cache)); |
|
81
|
|
|
|
|
82
|
|
|
return $factory; |
|
83
|
|
|
}; |
|
84
|
|
|
|
|
85
|
|
|
$this['bc_reporter_factory'] = function ($c) { |
|
86
|
|
|
$factory = new ReporterFactory(); |
|
87
|
|
|
$factory->add(new TextReporter()); |
|
88
|
|
|
$factory->add(new HtmlReporter()); |
|
89
|
|
|
$factory->add(new JsonReporter()); |
|
90
|
|
|
|
|
91
|
|
|
return $factory; |
|
92
|
|
|
}; |
|
93
|
|
|
|
|
94
|
|
|
$this['bc_break_filter'] = function ($c) { |
|
95
|
|
|
return new BreakFilter(); |
|
96
|
|
|
}; |
|
97
|
|
|
|
|
98
|
|
|
$this['cache'] = function ($c) { |
|
99
|
|
|
/** @var ConfigEditor $config_editor */ |
|
100
|
|
|
$config_editor = $c['config_editor']; |
|
101
|
|
|
$cache_provider = $config_editor->get('cache.provider'); |
|
102
|
|
|
|
|
103
|
|
|
$cache_factory = new CacheFactory(''); |
|
104
|
|
|
|
|
105
|
|
|
return $cache_factory->create('chain', array('array', $cache_provider)); |
|
106
|
|
|
}; |
|
107
|
34 |
|
} |
|
108
|
|
|
|
|
109
|
|
|
} |
|
110
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.