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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kjell dot eikland at online dot no
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 15:01:29 2024 UTC