From 2a44c6aa7c5b7af93bd0c2a854eb895bf3e5b6a8 Mon Sep 17 00:00:00 2001 From: JesusValera Date: Mon, 2 May 2022 23:49:28 +0200 Subject: [PATCH] Ensure GLOB_BRACE constant is defined for Alpine and Solaris OS --- CHANGELOG.md | 5 +++++ src/Framework/Config/PathFinder.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e438a59..2aff9adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Framework/Config/PathFinder.php b/src/Framework/Config/PathFinder.php index d2d88ca3..f58dff06 100644 --- a/src/Framework/Config/PathFinder.php +++ b/src/Framework/Config/PathFinder.php @@ -4,6 +4,8 @@ namespace Gacela\Framework\Config; +use function define; +use function defined; use function is_array; final class PathFinder implements PathFinderInterface @@ -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); + } + } }