Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"PhpCas\\": "test/CAS/"
}
},
"scripts": {
"test": "phpunit"
},
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
Expand Down
17 changes: 11 additions & 6 deletions source/CAS/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ function CAS_autoload($class)
// Static to hold the Include Path to CAS
static $include_path;
// Check only for CAS classes
if (substr($class, 0, 4) !== 'CAS_') {
if (substr($class, 0, 4) !== 'CAS_' && substr($class, 0, 7) !== 'PhpCas\\') {
return false;
}

// Setup the include path if it's not already set from a previous call
if (empty($include_path)) {
$include_path = array(dirname(__DIR__));
}

// Declare local variable to store the expected full path to the file

foreach ($include_path as $path) {
$file_path = $path . '/' . str_replace('_', '/', $class) . '.php';
$class_path = str_replace('_', DIRECTORY_SEPARATOR, $class);
// PhpCas namespace mapping
if (substr($class_path, 0, 7) === 'PhpCas\\') {
$class_path = 'CAS' . DIRECTORY_SEPARATOR . substr($class_path, 7);
}

$file_path = $path . DIRECTORY_SEPARATOR . $class_path . '.php';
$fp = @fopen($file_path, 'r', true);
if ($fp) {
fclose($fp);
Expand All @@ -54,6 +60,7 @@ function CAS_autoload($class)
return true;
}
}

$e = new Exception(
'Class ' . $class . ' could not be loaded from ' .
$file_path . ', file does not exist (Path="'
Expand Down Expand Up @@ -85,6 +92,4 @@ function CAS_autoload($class)
// it to the autoload stack
spl_autoload_register('__autoload');
}
}

?>
}