<?php
enum E: int { case A = 1; }
foreach (['sin','cos','deg2rad','fmod'] as $fn) {
try {
$fn === 'fmod' ? $fn(E::A, 2.0) : $fn(E::A);
echo "$fn: ok\n";
} catch (TypeError $e) {
echo "$fn: TypeError\n";
} catch (Throwable $e) {
echo "$fn: ", get_class($e), "\n";
}
}
Category
stdlib· php-src-strictProblem
Phase 1 umbrella #5613 covers
abs/ceil/floor/round/sqrt, but trigonometric, hyperbolic, and two-argument math builtins still accept enum case operands (or fail with non-Zend messages) instead ofTypeErrorlike Zend (Z_PARAM_DOUBLE/Z_PARAM_NUMBER).Verified probe (2026-06-04,
php-compiler:22.04-dev):sin/cos/tanok)asin/acos/atansinh/cosh/tanhexpm1/log1pdeg2rad/rad2degatan2/hypot/fmod… requires exactly two arguments(LogicException)php-src reference
ext/standard/math.c—ZEND_PARSE_PARAMETERSon trig/hyperbolic/two-arg functionsZend/zend_enum.cRepro
test/repro-maintainer/parity_trig_math_enum_type_error.php:Scope (PHP-in-PHP)
ext/standard/sin.php,cos.php,tan.php,asin.php,acos.php,atan.php,atan2.php,sinh.php,cosh.php,tanh.php,expm1.php,log1p.php,hypot.php,fmod.php,deg2rad.php,rad2deg.php— rejectVariable::TYPE_ENUM_CASEbefore numeric coercionext/standard/Jit*.php/lib/JIT/Builtin/lowererstest/compliance/cases/stdlib/trig_math_enum_case_type_error.phptDone when
TypeErrorwith Zend-aligned messages on enum case operands (VM)./script/ci-fast.sh --filter trig_math_enum_casegreenRelated
is_finitefamily) · Stdlib: floor()/ceil()/round()/fmod() — numeric-string scalar coercion (ext/standard/math.c parity) #4350 / Stdlib: pow()/sqrt() — numeric-string scalar coercion (ext/standard/math.c parity) #4359 (numeric-string coercion) · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492