Category
stdlib · php-src-strict
Problem
pathinfo() second argument cannot accept PATHINFO_* named constants—the VM throws LogicException: pathinfo() flags must be an integer in this compiler build instead of returning the selected component.
| Call |
Zend |
VM today |
pathinfo('/foo/bar/baz.txt', PATHINFO_FILENAME) |
'baz' |
LogicException |
pathinfo('/foo/bar/baz.txt', PATHINFO_EXTENSION) |
'txt' |
LogicException |
pathinfo('/foo/bar/baz.txt', PATHINFO_BASENAME) |
'baz.txt' |
LogicException |
Integer flag values work when written literally; named constants are not lowered to their integer values at the builtin boundary.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_pathinfo_pathinfo_filename.php'
php bin/vm.php test/repro/maintainer_gap_pathinfo_pathinfo_filename.php
Implementation hints (PHP-in-PHP)
Done when
Related
Category
stdlib· php-src-strictProblem
pathinfo()second argument cannot acceptPATHINFO_*named constants—the VM throwsLogicException: pathinfo() flags must be an integer in this compiler buildinstead of returning the selected component.pathinfo('/foo/bar/baz.txt', PATHINFO_FILENAME)'baz'LogicExceptionpathinfo('/foo/bar/baz.txt', PATHINFO_EXTENSION)'txt'LogicExceptionpathinfo('/foo/bar/baz.txt', PATHINFO_BASENAME)'baz.txt'LogicExceptionInteger flag values work when written literally; named constants are not lowered to their integer values at the builtin boundary.
php-src reference
ext/standard/basic_functions.c—zif_pathinfo,PATHINFO_*bitmask flagsRepro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_pathinfo_pathinfo_filename.php' php bin/vm.php test/repro/maintainer_gap_pathinfo_pathinfo_filename.phpImplementation hints (PHP-in-PHP)
ext/standard/pathinfo.php— resolvePATHINFO_DIRNAME|BASENAME|EXTENSION|FILENAME|ALLconstants like Zend[]literal — TypeError null for $array not empty string (ext/standard/string.c) #9563)PATHINFO_ALLassociative shape—orthogonal; this issue is named-constant binding for single-flag callsDone when
LogicExceptionforPATHINFO_FILENAMEet al.Related