Skip to content

Commit

Permalink
Ensure GLOB_BRACE constant is defined for Alpine and Solaris OS
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusValeraDev committed May 2, 2022
1 parent 64d659b commit 2a44c6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 0.17.2
#### 2022-05-02

- Ensure GLOB_BRACE constant is defined for Alpine and Solaris OS.

### 0.17.1
#### 2022-05-02

Expand Down
16 changes: 16 additions & 0 deletions src/Framework/Config/PathFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Gacela\Framework\Config;

use function define;
use function defined;
use function is_array;

final class PathFinder implements PathFinderInterface
Expand All @@ -13,8 +15,22 @@ final class PathFinder implements PathFinderInterface
*/
public function matchingPattern(string $pattern): array
{
$this->ensureGlobBraceIsDefined();

$glob = glob($pattern, GLOB_BRACE);

return is_array($glob) ? $glob : [];
}

/**
* Note: The GLOB_BRACE flag is not available on some non GNU systems, like Solaris or Alpine Linux.
*
* @see https://www.php.net/manual/en/function.glob.php
*/
private function ensureGlobBraceIsDefined(): void
{
if (!defined('GLOB_BRACE')) {
define('GLOB_BRACE', 0x10);
}
}
}

0 comments on commit 2a44c6a

Please sign in to comment.