Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
249 lines (225 loc) · 7.01 KB

File metadata and controls

249 lines (225 loc) · 7.01 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?php
/**
* phpDocumentor
*
* PHP Version 5
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor;
/**
* Finds and activates the autoloader.
*/
require_once findAutoloader();
use Symfony\Component\Console\Input\InputInterface;
use Cilex\Application as Cilex;
use Cilex\Provider\MonologServiceProvider;
/**
* Application class for phpDocumentor.
*
* Can be used as bootstrap when the run method is not invoked.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class Application extends Cilex
{
const VERSION = '2.0.0a12';
/**
* Initializes all components used by phpDocumentor.
*/
public function __construct()
{
parent::__construct('phpDocumentor', self::VERSION);
$this->addAutoloader();
$this->addLogging();
$this->setTimezone();
$this->addConfiguration();
$this->addEventDispatcher();
$this->loadPlugins();
$this['console']->getHelperSet()->set(
new \phpDocumentor\Console\Helper\ProgressHelper()
);
$this->addCommandsForProjectNamespace();
$this->addCommandsForTemplateNamespace();
$this->addCommandsForTemplateNamespace();
}
/**
* Run the application and if no command is provided, use project:run.
*
* @param bool $interactive Whether to run in interactive mode.
*
* @return void
*/
public function run($interactive = false)
{
$app = $this['console'];
if ($interactive) {
$app = new \Symfony\Component\Console\Shell($app);
}
$app->run(new \phpDocumentor\Console\Input\ArgvInput());
}
/**
* Adds the command to phpDocumentor that belong to the Project namespace.
*
* @return void
*/
protected function addCommandsForProjectNamespace()
{
$this->command(new \phpDocumentor\Command\Project\ParseCommand());
$this->command(new \phpDocumentor\Command\Project\RunCommand());
$this->command(new \phpDocumentor\Command\Project\TransformCommand());
}
/**
* Adds the command to phpDocumentor that belong to the plugin namespace.
*
* @return void
*/
protected function addCommandsForPluginNamespace()
{
$this->command(new \phpDocumentor\Command\Plugin\GenerateCommand());
}
/**
* Adds the command to phpDocumentor that belong to the Template namespace.
*
* @return void
*/
protected function addCommandsForTemplateNamespace()
{
$this->command(new \phpDocumentor\Command\Template\GenerateCommand());
$this->command(new \phpDocumentor\Command\Template\ListCommand());
$this->command(new \phpDocumentor\Command\Template\PackageCommand());
}
/**
* Instantiates the autoloader and adds it to phpDocumentor's container.
*
* @return void
*/
protected function addAutoloader()
{
$this['autoloader'] = include findAutoloader();
}
/**
* Adds a logging provider to the container of phpDocumentor.
*
* @return void
*/
protected function addLogging()
{
$this->register(
new MonologServiceProvider(),
array(
'monolog.name' => 'phpDocumentor',
'monolog.logfile' => sys_get_temp_dir().'/phpdoc.log'
)
);
}
/**
* If the timezone is not set anywhere, set it to UTC.
*
* This is done to prevent any warnings being outputted in relation to using
* date/time functions. What is checked is php.ini, and if the PHP version
* is prior to 5.4, the TZ environment variable.
*
* @return void
*/
public function setTimezone()
{
if (false === ini_get('date.timezone')
|| (version_compare(phpversion(), '5.4.0', '<')
&& false === getenv('TZ'))
) {
date_default_timezone_set('UTC');
}
}
/**
* Adds the Configuration object to the DIC.
*
* phpDocumentor first loads the template config file (/data/phpdoc.tpl.xml)
* and then the phpdoc.dist.xml, or the phpdoc.xml if it exists but not both,
* from the current working directory.
*
* The user config file (either phpdox.dist.xml or phpdoc.xml) is merged
* with the template file.
*
* @return void
*/
protected function addConfiguration()
{
$this['config'] = $this->share(
function () {
$user_config_file = (file_exists(getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.xml'))
? getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.xml'
: getcwd() . DIRECTORY_SEPARATOR . 'phpdoc.dist.xml';
$config_files = array(__DIR__ . '/../../data/phpdoc.tpl.xml');
if (is_readable($user_config_file)) {
$config_files[] = $user_config_file;
}
return \Zend\Config\Factory::fromFiles($config_files, true);
}
);
}
/**
* Adds the event dispatcher to phpDocumentor's container.
*
* @return void
*/
protected function addEventDispatcher()
{
$this['event_dispatcher'] = $this->share(
function () {
return Event\Dispatcher::getInstance();
}
);
}
/**
* Load the plugins.
*
* phpDocumentor instantiates the plugin manager given the Event Dispatcher,
* Configuration and autoloader.
* Using this manager it will read the configuration and load the required
* plugins.
*
* @return void
*/
protected function loadPlugins()
{
$app = $this;
$this['plugin_manager'] = $this->share(
function () use ($app) {
$manager = new \phpDocumentor\Plugin\Manager(
$app['event_dispatcher'],
$app['config'],
$app['autoloader']
);
return $manager;
}
);
$this['plugin_manager']->loadFromConfiguration();
}
}
/**
* Tries to find the autoloader relative to ththis file and return its path.
*
* @throws \RuntimeException if the autoloader could not be found.
*
* @return string the path of the autoloader.
*/
function findAutoloader()
{
$autoloader_base_path = '/../../vendor/autoload.php';
// if the file does not exist from a base path it is included as vendor
$autoloader_location = file_exists(__DIR__ . $autoloader_base_path)
? __DIR__ . $autoloader_base_path
: __DIR__ . '/../../..' . $autoloader_base_path;
if (!file_exists($autoloader_location)) {
throw new \RuntimeException(
'Unable to find autoloader at ' . $autoloader_location
);
}
return $autoloader_location;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.