Skip to content

Commit 8aa971b

Browse files
committed
PHP 5.2.x compatibility issue
To keep minimum requirements at PHP 5.2.1 or higher, anonymous functions shouldn't be used in autoload.php. Anonymous functions are not available prior to PHP 5.3.
1 parent 09701cc commit 8aa971b

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/Google/autoload.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18-
spl_autoload_register(
19-
function ($className) {
20-
$classPath = explode('_', $className);
21-
if ($classPath[0] != 'Google') {
22-
return;
23-
}
24-
// Drop 'Google', and maximum class file path depth in this project is 3.
25-
$classPath = array_slice($classPath, 1, 2);
26-
27-
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
28-
if (file_exists($filePath)) {
29-
require_once($filePath);
30-
}
31-
}
32-
);
18+
function google_api_php_client_autoload($className)
19+
{
20+
$classPath = explode('_', $className);
21+
if ($classPath[0] != 'Google') {
22+
return;
23+
}
24+
// Drop 'Google', and maximum class file path depth in this project is 3.
25+
$classPath = array_slice($classPath, 1, 2);
26+
$filePath = dirname(__FILE__) . '/' . implode('/', $classPath) . '.php';
27+
if (file_exists($filePath)) {
28+
require_once($filePath);
29+
}
30+
}
31+
spl_autoload_register('google_api_php_client_autoload');

0 commit comments

Comments
 (0)