Skip to content

Commit

Permalink
Remove recursion checking
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook committed Mar 21, 2017
1 parent 0ea8cb6 commit 60fe799
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Automatically and recursively require_once all php files in a given directory.",
"type": "library",
"license": "UNLICENSE",
"version": "2.0.4",
"version": "2.0.5",
"authors": [
{
"name": "A7",
Expand Down
18 changes: 2 additions & 16 deletions src/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,10 @@
* Recursively loads all php files in all subdirectories of the given path
*
* @param $directory
* @param $recurse
*
* @throws \Exception
*/
function autoload( $directory, $recurse = false ) {
static $recurse_depth = 0;

if ( true === $recurse ) {
$recurse_depth++;
}

if ( $recurse_depth > 10 ) {
trigger_error( 'Using autoload for more than 10 directories is not recommended', E_USER_WARNING );
}

if ( $recurse_depth > 15 ) {
throw new \Exception( 'Maximum recurse depth reached for autoload.' );
}
function autoload( $directory ) {

// Get a listing of the current directory
$scanned_dir = scandir( $directory );
Expand Down Expand Up @@ -63,7 +49,7 @@ function autoload( $directory, $recurse = false ) {
// If it's a directory then recursively load it
if ( 'dir' === $filetype ) {

autoload( $real_path, true );
autoload( $real_path );
}

// If it's a file, let's try to load it
Expand Down

0 comments on commit 60fe799

Please sign in to comment.