-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
160 changed files
with
2,012 additions
and
1,899 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> and Contributors | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
|
@@ -32,7 +32,6 @@ | |
*/ | ||
namespace TheSeer\phpDox { | ||
|
||
use TheSeer\DirectoryScanner\DirectoryScanner; | ||
use TheSeer\phpDox\Collector\InheritanceResolver; | ||
use TheSeer\phpDox\Generator\Enricher\EnricherException; | ||
|
||
|
@@ -55,15 +54,16 @@ class Application { | |
|
||
/** | ||
* Factory instance | ||
* | ||
* @var Factory | ||
*/ | ||
private $factory; | ||
|
||
/** | ||
* Constructor of PHPDox Application | ||
* | ||
* @param Factory $factory Factory instance | ||
* @param ProgressLogger $logger Instance of the SilentProgressLogger class | ||
* @param Factory $factory Factory instance | ||
* @param ProgressLogger $logger Instance of the SilentProgressLogger class | ||
*/ | ||
public function __construct(Factory $factory, ProgressLogger $logger) { | ||
$this->factory = $factory; | ||
|
@@ -83,9 +83,8 @@ public function runBootstrap(FileInfoCollection $requires) { | |
return $bootstrap; | ||
} | ||
|
||
|
||
public function runConfigChangeDetection(FileInfo $workDirectory, FileInfo $configFile) { | ||
$index = new FileInfo( (string)$workDirectory . '/index.xml'); | ||
$index = new FileInfo((string)$workDirectory . '/index.xml'); | ||
if (!$index->exists() || ($index->getMTime() >= $configFile->getMTime())) { | ||
return; | ||
} | ||
|
@@ -123,7 +122,7 @@ public function runCollector(CollectorConfig $config) { | |
|
||
if ($collector->hasParseErrors()) { | ||
$this->logger->log('The following file(s) had errors during processing and were excluded:'); | ||
foreach($collector->getParseErrors() as $file => $message) { | ||
foreach ($collector->getParseErrors() as $file => $message) { | ||
$this->logger->log(' - ' . $file . ' (' . $message . ')'); | ||
} | ||
} | ||
|
@@ -134,7 +133,7 @@ public function runCollector(CollectorConfig $config) { | |
$vanished = $project->cleanVanishedFiles(); | ||
if (count($vanished) > 0) { | ||
$this->logger->log(sprintf("Removed %d vanished file(s) from project:", count($vanished))); | ||
foreach($vanished as $file) { | ||
foreach ($vanished as $file) { | ||
$this->logger->log(' - ' . $file); | ||
} | ||
} | ||
|
@@ -146,7 +145,7 @@ public function runCollector(CollectorConfig $config) { | |
|
||
if ($resolver->hasUnresolved()) { | ||
$this->logger->log('The following unit(s) had missing dependencies during inheritance resolution:'); | ||
foreach($resolver->getUnresolved() as $class => $missing) { | ||
foreach ($resolver->getUnresolved() as $class => $missing) { | ||
if (is_array($missing)) { | ||
$missing = join(', ', $missing); | ||
} | ||
|
@@ -156,7 +155,7 @@ public function runCollector(CollectorConfig $config) { | |
|
||
if ($resolver->hasErrors()) { | ||
$this->logger->log('The following unit(s) caused errors during inheritance resolution:'); | ||
foreach($resolver->getErrors() as $class => $error) { | ||
foreach ($resolver->getErrors() as $class => $error) { | ||
$this->logger->log(' - ' . $class . ': ' . implode(', ', $error)); | ||
} | ||
} | ||
|
@@ -181,8 +180,8 @@ public function runGenerator(GeneratorConfig $config) { | |
|
||
$failed = array_diff($config->getRequiredEngines(), $engineFactory->getEngineList()); | ||
if (count($failed)) { | ||
$list = join("', '", $failed); | ||
throw new ApplicationException("The engine(s) '$list' is/are not registered", ApplicationException::UnknownEngine); | ||
$list = join("', '", $failed); | ||
throw new ApplicationException("The engine(s) '$list' is/are not registered", ApplicationException::UnknownEngine); | ||
} | ||
|
||
$failed = array_diff($config->getRequiredEnrichers(), $enricherFactory->getEnricherList()); | ||
|
@@ -193,12 +192,12 @@ public function runGenerator(GeneratorConfig $config) { | |
|
||
$generator = $this->factory->getGenerator(); | ||
|
||
foreach($config->getActiveBuilds() as $buildCfg) { | ||
$generator->addEngine( $engineFactory->getInstanceFor($buildCfg) ); | ||
foreach ($config->getActiveBuilds() as $buildCfg) { | ||
$generator->addEngine($engineFactory->getInstanceFor($buildCfg)); | ||
} | ||
|
||
$this->logger->log('Loading enrichers'); | ||
foreach($config->getActiveEnrichSources() as $type => $enrichCfg) { | ||
foreach ($config->getActiveEnrichSources() as $type => $enrichCfg) { | ||
try { | ||
$enricher = $enricherFactory->getInstanceFor($enrichCfg); | ||
$generator->addEnricher($enricher); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> and Contributors | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
|
@@ -42,7 +42,6 @@ | |
*/ | ||
namespace TheSeer\phpDox { | ||
|
||
use TheSeer\fDOM\fDOMDocument; | ||
use TheSeer\fDOM\fDOMException; | ||
|
||
class CLI { | ||
|
@@ -92,18 +91,18 @@ public function run(CLIOptions $options) { | |
|
||
$this->environment->ensureFitness(); | ||
|
||
if ($options->showHelp() === TRUE) { | ||
if ($options->showHelp() === true) { | ||
$this->showVersion(); | ||
echo $options->getHelpScreen(); | ||
return self::ExitOK; | ||
} | ||
|
||
if ($options->showVersion() === TRUE) { | ||
if ($options->showVersion() === true) { | ||
$this->showVersion(); | ||
return self::ExitOK; | ||
} | ||
|
||
if ($options->generateSkel() === TRUE) { | ||
if ($options->generateSkel() === true) { | ||
$this->showSkeletonConfig($options->generateStrippedSkel()); | ||
return self::ExitOK; | ||
} | ||
|
@@ -117,7 +116,7 @@ public function run(CLIOptions $options) { | |
} | ||
|
||
$logger = $this->factory->getLogger(); | ||
$logger->log("Using config file '". $config->getConfigFile()->getPathname() . "'"); | ||
$logger->log("Using config file '" . $config->getConfigFile()->getPathname() . "'"); | ||
|
||
$app = $this->factory->getApplication(); | ||
|
||
|
@@ -148,7 +147,7 @@ public function run(CLIOptions $options) { | |
return self::ExitOK; | ||
} | ||
|
||
foreach($config->getProjects() as $projectName => $projectConfig) { | ||
foreach ($config->getProjects() as $projectName => $projectConfig) { | ||
|
||
$logger->log("Starting to process project '$projectName'"); | ||
|
||
|
@@ -158,11 +157,11 @@ public function run(CLIOptions $options) { | |
); | ||
|
||
if (!$options->generatorOnly()) { | ||
$app->runCollector( $projectConfig->getCollectorConfig() ); | ||
$app->runCollector($projectConfig->getCollectorConfig()); | ||
} | ||
|
||
if (!$options->collectorOnly()) { | ||
$app->runGenerator( $projectConfig->getGeneratorConfig() ); | ||
$app->runGenerator($projectConfig->getGeneratorConfig()); | ||
} | ||
|
||
$logger->log("Processing project '$projectName' completed."); | ||
|
@@ -180,25 +179,25 @@ public function run(CLIOptions $options) { | |
return self::ExitEnvError; | ||
} catch (CLIOptionsException $e) { | ||
$this->showVersion(); | ||
fwrite(STDERR, $e->getMessage()."\n\n"); | ||
fwrite(STDERR, $e->getMessage() . "\n\n"); | ||
fwrite(STDERR, $options->getHelpScreen()); | ||
return self::ExitParamError; | ||
} catch (ConfigLoaderException $e) { | ||
$this->showVersion(); | ||
fwrite(STDERR, "\nAn error occured while trying to load the configuration file:\n\n" . $e->getMessage(). "\n\n"); | ||
fwrite(STDERR, "\nAn error occured while trying to load the configuration file:\n\n" . $e->getMessage() . "\n\n"); | ||
if ($e->getCode() == ConfigLoaderException::NeitherCandidateExists) { | ||
fwrite(STDERR, "Using --skel might get you started.\n\n"); | ||
} | ||
return self::ExitConfigError; | ||
} catch (ConfigException $e) { | ||
fwrite(STDERR, "\nYour configuration seems to be corrupted:\n\n\t" . $e->getMessage()."\n\nPlease verify your configuration xml file.\n\n"); | ||
fwrite(STDERR, "\nYour configuration seems to be corrupted:\n\n\t" . $e->getMessage() . "\n\nPlease verify your configuration xml file.\n\n"); | ||
return self::ExitConfigError; | ||
} catch (ApplicationException $e) { | ||
fwrite(STDERR, "\nAn application error occured while processing:\n\n\t" . $e->getMessage()."\n\nPlease verify your configuration.\n\n"); | ||
fwrite(STDERR, "\nAn application error occured while processing:\n\n\t" . $e->getMessage() . "\n\nPlease verify your configuration.\n\n"); | ||
return self::ExitExecError; | ||
} catch (\Exception $e) { | ||
if ($e instanceof fDOMException) { | ||
$e->toggleFullMessage(TRUE); | ||
$e->toggleFullMessage(true); | ||
} | ||
$this->showVersion(); | ||
$errorHandler->handleException($e); | ||
|
@@ -214,11 +213,11 @@ public function run(CLIOptions $options) { | |
* Helper to output version information. | ||
*/ | ||
private function showVersion() { | ||
static $shown = FALSE; | ||
static $shown = false; | ||
if ($shown) { | ||
return; | ||
} | ||
$shown = TRUE; | ||
$shown = true; | ||
echo $this->version->getInfoString() . "\n\n"; | ||
} | ||
|
||
|
@@ -229,7 +228,7 @@ private function showSkeletonConfig($strip) { | |
|
||
private function showList($title, Array $list) { | ||
echo "\nThe following $title are registered:\n\n"; | ||
foreach($list as $name => $desc) { | ||
foreach ($list as $name => $desc) { | ||
printf(" %s \t %s\n", $name, $desc); | ||
} | ||
echo "\n\n"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of Arne Blankerts nor the names of contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package phpDox | ||
* @author Arne Blankerts <[email protected]> | ||
* @copyright Arne Blankerts <[email protected]>, All rights reserved. | ||
* @license BSD License | ||
* | ||
*/ | ||
/** | ||
* Copyright (c) 2010-2019 Arne Blankerts <[email protected]> and Contributors | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of Arne Blankerts nor the names of contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package phpDox | ||
* @author Arne Blankerts <[email protected]> | ||
* @copyright Arne Blankerts <[email protected]>, All rights reserved. | ||
* @license BSD License | ||
* | ||
*/ | ||
|
||
namespace TheSeer\phpDox { | ||
|
||
class CLIOptions { | ||
|
||
private $argv; | ||
|
||
private $parsed; | ||
|
||
public function __construct(array $argv) { | ||
|
@@ -125,24 +126,24 @@ public function collectorOnly() { | |
} | ||
|
||
private function parse() { | ||
$options = array( | ||
'file','help','version','collector','generator', 'engines', 'enrichers', 'backends', 'skel', 'strip' | ||
); | ||
$shortMap = array( | ||
$options = [ | ||
'file', 'help', 'version', 'collector', 'generator', 'engines', 'enrichers', 'backends', 'skel', 'strip' | ||
]; | ||
$shortMap = [ | ||
'f' => 'file', | ||
'h' => 'help', | ||
'c' => 'collector', | ||
'g' => 'generator', | ||
'v' => 'version' | ||
); | ||
$valueOptions = array( | ||
]; | ||
$valueOptions = [ | ||
'file' | ||
); | ||
]; | ||
|
||
$conflictingOptions = array( | ||
'collector' => array('generator'), | ||
'generator' => array('collector') | ||
); | ||
$conflictingOptions = [ | ||
'collector' => ['generator'], | ||
'generator' => ['collector'] | ||
]; | ||
|
||
$argv = $this->argv; | ||
array_map('trim', $argv); | ||
|
@@ -151,13 +152,13 @@ private function parse() { | |
array_shift($argv); | ||
} | ||
|
||
foreach($options as $opt) { | ||
$this->parsed[$opt] = FALSE; | ||
foreach ($options as $opt) { | ||
$this->parsed[$opt] = false; | ||
} | ||
|
||
$valueExcepted = false; | ||
$argName = ''; | ||
foreach($argv as $arg) { | ||
foreach ($argv as $arg) { | ||
if ($arg[0] == '-') { | ||
if (strlen($arg) == 1) { | ||
throw new CLIOptionsException( | ||
|
@@ -181,15 +182,15 @@ private function parse() { | |
$argName = $shortMap[$argChar]; | ||
} | ||
if (isset($conflictingOptions[$argName])) { | ||
foreach($conflictingOptions[$argName] as $conflict) { | ||
foreach ($conflictingOptions[$argName] as $conflict) { | ||
if ($this->parsed[$conflict]) { | ||
throw new CLIOptionsException( | ||
sprintf('Option "%s" conflicts with already set option "%s"', $argName, $conflict) | ||
); | ||
} | ||
} | ||
} | ||
$this->parsed[$argName] = TRUE; | ||
$this->parsed[$argName] = true; | ||
$valueExcepted = in_array($argName, $valueOptions); | ||
continue; | ||
} | ||
|
Oops, something went wrong.