Bug #75345 [NEW]: Strict type declarations not enforced for Reflection API invocation

From: Date: Mon, 09 Oct 2017 14:42:06 +0000
Subject: Bug #75345 [NEW]: Strict type declarations not enforced for Reflection API invocation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211588@lists.php.net to get a copy of this message
From: sebastian Operating system: Irrelevant PHP version: Irrelevant Package: Reflection related Bug Type: Bug Bug description:Strict type declarations not enforced for Reflection API invocation Description: ------------ Strict type declarations are not enforced when a function or method is invoked via the Reflection API. The test script generates the same result with PHP 7.0.25-dev (f48abfa9022c026c2447b14bc03c978d2b831b27), 7.1.11-dev (d8881f4eb4ec138db00d5fcf0b27a64f8986cd85), PHP 7.2.0-dev (611d117b24b58544ef69390cfe44166ba606b0ab), and PHP 7.3.0-dev (39ded1d5f85ca3358cc8a52bb37e72a5eb5ce0db). Test script: --------------- <?php declare(strict_types=1); function f(bool $a) { var_dump($a); } $f = new ReflectionFunction('f'); $f->invokeArgs([1]); // or $f->invoke(1); Expected result: ---------------- TypeError exception because int(1) does not match bool. Actual result: -------------- bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=75345&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75345&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75345&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75345&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75345&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75345&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75345&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75345&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75345&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75345&r=support Expected behavior: https://bugs.php.net/fix.php?id=75345&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75345&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75345&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75345&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75345&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75345&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75345&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75345&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75345&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75345&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75345&r=mysqlcfg

« previous php.bugs (#211588) next »