From 1e056bb0401e5a62c743da8c14475e255ff9e6b2 Mon Sep 17 00:00:00 2001
From: Travis Paul
Date: Thu, 21 Aug 2014 13:01:54 -0400
Subject: [PATCH] Made autoloader work within Phar files
realpath() has issues when executing inside of a Phar.
I also simplified the autoloader code.
---
src/Phpass/Loader.php | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/Phpass/Loader.php b/src/Phpass/Loader.php
index aaa07be..de866fb 100644
--- a/src/Phpass/Loader.php
+++ b/src/Phpass/Loader.php
@@ -46,16 +46,11 @@ class Loader
*/
public static function load($class)
{
- if (substr($class, 0, 6) !== 'Phpass') {
- return;
- }
+ if (stripos($class, 'Phpass') === 0) {
+ $file = str_replace('\\', '/', $class);
- $libraryRoot = realpath(__DIR__ . '/../');
- $file = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
- $file = realpath($libraryRoot . DIRECTORY_SEPARATOR . $file);
- if (substr($file, 0, strlen($libraryRoot)) == $libraryRoot) {
- if (is_readable($file)) {
- include $file;
+ if (file_exists(dirname(__FILE__) . '/../' . $file . '.php')) {
+ require_once(dirname(__FILE__) . '/../' . $file . '.php');
}
}
}