Category
stdlib · php-src-strict · profile gate / phantom API
Problem
clamp() landed in php-src 8.6 (RFC clamp_v2, PR #19434). This repo already implements it (ext/standard/clamp.php, VmMath::clamp, JitClamp) but gates are wrong vs Zend:
- Comments /
supportsClamp() treat it as PHP 8.3+
- Under
PHP_COMPILER_PROFILE=8.4: function_exists('clamp') is false, yet clamp(5,1,3) returns 3 (callable via supportsClamp while advertisesClamp hides it)
- Under
PROFILE=8.3: function_exists is true and call works — Zend 8.3 has no clamp
- Under
PROFILE=8.6: still not advertised/aligned with Zend 8.6
Verified 2026-07-19 on master (VERSION=8.4.0-dev):
| Profile |
function_exists('clamp') |
clamp(5,1,3) |
Zend |
8.3 |
true |
3 |
undefined function |
8.4 |
false |
3 (still callable!) |
undefined function |
8.6 |
false |
(callable if supports) |
3 + exists true |
php-src reference
PHP implementation target
- Retarget
CompilerVersion::supportsClamp() / advertisesClamp() to language profile ≥ 8.6 (both register and function_exists)
- Keep PHP implementation; fix docs that say “PHP 8.3”
- On ≤8.5 profiles: undefined-function
Error like Zend (no silent call path)
- No new C
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
cat > /tmp/clamp_gate.php << "PHP"
<?php
echo "exists=", function_exists("clamp") ? "1" : "0", "\n";
try {
echo "call=", clamp(5, 1, 3), "\n";
} catch (Throwable $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
}
PHP
for p in 8.3 8.4 8.6; do
echo "=== PROFILE=$p ==="
PHP_COMPILER_PROFILE=$p php bin/vm.php /tmp/clamp_gate.php
done'
Done when
Related
Category
stdlib· php-src-strict · profile gate / phantom APIProblem
clamp()landed in php-src 8.6 (RFC clamp_v2, PR #19434). This repo already implements it (ext/standard/clamp.php,VmMath::clamp,JitClamp) but gates are wrong vs Zend:supportsClamp()treat it as PHP 8.3+PHP_COMPILER_PROFILE=8.4:function_exists('clamp')is false, yetclamp(5,1,3)returns3(callable viasupportsClampwhileadvertisesClamphides it)PROFILE=8.3:function_existsis true and call works — Zend 8.3 has noclampPROFILE=8.6: still not advertised/aligned with Zend 8.6Verified 2026-07-19 on master (
VERSION=8.4.0-dev):function_exists('clamp')clamp(5,1,3)8.3true38.4false3(still callable!)8.6false3+ exists truephp-src reference
ext/standard/math.c—PHP_FUNCTION(clamp)/php_math_clampext/standard/basic_functions.stub.php—clamp(master / 8.6)PHP implementation target
CompilerVersion::supportsClamp()/advertisesClamp()to language profile ≥ 8.6 (both register andfunction_exists)Errorlike Zend (no silent call path)Repro
Done when
PROFILE≤8.5:function_existsfalse and call throws undefined-functionError(php-src-strict)PROFILE=8.6(or ≥8.6):function_existstrue;clamp(5,1,3)===3; ValueError on min>max / NAN bounds like Zend.phptfor both phantom and forward profiles; php-src-strictRelated