Bug #74750 [Opn]: strict_types not used for builtin callbacks (eg array_map)
| From: | cmb@php.net | Date: | Tue, 13 Jun 2017 11:53:47 +0000 |
| Subject: | Bug #74750 [Opn]: strict_types not used for builtin callbacks (eg array_map) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74750&edit=1
ID: 74750
Updated by: cmb@php.net
Reported by: fredemmott@php.net
Summary: strict_types not used for builtin callbacks (eg
array_map)
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Debian Jessie
PHP Version: 7.1.6
Block user comment: N
Private report: N
New Comment:
Isn't that to be expected? print_str() is called from array_map()
and the latter is not declared in a declare(strict_types=1) file.
Previous Comments:
------------------------------------------------------------------------
[2017-06-12 16:32:09] fredemmott@php.net
Description:
------------
In a strict file:
- declare a function with typed parameters
- call a builtin in a way that types don't match (eg if your function takes a string,
array_map over ints)
Test script:
---------------
<?php
declare(strict_types=1);
function print_str(string $foo) { var_dump($foo); }
$input = [1, 2, 3];
array_map('print_str', $input);
Expected result:
----------------
Type error
Actual result:
--------------
Coercion
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74750&edit=1