RobLoach / component-installer

Install Web Components through Composer
https://asset-packagist.org/
Other
280 stars 35 forks source link

Invalid foreach argument #60

Open skrobek opened 10 years ago

skrobek commented 10 years ago

In Filesystem.php in line: glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) returns on my local system false, beacuse glob() returns error without information.

I have no clue why it happens ( short discussion: http://stackoverflow.com/questions/13809465/why-does-glob-returns-false-when-the-directory-is-empty )

But if first i will check if glob() returns array, then everything works perfect. Maybe before iterating over glob() result, first we should check what it returns ?

Example

if (strpos($pattern, '**') !== FALSE) {
    $path = glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT);
    if (is_array($path)) {
        foreach ($path as $dir) {
                $files = array_merge($files, $this->recursiveGlob($dir.'/'.basename($pattern), $flags));
            }
        }
}
RobLoach commented 10 years ago

Is it the acting on glob() that's affecting it?

skrobek commented 10 years ago

Sorry i don't get you question ..