Doc #74942 [NEW]: Slight Ambiguity in Definition of Return Value

From: Date: Mon, 17 Jul 2017 18:28:30 +0000
Subject: Doc #74942 [NEW]: Slight Ambiguity in Definition of Return Value
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14845@lists.php.net to get a copy of this message
From: derek dot price at dxc dot com Operating system: All PHP version: 7.1.7 Package: Documentation problem Bug Type: Documentation Problem Bug description:Slight Ambiguity in Definition of Return Value Description: ------------ --- From manual page: http://www.php.net/function.array-diff-key --- The return value is specified as "Returns an array containing all the entries from array1 whose keys are not present in any of the other arrays." On my first read, I interpreted this as how the function actually works, as revealed by testing. However, I got in an argument with a developer who read this to mean something different, almost the opposite, a meaning I could see in the original text once pointed out. Basically, the other developer had interpreted this as, "Returns an array containing all the entries from array1 whose keys is not present in AT LEAST ONE of the other arrays". Whereas, the actual behavior can more precisely be stated as, "Returns an array containing all the entries from array1 whose keys are MISSING FROM ALL of the other arrays." A three argument example like the one I entered as the test script & expected result, below, would probably help too. Test script: --------------- <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'yellow' => 7, 'cyan' => 8); $array3 = array('blue' => 6, 'yellow' => 7, 'mauve' => 8); var_dump(array_diff_key($array1, $array2, $array3)); Expected result: ---------------- array(2) { ["red"]=> int(2) ["purple"]=> int(4) } -- Edit bug report at https://bugs.php.net/bug.php?id=74942&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74942&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74942&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74942&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74942&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74942&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74942&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74942&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74942&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74942&r=support Expected behavior: https://bugs.php.net/fix.php?id=74942&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74942&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74942&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74942&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74942&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74942&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74942&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74942&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74942&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74942&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74942&r=mysqlcfg

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