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\KnowledgeBase\DatabaseManager; |
20
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory; |
21
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
22
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
23
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
24
|
|
|
|
25
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
26
|
|
|
{ |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
22 |
|
public function __construct(array $values = array()) |
32
|
|
|
{ |
33
|
22 |
|
parent::__construct($values); |
34
|
|
|
|
35
|
22 |
|
$this['app_name'] = 'Code-Insight'; |
36
|
22 |
|
$this['app_version'] = '@git-version@'; |
37
|
|
|
|
38
|
22 |
|
$this['working_directory_sub_folder'] = '.code-insight'; |
39
|
|
|
|
40
|
22 |
|
$this['config_defaults'] = array(); |
41
|
|
|
|
42
|
|
|
$this['project_root_folder'] = function () { |
43
|
22 |
|
return dirname(dirname(__DIR__)); |
44
|
|
|
}; |
45
|
|
|
|
46
|
|
|
$this['migration_manager'] = function ($c) { |
|
|
|
|
47
|
22 |
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
48
|
22 |
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
49
|
22 |
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
50
|
22 |
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
51
|
|
|
|
52
|
22 |
|
return $migration_manager; |
53
|
|
|
}; |
54
|
|
|
|
55
|
|
|
$this['db_manager'] = function ($c) { |
56
|
|
|
return new DatabaseManager($c['migration_manager']); |
57
|
|
|
}; |
58
|
|
|
|
59
|
|
|
$this['knowledge_base_factory'] = function ($c) { |
60
|
|
|
return new KnowledgeBaseFactory($c['db_manager']); |
61
|
|
|
}; |
62
|
|
|
|
63
|
22 |
|
$this['bc_checker_factory'] = function ($c) { |
|
|
|
|
64
|
|
|
$factory = new CheckerFactory(); |
65
|
|
|
$factory->add(new ClassChecker()); |
66
|
|
|
$factory->add(new FunctionChecker()); |
67
|
22 |
|
$factory->add(new ConstantChecker()); |
68
|
|
|
|
69
|
|
|
$factory->add(new InPortalClassChecker()); |
70
|
|
|
|
71
|
|
|
return $factory; |
72
|
|
|
}; |
73
|
22 |
|
} |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
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.