Skip to content

Commit

Permalink
Rework autoload handling (fixes #179, fixes #181)
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Nov 29, 2014
1 parent 96bc460 commit edfcd32
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 45 deletions.
12 changes: 2 additions & 10 deletions bootstrap/backends.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,9 @@
* @license BSD License
*/
namespace TheSeer\phpDox {
/**
* @var BootstrapApi $phpDox
*/

// nikic's PHPParser
if (!class_exists('PhpParser\Autoloader', true)) {
require __DIR__ . '/../vendor/nikic/php-parser/lib/bootstrap.php';
}
/** @var BootstrapApi $phpDox */

if (class_exists('PhpParser\Autoloader', false)) {
$phpDox->registerBackend('parser', 'PHP Parser');
}
$phpDox->registerBackend('parser', 'PHP Parser');

}
11 changes: 9 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@

<target name="phpab">
<exec executable="phpab">
<arg line='--cache ${basedir}/build/autoload.cache -o src/autoload.php' />
<arg line="--cache ${basedir}/build/phpab/autoload.cache -o src/autoload.php" />
<arg path="src" />
</exec>
<exec executable="phpab">
<arg line="--cache ${basedir}/build/phpab/autoload.cache" />
<arg line="-o src/vendor.php" />
<arg line="-b vendor" />
<arg line="-t ${basedir}/build/phpab/vendor.tpl" />
<arg path="vendor/phpunit/php-timer/PHP" />
<arg path="vendor/nikic/php-parser/lib" />
<arg path="vendor/theseer/*/src" />
</exec>
</target>
Expand Down Expand Up @@ -184,7 +191,7 @@
</exec>

<chmod file="${basedir}/build/phar/phpdox-${version}.phar" perm="ugo+rx"/>
<delete dir="${basedir}/build/phar/_tmp"/>
<!--<delete dir="${basedir}/build/phar/_tmp"/>-->
</target>

<target name="build" depends="clean,parallelTasks,phpunit"/>
Expand Down
20 changes: 20 additions & 0 deletions build/phpab/vendor.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
// @codingStandardsIgnoreFile
// @codeCoverageIgnoreStart
// this is an autogenerated file - do not edit
spl_autoload_register(
function($class) use ($vendor) {
static $classes = null;
if ($classes === null) {
$classes = array(
___CLASSLIST___
);
}
$cn = strtolower($class);
if (isset($classes[$cn])) {
require $vendor . '/' . $classes[$cn];
}
}
);
// @codeCoverageIgnoreEnd

17 changes: 17 additions & 0 deletions phpdox
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@

require __DIR__ . '/src/autoload.php';

$found = false;
foreach(array(__DIR__ . '/vendor', __DIR__ . '/../../vendor') as $vendor) {

This comment has been minimized.

Copy link
@dstockto

dstockto Dec 3, 2014

Contributor

@theseer With existing and fresh installs of phpdox, I am always getting the message that I need to set up project dependencies with composer. If you're looking for the vendor directory is think you need DIR . '/../../../vendor'. DIR is reporting as vendor/theseer/phpdox.

Thank you.

if (file_exists($vendor)) {
$found = true;
require __DIR__ . '/src/vendor.php';
}
}

if (!$found) {
fwrite(STDERR,
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'wget http://getcomposer.org/composer.phar' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
die(1);
}

(new TheSeer\phpDox\Factory())->getCLI()->run(
new TheSeer\phpDox\CLIOptions($_SERVER['argv'])
);
14 changes: 4 additions & 10 deletions src/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,17 @@ private function preBootstrap() {
xdebug_disable();
}

try {
date_default_timezone_set(date_default_timezone_get());
} catch (\ErrorException $e) {
date_default_timezone_set('UTC');
throw new CLIEnvironmentException(
"No default date.timezone configured in php.ini.",
CLIEnvironmentException::DateTimeZoneMissing,
$e
);
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

}

}

class CLIEnvironmentException extends \Exception {
const ExtensionMissing = 1;
const DateTimeZoneMissing = 2;
const VendorMissing = 2;
}

}
23 changes: 0 additions & 23 deletions src/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,6 @@ function($class) {
static $classes = null;
if ($classes === null) {
$classes = array(
'php_timer' => '/../vendor/phpunit/php-timer/PHP/Timer.php',
'theseer\\directoryscanner\\directoryscanner' => '/../vendor/theseer/directoryscanner/src/directoryscanner.php',
'theseer\\directoryscanner\\exception' => '/../vendor/theseer/directoryscanner/src/directoryscanner.php',
'theseer\\directoryscanner\\filesonlyfilteriterator' => '/../vendor/theseer/directoryscanner/src/filesonlyfilter.php',
'theseer\\directoryscanner\\includeexcludefilteriterator' => '/../vendor/theseer/directoryscanner/src/includeexcludefilter.php',
'theseer\\directoryscanner\\phpfilteriterator' => '/../vendor/theseer/directoryscanner/src/phpfilter.php',
'theseer\\fdom\\css\\dollarequalrule' => '/../vendor/theseer/fdomdocument/src/css/DollarEqualRule.php',
'theseer\\fdom\\css\\notrule' => '/../vendor/theseer/fdomdocument/src/css/NotRule.php',
'theseer\\fdom\\css\\nthchildrule' => '/../vendor/theseer/fdomdocument/src/css/NthChildRule.php',
'theseer\\fdom\\css\\regexrule' => '/../vendor/theseer/fdomdocument/src/css/RegexRule.php',
'theseer\\fdom\\css\\ruleinterface' => '/../vendor/theseer/fdomdocument/src/css/RuleInterface.php',
'theseer\\fdom\\css\\translator' => '/../vendor/theseer/fdomdocument/src/css/Translator.php',
'theseer\\fdom\\fdomdocument' => '/../vendor/theseer/fdomdocument/src/fDOMDocument.php',
'theseer\\fdom\\fdomdocumentfragment' => '/../vendor/theseer/fdomdocument/src/fDOMDocumentFragment.php',
'theseer\\fdom\\fdomelement' => '/../vendor/theseer/fdomdocument/src/fDOMElement.php',
'theseer\\fdom\\fdomexception' => '/../vendor/theseer/fdomdocument/src/fDOMException.php',
'theseer\\fdom\\fdomnode' => '/../vendor/theseer/fdomdocument/src/fDOMNode.php',
'theseer\\fdom\\fdomxpath' => '/../vendor/theseer/fdomdocument/src/fDOMXPath.php',
'theseer\\fdom\\xpathquery' => '/../vendor/theseer/fdomdocument/src/XPathQuery.php',
'theseer\\fdom\\xpathqueryexception' => '/../vendor/theseer/fdomdocument/src/XPathQueryException.php',
'theseer\\fxsl\\fxslcallback' => '/../vendor/theseer/fxsl/src/fxslcallback.php',
'theseer\\fxsl\\fxsltprocessor' => '/../vendor/theseer/fxsl/src/fxsltprocessor.php',
'theseer\\fxsl\\fxsltprocessorexception' => '/../vendor/theseer/fxsl/src/fxsltprocessor.php',
'theseer\\phpdox\\application' => '/Application.php',
'theseer\\phpdox\\applicationexception' => '/Application.php',
'theseer\\phpdox\\backendbootstrapapi' => '/bootstrap/BackendBootstrapApi.php',
Expand Down
Loading

0 comments on commit edfcd32

Please sign in to comment.