Skip to content

Fix SplHeap::compare arginfo and tests#3686

Closed
morrisonlevi wants to merge 1 commit into
php:masterfrom
morrisonlevi:splheap-fixes
Closed

Fix SplHeap::compare arginfo and tests#3686
morrisonlevi wants to merge 1 commit into
php:masterfrom
morrisonlevi:splheap-fixes

Conversation

@morrisonlevi

Copy link
Copy Markdown
Contributor

No description provided.

@petk petk added the Quickfix label Nov 27, 2018

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread ext/spl/spl_heap.c Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@nikic

nikic commented Nov 28, 2018

Copy link
Copy Markdown
Member

The main thing I'd be concerned about is that a user implements compare with compare(Foo $a, Foo $b), which would no longer satisfy this signature (even with parameter contravariance -- this would need generics to work).

@carusogabriel

Copy link
Copy Markdown
Contributor

This can be merged against master now :)

@krakjoe

krakjoe commented Jan 31, 2019

Copy link
Copy Markdown
Member

I'm not certain that Nikita's concern has been or is going to be addressed ?

What do you think about this now @nikic ?

@nikic

nikic commented Jan 31, 2019

Copy link
Copy Markdown
Member

I'm conflicted here. On the one hand, this change is going to make ergonomics worse, because people will no longer be able to typehint their compare() methods. On the other hand, the way this is currently achieved is through a dirty engine hack that probably shouldn't exist in the first place.

Overall I think we should merge this for PHP 8. Not a lot of people override this method and the current behavior is inconsistent with how PHP usually works.

We may also make availability of arginfo a hard requirement in future, in which case this would no longer work anyway.

@nikic nikic added this to the PHP 8.0 milestone Feb 8, 2019
@nikic

nikic commented Feb 8, 2019

Copy link
Copy Markdown
Member

Merged as 780bdcd into master.

@nikic nikic closed this Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants