|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75345 Strict type declarations not enforced for Reflection API invocation
Submitted: 2017-10-09 14:42 UTC Modified: 2018-07-02 18:22 UTC
Avg. Score:4.2 ± 0.9
Reproduced:4 of 6 (66.7%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: Assigned:
Status: Wont fix Package: Reflection related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
36 - 36 = ?
Subscribe to this entry?

 [2017-10-09 14:42 UTC]
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:

function f(bool $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:


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-02 18:22 UTC]
-Status: Open +Status: Wont fix
 [2018-07-02 18:22 UTC]
This has been discussed on the internals list in, and the decision was not change this behavior.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 17:01:28 2024 UTC