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\CheckerFactory; |
15
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\ClassChecker; |
16
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\ConstantChecker; |
17
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\FunctionChecker; |
18
|
|
|
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\InPortalClassChecker; |
19
|
|
|
use ConsoleHelpers\CodeInsight\Cache\CacheFactory; |
20
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager; |
21
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory; |
22
|
|
|
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor; |
23
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
24
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
25
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
26
|
|
|
|
27
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
28
|
|
|
{ |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
22 |
|
public function __construct(array $values = array()) |
34
|
22 |
|
{ |
35
|
22 |
|
parent::__construct($values); |
36
|
|
|
|
37
|
22 |
|
$this['app_name'] = 'Code-Insight'; |
38
|
22 |
|
$this['app_version'] = '@git-version@'; |
39
|
|
|
|
40
|
22 |
|
$this['working_directory_sub_folder'] = '.code-insight'; |
41
|
|
|
|
42
|
22 |
|
$this['config_defaults'] = array( |
43
|
22 |
|
'cache.provider' => '', |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
$this['project_root_folder'] = function () { |
47
|
22 |
|
return dirname(dirname(__DIR__)); |
48
|
|
|
}; |
49
|
|
|
|
50
|
|
|
$this['migration_manager'] = function ($c) { |
|
|
|
|
51
|
22 |
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
52
|
22 |
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
53
|
22 |
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
54
|
22 |
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
55
|
|
|
|
56
|
22 |
|
return $migration_manager; |
57
|
|
|
}; |
58
|
|
|
|
59
|
|
|
$this['db_manager'] = function ($c) { |
60
|
|
|
return new DatabaseManager($c['migration_manager']); |
61
|
|
|
}; |
62
|
|
|
|
63
|
|
|
$this['knowledge_base_factory'] = function ($c) { |
64
|
|
|
return new KnowledgeBaseFactory($c['db_manager']); |
65
|
|
|
}; |
66
|
|
|
|
67
|
|
|
$this['bc_checker_factory'] = function ($c) { |
68
|
|
|
$cache = $c['cache']; |
69
|
|
|
|
70
|
|
|
$factory = new CheckerFactory(); |
71
|
|
|
$factory->add(new ClassChecker($cache)); |
72
|
|
|
$factory->add(new FunctionChecker($cache)); |
73
|
|
|
$factory->add(new ConstantChecker($cache)); |
74
|
|
|
|
75
|
|
|
$factory->add(new InPortalClassChecker($cache)); |
76
|
|
|
|
77
|
|
|
return $factory; |
78
|
|
|
}; |
79
|
|
|
|
80
|
|
|
$this['cache'] = function ($c) { |
81
|
|
|
/** @var ConfigEditor $config_editor */ |
82
|
|
|
$config_editor = $c['config_editor']; |
83
|
|
|
$cache_provider = $config_editor->get('cache.provider'); |
84
|
|
|
|
85
|
|
|
$cache_factory = new CacheFactory(''); |
86
|
|
|
|
87
|
|
|
return $cache_factory->create('chain', array('array', $cache_provider)); |
88
|
|
|
}; |
89
|
22 |
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
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.