Doc #76024 [Opn]: Elements disappear After Interaction with SplHeap

From: Date: Wed, 28 Feb 2018 12:50:52 +0000
Subject: Doc #76024 [Opn]: Elements disappear After Interaction with SplHeap
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15481@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76024&edit=1 ID: 76024 Updated by: salathe@php.net Reported by: mt at mfmello dot com Summary: Elements disappear After Interaction with SplHeap Status: Open Type: Documentation Problem Package: SPL related Operating System: Linux Mint 18.1 64bits PHP Version: 7.0.27 Block user comment: N Private report: N New Comment: SplHeap::next() already documents that calling this method (which happens implicitly using foreach) will delete the top node of the heap. -- http://php.net/manual/en/splheap.next.php Previous Comments: ------------------------------------------------------------------------ [2018-02-28 10:18:30] cmb@php.net This behavior is by design[1]. Changing to doc bug. [1] <https://github.com/php/php-src/blob/PHP-7.2.3/ext/spl/spl_heap.c#L945-L961> <https://github.com/php/php-src/blob/PHP-7.2.3/ext/spl/spl_heap.c#L885-L889> ------------------------------------------------------------------------ [2018-02-28 00:41:57] carusogabriel34 at gmail dot com Confirmed: https://3v4l.org/pHeW0 ------------------------------------------------------------------------ [2018-02-28 00:14:45] mt at mfmello dot com Description: ------------ --- From manual page: http://www.php.net/class.splheap --- After filling a SplHeap object using "SplHeap::insert" and creating an interaction with the object the inserted elements simply disappear, I looked in several forums and I saw many people with the same problem because they did not expect that after looping their elements no longer exist in the initial object. Original (pt-br): Após preencher um objeto SplHeap usando "SplHeap::insert" e criar uma interação com o objeto os elementos inseridos simplesmente somem, pesquisei em diversos forúns e vi muitas pessoas com o mesmo problema, pois elas não esperam que após fazer um loop os seus elementos não existam mais no objecto inicial. Test script: --------------- <?php $spl = new SplMinHeap(); $spl->insert(10); $spl->insert(7); $spl->insert(5); $spl->insert(2); echo 'Size object: ' . $spl->count(); // result 4 echo PHP_EOL; foreach ($spl as $number) echo 'Number: ' . $number . PHP_EOL; echo 'New size object: ' . $spl->count(); // result 0 Expected result: ---------------- I believe that I and many others hope that after a loop the elements are still inside the object. Because we do not configure the removal of it and we do not execute anything like "SplHeap::extract" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76024&edit=1

« previous php.doc.bugs (#15481) next »