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: Assigned Package: SPL related
PHP Version: Next major version OS: windows
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:
13 + 3 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 03:01:26 2019 UTC