Skip to content

Commit

Permalink
Merge pull request #2735 from koendc/fix_glob_brace
Browse files Browse the repository at this point in the history
Do not rely on GLOB_BRACE as it is not available on non-glibc based systems
  • Loading branch information
jbrooksuk committed Sep 29, 2017
2 parents b5f6c23 + e69169e commit 818adcc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/Foundation/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ public function map(Router $router)
$router->group(['namespace' => $this->namespace, 'as' => 'core::'], function (Router $router) {
$path = app_path('Http/Routes');

// GLOB_BRACE is defined as 0, check the source!
// https://github.com/php/php-src/blob/31e4afe3c3654f9c5ab2eafa3a02c62d41c58b47/ext/standard/dir.c#L154-L158
$globBrace = defined('GLOB_BRACE') ? GLOB_BRACE : 0;
$globFlag = $globBrace;
$AllFileIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
$PhpFileIterator = new \RegexIterator($AllFileIterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);

foreach (glob("{$path}/*{,/*}.php", $globFlag) as $file) {
foreach ($PhpFileIterator as $file => $object) {
$class = substr($file, strlen($path));
$class = str_replace('/', '\\', $class);
$class = substr($class, 0, -4);
Expand Down

0 comments on commit 818adcc

Please sign in to comment.