Doc #78964 [NEW]: Third parameter of array_slice() is int type but with NULL default

From: Date: Sun, 15 Dec 2019 18:30:14 +0000
Subject: Doc #78964 [NEW]: Third parameter of array_slice() is int type but with NULL default
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17129@lists.php.net to get a copy of this message
From:             kjell dot eikland at online dot no
Operating system: Win
PHP version:      7.4.0
Package:          *General Issues
Bug Type:         Documentation Problem
Bug description:Third parameter of array_slice() is int type but with NULL default

Description:
------------
I need to have keys returned in an array_slice() operation where I
remove some n first elements and keep the rest.  That means that the
third parameter must be NULL and the fourth is TRUE. 

The third parameter is defined to be of type int, with a default of
NULL.  I get non-fatal error messages when specifying a NULL parameter
value to override the default for the fourth parameter. 

Test script:
---------------
$arr = ['a' => 45, 'b' => 30];
$exp = array_slice($exp, 1, null, true);

Expected result:
----------------
$exp = ['b' => 30] and no debug error message returned.

Actual result:
--------------
$exp = ['b' => 30] and error message returned.
Severity	Code	Description	Project	File	Line	Suppression State
Warning	PHP0406	Argument '3' passed to array_slice() is expected to be
of type int, null given	... 	

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


Thread (1 message)

  • kjell dot eikland at online dot no
« previous php.doc.bugs (#17129) next »