Permalink
Browse files

Some autoloader fixes.

  • Loading branch information...
1 parent 0438d72 commit d6aa8c29fd93a67b34ddac05de87befcbecf8134 @henriquemoody henriquemoody committed Feb 16, 2012
Showing with 15 additions and 8 deletions.
  1. +15 −8 bin/respect.php
View
@@ -1,24 +1,31 @@
<?php
-chdir(__DIR__.'/../library');
+chdir(__DIR__ . '/../library');
-if (!@include __DIR__.'/../vendor/.composer/autoload.php') {
- $pear_path = trim(`pear config-get php_dir`);
- set_include_path('../library'
- . PATH_SEPARATOR . $pear_path
- . PATH_SEPARATOR . get_include_path());
+if (!@include __DIR__ . '/../vendor/.composer/autoload.php') {
+
+ /* Include path */
+ set_include_path(implode(PATH_SEPARATOR, array(
+ realpath(__DIR__ . '/../library'),
+ trim(`pear config-get php_dir`),
+ get_include_path(),
+ )));
+
+ /* Autoloader */
spl_autoload_register(
function($className) {
$fileParts = explode('\\', ltrim($className, '\\'));
- if (false !== strpos(end($fileParts), '_'))
+ if (false !== strpos(end($fileParts), '_')) {
array_splice($fileParts, -1, 1, explode('_', current($fileParts)));
+ }
$file = implode(DIRECTORY_SEPARATOR, $fileParts) . '.php';
foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
- if (file_exists($path = $path . DIRECTORY_SEPARATOR . $file))
+ if (file_exists($path = $path . DIRECTORY_SEPARATOR . $file)) {
return require $path;
+ }
}
}
);

0 comments on commit d6aa8c2

Please sign in to comment.