php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77931 Warning for array_map mentions wrong type
Submitted: 2019-04-23 09:29 UTC Modified: 2019-04-23 09:35 UTC
From: domen at jollydeck dot com Assigned: nikic (profile)
Status: Closed Package: Arrays related
PHP Version: 7.3.4 OS: Windows
Private report: No CVE-ID: None
 [2019-04-23 09:29 UTC] domen at jollydeck dot com
Description:
------------
Function array_map always emits warning "Warning: array_map(): Expected parameter 3 to be an array, array given" if third parameter is not an array.

It looks like X in "X given" is type of the second parameter instead of the offending parameter.

Test cases:
array_map('trim', array(), 1); – "array given"
array_map('trim', array(), true); – "array given"
array_map('trim', array(), null); – "array given"

array_map('trim', 1, true); – "int given"
array_map('trim', true, true); – "bool given"


Test script:
---------------
<?php
array_map('trim', array(), true);
?>

Expected result:
----------------
Warning: array_map(): Expected parameter 3 to be an array, bool given

Actual result:
--------------
Warning: array_map(): Expected parameter 3 to be an array, array given

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-23 09:35 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: nikic
 [2019-04-23 09:41 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cedee4408b21baed6376a2702d7d8d01e8d4a111
Log: Fixed bug #77931
 [2019-04-23 09:41 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC