Doc #80698 [NEW]: Add a note for key types may not be honored.

From: Date: Tue, 02 Feb 2021 19:13:49 +0000
Subject: Doc #80698 [NEW]: Add a note for key types may not be honored.
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18485@lists.php.net to get a copy of this message
From:             ksteinmetz at officesupply dot com
Operating system: Ubuntu 18.04.5 LTS
PHP version:      7.4.14
Package:          Arrays related
Bug Type:         Documentation Problem
Bug description:Add a note for key types may not be honored. 

Description:
------------
---
From manual page: https://php.net/function.array-rand
---

As we are moving toward strong predictable typing, it would be nice to
at least mention in the documentation that the quoted string integers
would be implicitly converted to integers. Of course the fixes in our
code are trivial. Type cast the results as needed or insure that the key
really looks like a string to php. 

Test script:
---------------
is_string(array_rand(["1" => [2], "3" => [4], "5" => [6]]));
!is_string(array_rand([1 => [2], 3 => [4], 5 => [6]]));

Expected result:
----------------
true
true

Actual result:
--------------
false
true

-- 
Edit bug report at https://bugs.php.net/bug.php?id=80698&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80698&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80698&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80698&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80698&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80698&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80698&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80698&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80698&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80698&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80698&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80698&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80698&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80698&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80698&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80698&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80698&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80698&r=mysqlcfg


Thread (2 messages)

« previous php.doc.bugs (#18485) next »