Doc->Bug #78964 [Opn->Fbk]: Third parameter of array_slice() is int type but with NULL default

From: Date: Sun, 15 Dec 2019 21:45:36 +0000
Subject: Doc->Bug #78964 [Opn->Fbk]: Third parameter of array_slice() is int type but with NULL default
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224317@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78964&edit=1 ID: 78964 Updated by: requinix@php.net Reported by: kjell dot eikland at online dot no Summary: Third parameter of array_slice() is int type but with NULL default -Status: Open +Status: Feedback -Type: Documentation Problem +Type: Bug -Package: *General Issues +Package: Arrays related Operating System: Win PHP Version: 7.4.0 Block user comment: N Private report: N New Comment: Works for me. https://3v4l.org/GJCdH Previous Comments: ------------------------------------------------------------------------ [2019-12-15 18:30:14] kjell dot eikland at online dot no 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 this bug report at https://bugs.php.net/bug.php?id=78964&edit=1

« previous php.bugs (#224317) next »