Skip to content

Fix SplHeap::compare arginfo and tests #3686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ static const zend_function_entry spl_funcs_SplHeap[] = {
SPL_ME(SplHeap, valid, arginfo_splheap_void, ZEND_ACC_PUBLIC)
SPL_ME(SplHeap, recoverFromCorruption, arginfo_splheap_void, ZEND_ACC_PUBLIC)
SPL_ME(SplHeap, isCorrupted, arginfo_splheap_void, ZEND_ACC_PUBLIC)
ZEND_FENTRY(compare, NULL, NULL, ZEND_ACC_PROTECTED|ZEND_ACC_ABSTRACT)
ZEND_FENTRY(compare, NULL, arginfo_heap_compare, ZEND_ACC_PROTECTED|ZEND_ACC_ABSTRACT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a BC, isn't? 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding arginfo is BC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC breaks go to PHP 8 or is it something that PHP 7.4 can handle as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petk BC goes only in PHP 8. See #3443 for example, as well #74035 and #75958

PHP_FE_END
};
/* }}} */
Expand Down
10 changes: 5 additions & 5 deletions ext/spl/tests/heap_isempty_variation_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
SPL: SplHeap: isEmpty argument variation.
--FILE--
<?php
class SplHeap2 extends SplHeap{

public function compare() {
return -parent::compare();
}
class SplHeap2 extends SplHeap {
public function compare($a, $b) {
return -parent::compare($a, $b);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Stupid question): what does - do here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The - prefix negates the return value, so if the right operand returns 8, then this will return -8

}
}

$h = new SplHeap2;
$h = new SplHeap2();
$h->isEmpty(1);
?>
--EXPECTF--
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/spl_heap_extract_parameter_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TestFest London May 2009

class TestHeap extends SplHeap {

function compare() {
function compare($a, $b) {
print "This shouldn't be printed";
}
}
Expand Down