|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-06-29 17:19 UTC] cmb@php.net
 
-Status:      Open
+Status:      Not a bug
-Assigned To:
+Assigned To: cmb
  [2016-06-29 17:19 UTC] cmb@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 20:00:01 2025 UTC | 
Description: ------------ when declared strict_types=1, the type check for a callable's parameter is being bypassed. Test script: --------------- <?php declare(strict_types=1); class IntArray { public function __construct(array $initial = []) { array_walk($initial, function(int $value){}); // bypass strict_types foreach ($initial as $data) { $this->typeCheck($data); } // type checked as expected } private function typeCheck(int $value) { } } $array = new IntArray(["12"]); var_dump($array); Expected result: ---------------- Fatal error: Uncaught TypeError: Argument 1 passed to {closure} must be of the type integer, string given, called in /var/tmp/x.php on line 8 and defined in /var/tmp/x.php:12 Stack trace: #0 /var/tmp/x.php(8): {closure('12')} #1 /var/tmp/x.php(17): IntArray->__construct(Array) #2 {main} thrown in /var/tmp/x.php on line 12 Actual result: -------------- Fatal error: Uncaught TypeError: Argument 1 passed to IntArray::typeCheck() must be of the type integer, string given, called in /var/tmp/x.php on line 9 and defined in /var/tmp/x.php:12 Stack trace: #0 /var/tmp/x.php(9): IntArray->typeCheck('12') #1 /var/tmp/x.php(17): IntArray->__construct(Array) #2 {main} thrown in /var/tmp/x.php on line 12