glob() fails due GLOB_BRACE const usage, which is not available under alpine linux due non-standard libc (musl) usage
Closed this issue · 4 comments
Which version(s) is affected: 8.0.0.
Description
Warning:
Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE'
(this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38
Fatal error: Uncaught TypeError:glob() expects parameter 2 to be int, string given
in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38
Full log
Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38
Fatal error: Uncaught TypeError: glob() expects parameter 2 to be int, string given in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38
Stack trace:
#0 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(38): glob('./*{.yml,.yaml,...', 'GLOB_BRACE')
#1 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(20): YamlStandards\Command\Service\FilesPathService::globRecursive('./*{.yml,.yaml,...')
#2 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(43): YamlStandards\Command\Service\FilesPathService::getPathToFiles(Array)
#3 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(31): YamlStandards\Model\Config\YamlStandardConfigLoader->createConfigData(Array)
#4 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/YamlCommand.php(51): YamlStandards\Model\Config\YamlStandardConfigLoader->loadFromYaml('./yaml-standard...')
#5 /srv/sylius/vendor/symfo in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38
How to reproduce
call yaml-standard bin from docker with alpine linux
Possible Solution
Handle possiblity of GLOB_BRACE
missing.
https://www.php.net/manual/en/function.glob.php
Additional information
zendframework/zend-stdlib#58
zend-stdlib has fallback glob for this exact issue https://github.com/zendframework/zend-stdlib/blob/6d965efcce81ee60e2b425792f1cd3f27aed82d9/src/Glob.php#L39-L46
Hello, thanks for report. I will work on it.
Just patched my local version with it and seems to work correctly.
vendor/bin/yaml-standards
is being called without errors now- Number of found files matches number of files in directory with
find path/to/dir -mindepth 1 -type f -name "*.yml" -printf x | wc -c
for yml/yaml file extensions.
Thank you for super fast fix :)
EDIT: P.S. Yes, it's okay for me and I've no use for GLOB_BRACE const directly.
You are welcome 😊 I released new version where is this issue fixed, so you can change version in composer.json
to don't have to change your localhost version
Thank you for your report