php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78964 Third parameter of array_slice() is int type but with NULL default
Submitted: 2019-12-15 18:30 UTC Modified: 2019-12-29 04:22 UTC
From: kjell dot eikland at online dot no Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 7.4.0 OS: Win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 13 = ?
Subscribe to this entry?

 
 [2019-12-15 18:30 UTC] 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	... 	

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-15 21:45 UTC] requinix@php.net
-Status: Open +Status: Feedback -Type: Documentation Problem +Type: Bug -Package: *General Issues +Package: Arrays related
 [2019-12-15 21:45 UTC] requinix@php.net
Works for me. https://3v4l.org/GJCdH
 [2019-12-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 00:01:30 2024 UTC