Bug #74750 [Com]: strict_types not used for builtin callbacks (eg array_map)
| From: | spam2 at rhsoft dot net | Date: | Tue, 13 Jun 2017 12:36:53 +0000 |
| Subject: | Bug #74750 [Com]: strict_types not used for builtin callbacks (eg array_map) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-209519@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
Comment by: spam2 at rhsoft dot 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
shouldn't it be logical that when *all* of your files start with declare(strict_types=1)
everything has to use strict typing?
Previous Comments:
------------------------------------------------------------------------
[2017-06-13 11:53:46] cmb@php.net
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.
------------------------------------------------------------------------
[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