php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75958 bool return on some SPL methods, not void
Submitted: 2018-02-14 09:38 UTC Modified: 2018-09-21 05:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: oeildanslabouche at gmail dot com Assigned: carusogabriel (profile)
Status: Closed Package: SPL related
PHP Version: Next major version OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oeildanslabouche at gmail dot com
New email:
PHP Version: OS:

 

 [2018-02-14 09:38 UTC] oeildanslabouche at gmail dot com
Description:
------------
The doc says push() return void, but it's a boolean indeed.

Test script:
---------------
$test = new \SplStack();
var_dump( $test->push(1));


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-14 09:59 UTC] requinix@php.net
-Summary: bool return on \SplStack->push(), not void +Summary: bool return on some SPL methods, not void -Type: Documentation Problem +Type: Bug
 [2018-02-14 09:59 UTC] requinix@php.net
Just went through the SPL code...

Always RETURN_TRUE, docs say void:
- SplHelp::insert
- SplPriorityQueue::insert
- SplHeap::recoverFromCorruption
- SplDoublyLinkedList::push
- SplDoublyLinkedList::unshift

Always RETURN_TRUE, docs say bool:
- SplFixedArray::setSize

Always returning true isn't helpful. Maybe it would be better to change the code so they are actually void?
 [2018-07-23 02:32 UTC] carusogabriel@php.net
We're only going to change it in the next major version of PHP, as this, unfortunately, is a BC.

Ref: https://github.com/php/php-src/pull/3162
 [2018-07-23 02:32 UTC] carusogabriel@php.net
-Assigned To: +Assigned To: carusogabriel
 [2018-08-11 21:38 UTC] cmb@php.net
Adding array_walk()[1] to this list, even though it is not an SPL
method.

[1] <https://bugs.php.net/76668>
 [2018-08-12 00:14 UTC] carusogabriel@php.net
Also Locale::setDefault from https://bugs.php.net/55173
 [2018-09-21 05:36 UTC] carusogabriel@php.net
-PHP Version: 7.1.14 +PHP Version: Next major version
 [2020-03-25 14:05 UTC] kocsismate@php.net
Automatic comment on behalf of kocsismate@woohoolabs.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=782f7e2ad864693919b9f9efbb4d64bbae17cdc5
Log: Fix #75958 Return void instead of true
 [2020-03-25 14:05 UTC] kocsismate@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jun 07 11:01:27 2025 UTC