Skip to content

Commit 60fe799

Browse files
author
Aaron Holbrook
committed
Remove recursion checking
1 parent 0ea8cb6 commit 60fe799

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Automatically and recursively require_once all php files in a given directory.",
44
"type": "library",
55
"license": "UNLICENSE",
6-
"version": "2.0.4",
6+
"version": "2.0.5",
77
"authors": [
88
{
99
"name": "A7",

src/autoload.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,10 @@
66
* Recursively loads all php files in all subdirectories of the given path
77
*
88
* @param $directory
9-
* @param $recurse
109
*
1110
* @throws \Exception
1211
*/
13-
function autoload( $directory, $recurse = false ) {
14-
static $recurse_depth = 0;
15-
16-
if ( true === $recurse ) {
17-
$recurse_depth++;
18-
}
19-
20-
if ( $recurse_depth > 10 ) {
21-
trigger_error( 'Using autoload for more than 10 directories is not recommended', E_USER_WARNING );
22-
}
23-
24-
if ( $recurse_depth > 15 ) {
25-
throw new \Exception( 'Maximum recurse depth reached for autoload.' );
26-
}
12+
function autoload( $directory ) {
2713

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

66-
autoload( $real_path, true );
52+
autoload( $real_path );
6753
}
6854

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

0 commit comments

Comments
 (0)