Skip to content
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

[RFC] User-defined object comparison #3339

Closed
wants to merge 40 commits into from

Conversation

4 participants
@rtheunissen
Copy link
Contributor

rtheunissen commented Jun 26, 2018

@rtheunissen rtheunissen changed the title WIP: Draft implementation of the user-defined object comparison RFC [RFC] Draft implementation of user-defined object comparison Jun 26, 2018

@Majkl578

This comment has been minimized.

Copy link
Contributor

Majkl578 commented Jun 27, 2018

I was playing with this recently (based on Java): https://gist.github.com/Majkl578/e71828d2a146a5cad34ccb893171f6ab

@carusogabriel
Copy link
Member

carusogabriel left a comment

Great RFC :)

Nit: some tests don't need EXPECTF, we can use EXPECT

@rtheunissen rtheunissen force-pushed the rtheunissen:rt-compare-to-magic-method branch from 4cdb098 to 5da5218 Jun 27, 2018

@rtheunissen

This comment has been minimized.

Copy link
Contributor Author

rtheunissen commented Jun 27, 2018

@carusogabriel Thanks for the suggestion! Fixed them all in 7f40bf2.

@rtheunissen

This comment has been minimized.

Copy link
Contributor Author

rtheunissen commented Jun 28, 2018

Can someone help me debug what's happening with inheritance here?

When ENABLE_DEBUG is 0 on a non-debug build, running the same script as Travis results in some very strange behaviour around inheritance:

./sapi/cli/php run-tests.php -p `pwd`/sapi/cli/php $(if [ $ENABLE_DEBUG == 0 ]; then echo "-d opcache.enable_cli=1 -d zend_extension=`pwd`/modules/opcache.so"; fi) -g "FAIL,XFAIL,BORK,WARN,LEAK,SKIP,PASS" --offline --show-diff --show-slow 1000 --set-timeout 120 Zend/tests/comparisons/*.phpt
Fatal error: Uncaught Error: Cannot access parent:: when current class scope has no parent in .../Zend/tests/comparisons/compare-inheritance.php:18

There are multiple failures all over the place but this is a good one to inspect.

That test file is here, and the included file is here. it's worth noting that taking out that include and embedded the contents in that .phpt file has no effect on the output.

@nikic

This comment has been minimized.

Copy link
Member

nikic commented Jun 28, 2018

@rtheunissen The debug=0 build is with opcache. You're missing an update to https://github.com/php/php-src/blob/master/ext/opcache/zend_accelerator_util_funcs.c#L425 -- pointers to methods need to be rewired to point into the CG arena.

@nikic nikic added the RFC label Jun 28, 2018

@Majkl578

This comment has been minimized.

Copy link
Contributor

Majkl578 commented Jun 28, 2018

I'm slightly worried about the behavior of weak comparison after this change.

Given the discussion in #3297 (comment), this may make things more confusing.
I'd like to come up with RFC for declare(strict_comparisons=1) which would affect ==, !=, but also <, >, <=, >=, <=>, <>, targeting PHP-next (whichever it is - after 7.3). This would make ==/!= behave the same way as ===/!==.

I'm afraid that if this RFC was implemented sooner, it would make things more confusing.

@rtheunissen rtheunissen changed the title [RFC] Draft implementation of user-defined object comparison [RFC] User-defined object comparison Jun 28, 2018

@rtheunissen

This comment has been minimized.

Copy link
Contributor Author

rtheunissen commented Jun 28, 2018

I'm slightly worried about the behavior of weak comparison after this change.

@Majkl578 see #3297 (comment)

@rtheunissen rtheunissen force-pushed the rtheunissen:rt-compare-to-magic-method branch 2 times, most recently from 95519dc to 20a1efc Jun 30, 2018

@rtheunissen rtheunissen force-pushed the rtheunissen:rt-compare-to-magic-method branch from e490eba to 7bbae20 Jul 4, 2018

@rtheunissen

This comment has been minimized.

Copy link
Contributor Author

rtheunissen commented Jul 16, 2018

Closing due to declined RFC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.