Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove cilex #1934

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions box.json
Expand Up @@ -19,7 +19,6 @@
"tests"
],
"in": [
"vendor/cilex/cilex/src",
"vendor/composer",
"vendor/container-interop",
"vendor/doctrine/annotations/lib",
Expand Down Expand Up @@ -48,7 +47,6 @@
"vendor/psr/cache/src",
"vendor/psr/container/src",
"vendor/psr/log/Psr",
"vendor/silex/api",
"vendor/symfony",
"vendor/tedivm/stash",
"vendor/twig/twig/lib",
Expand All @@ -69,7 +67,6 @@
"tests"
],
"in": [
"vendor/cilex/cilex/src",
"vendor/composer",
"vendor/container-interop",
"vendor/doctrine/annotations/lib",
Expand Down Expand Up @@ -98,7 +95,6 @@
"vendor/psr/cache/src",
"vendor/psr/container/src",
"vendor/psr/log/Psr",
"vendor/silex/api",
"vendor/symfony",
"vendor/tedivm/stash",
"vendor/twig/twig/lib",
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Expand Up @@ -26,8 +26,6 @@
},
"require": {
"php": ">=7.0",

"cilex/cilex": "^2.0",
"symfony/console": "~2.3",

"monolog/monolog": "~1.6",
Expand Down Expand Up @@ -55,7 +53,8 @@
"webmozart/assert": "^1.2",
"padraic/phar-updater": "^1.0",
"tedivm/stash": "^0.14.2",
"phpdocumentor/flyfinder": "@beta"
"phpdocumentor/flyfinder": "@beta",
"pimple/pimple": "^3.2"
},
"minimum-stability": "stable",
"require-dev": {
Expand Down
114 changes: 1 addition & 113 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 97 additions & 27 deletions src/phpDocumentor/Application.php
Expand Up @@ -23,6 +23,8 @@
use phpDocumentor\Command\Helper\ConfigurationHelper;
use phpDocumentor\Command\Helper\LoggerHelper;
use phpDocumentor\Console\Input\ArgvInput;
use phpDocumentor\Console\Output\Output;
use Pimple\Container;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -34,11 +36,15 @@
*
* Can be used as bootstrap when the run method is not invoked.
*/
class Application extends Cilex
class Application implements \ArrayAccess
{
/** @var string $VERSION represents the version of phpDocumentor as stored in /VERSION */
public static $VERSION;

private $container;

private $console;

/**
* Initializes all components used by phpDocumentor.
*
Expand All @@ -49,11 +55,21 @@ public function __construct($autoloader = null, array $values = array())
{
$this->defineIniSettings();

$this->container = new Container();
foreach ($values as $key => $value) {
$this->container[$key] = $value;
}

self::$VERSION = strpos('@package_version@', '@') === 0
? trim(file_get_contents(__DIR__ . '/../../VERSION'))
: '@package_version@';

parent::__construct('phpDocumentor', self::$VERSION, $values);
$this->console = new \Symfony\Component\Console\Application('phpDocumentor', self::$VERSION);
$this->console->getHelperSet()->set(new LoggerHelper($this->container));

$this->container['console'] = function () {
return $this->console;
};

$this['kernel.timer.start'] = time();
$this['kernel.stopwatch'] = function () {
Expand All @@ -62,18 +78,18 @@ public function __construct($autoloader = null, array $values = array())

$this['autoloader'] = $autoloader;

$this->register(new JmsSerializerServiceProvider());
$this->register(new Configuration\ServiceProvider());
$this->container->register(new JmsSerializerServiceProvider());
$this->container->register(new Configuration\ServiceProvider());

$this->addEventDispatcher();
$this->addLogging();

$this->register(new Translator\ServiceProvider());
$this->register(new Descriptor\ServiceProvider());
$this->register(new Partials\ServiceProvider());
$this->register(new Parser\ServiceProvider());
$this->register(new Transformer\ServiceProvider());
$this->register(new Plugin\ServiceProvider());
$this->container->register(new Translator\ServiceProvider());
$this->container->register(new Descriptor\ServiceProvider());
$this->container->register(new Partials\ServiceProvider());
$this->container->register(new Parser\ServiceProvider());
$this->container->register(new Transformer\ServiceProvider());
$this->container->register(new Plugin\ServiceProvider());

$this->addCommandsForProjectNamespace();

Expand Down Expand Up @@ -161,23 +177,16 @@ public function configureLogger($logger, $level, $logPath = null)
}
}

/**
* @param null|InputInterface $input
* @param null|OutputInterface $output
* @return mixed
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
public function run()
{
/** @var ConsoleApplication $app */
$app = $this['console'];
$app->setAutoExit(false);

if ($output === null) {
$output = new Console\Output\Output();
$output->setLogger($this['monolog']);
}
$output = new Console\Output\Output();
$output->setLogger($this['monolog']);

return parent::run(new ArgvInput(), $output);
return $app->run(new ArgvInput(), $output);
}


Expand Down Expand Up @@ -237,7 +246,7 @@ protected function setTimezone()
*/
protected function addLogging()
{
$this->register(
$this->container->register(
new MonologServiceProvider(),
array(
'monolog.name' => 'phpDocumentor',
Expand All @@ -250,7 +259,7 @@ protected function addLogging()
$app = $this;
/** @var Configuration $configuration */
$configuration = $this['config'];
$this['monolog.configure'] = $this->protect(
$this['monolog.configure'] = $this->container->protect(
function ($log) use ($app, $configuration) {
$paths = $configuration->getLogging()->getPaths();
$logLevel = $configuration->getLogging()->getLevel();
Expand All @@ -259,10 +268,9 @@ function ($log) use ($app, $configuration) {
}
);

$this->extend(
$this->container->extend(
'console',
function (ConsoleApplication $console) use ($configuration) {
$console->getHelperSet()->set(new LoggerHelper());
$console->getHelperSet()->set(new ConfigurationHelper($configuration));

return $console;
Expand Down Expand Up @@ -291,7 +299,7 @@ protected function addEventDispatcher()
*/
protected function addCommandsForProjectNamespace()
{
$this->command(new Command\Project\RunCommand());
$this->console->add(new Command\Project\RunCommand($this->container['descriptor.builder']));
}

/**
Expand All @@ -301,6 +309,68 @@ protected function addCommandsForProjectNamespace()
*/
protected function addCommandsForPharNamespace()
{
$this->command(new Command\Phar\UpdateCommand());
$this->console->add(new Command\Phar\UpdateCommand());
}

/**
* Whether a offset exists
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
* @param mixed $offset <p>
* An offset to check for.
* </p>
* @return boolean true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
public function offsetExists($offset)
{
return $this->container->offsetExists($offset);
}

/**
* Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
* @return mixed Can return all value types.
* @since 5.0.0
*/
public function offsetGet($offset)
{
return $this->container[$offset];
}

/**
* Offset to set
* @link http://php.net/manual/en/arrayaccess.offsetset.php
* @param mixed $offset <p>
* The offset to assign the value to.
* </p>
* @param mixed $value <p>
* The value to set.
* </p>
* @return void
* @since 5.0.0
*/
public function offsetSet($offset, $value)
{
$this->container[$offset] = $value;
}

/**
* Offset to unset
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
* @param mixed $offset <p>
* The offset to unset.
* </p>
* @return void
* @since 5.0.0
*/
public function offsetUnset($offset)
{
$this->container->offsetUnset($offset);
}
}