1.2.497. GLOB_BRACE Usage¶
GLOB_BRACE is not always available on every underlying operating system. This is the case on Solaris OS, and on Alpine OS, used for Docker. It is possible to check the support for GLOB_BRACE by checking the presence of the constant.
<?php
// glob uses GLOB_BRACE
$abcFiles = glob($path.'/{a,b,c}*', GLOB_BRACE);
// avoiding usage of GLOB_BRACE
$abcFiles = array_merge(glob($path.'/a*'),
glob($path.'/b*'),
glob($path.'/c*'),
);
?>
See also Alpine Linux, GLOB_BRACE breaks Sulu on Alpine Linux and [performance] Symfony Kernel::boot() in dev mode on Alpine #35009.
1.2.497.1. Connex PHP features¶
1.2.497.1.1. Suggestions¶
Create as many glob() calls at there are alternative in the braces
Use another tool to search the system on names
Do not use glob brace
1.2.497.1.2. Specs¶
Short name |
Portability/GlobBraceUsage |
Rulesets |
|
Exakat since |
2.1.6 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |