Category
stdlib | php-src-strict
Problem
#5732 landed but regressed: glob() with an enum case $pattern returns an empty array instead of throwing TypeError. Zend rejects non-string patterns before filesystem lookup.
php-src reference
Repro
test/repro-maintainer/parity_glob_enum_pattern.php:
<?php
declare(strict_types=1);
enum E { case A; }
enum Es: string { case P = '*.txt'; }
foreach ([E::A, Es::P] as $pattern) {
try {
var_export(glob($pattern));
echo "\nuncaught\n";
} catch (Throwable $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
}
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_glob_enum_pattern.php
php bin/vm.php test/repro-maintainer/parity_glob_enum_pattern.php'
| Runtime |
Result |
| Zend |
TypeError: glob(): Argument #1 ($pattern) must be of type string, E given (and same for Es) |
| VM today |
array () + uncaught (no exception) |
Scope (this repo)
| Path |
Work |
ext/standard/glob.php |
Reject enum operands via VmString::requireStringBuiltinArg (not coerce / not empty-array fallback) |
lib/JIT/Builtin/*Glob* |
Mirror strict string check when JIT lowering exists |
| Tests |
test/compliance/cases/stdlib/glob_enum_pattern.phpt |
PHP-in-PHP: fix operand guard in ext/standard; do not add C branches in runtime/.
Done when
Related
#5732 (closed) · #7405 (php-in-php glob vec) · #1492
Category
stdlib| php-src-strictProblem
#5732 landed but regressed:
glob()with an enum case$patternreturns an empty array instead of throwingTypeError. Zend rejects non-string patterns before filesystem lookup.php-src reference
ext/standard/dir.c—php_glob()/Z_PARAM_STRon$patternext/standard/basic_functions.stub.php—function glob(string $pattern, ...)Repro
test/repro-maintainer/parity_glob_enum_pattern.php:TypeError: glob(): Argument #1 ($pattern) must be of type string, E given(and same forEs)array ()+uncaught(no exception)Scope (this repo)
ext/standard/glob.phpVmString::requireStringBuiltinArg(not coerce / not empty-array fallback)lib/JIT/Builtin/*Glob*test/compliance/cases/stdlib/glob_enum_pattern.phptPHP-in-PHP: fix operand guard in
ext/standard; do not add C branches inruntime/.Done when
TypeErrorfor both pure and backed enum cases (nouncaught)./script/ci-fast.sh --filter glob_enumgreenRelated
#5732 (closed) · #7405 (php-in-php glob vec) · #1492