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

PHP 8.2 | Fix "Use of "parent" in callables is deprecated" notice #1169

Merged

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 15, 2022

I've searched the code base to see if I could find all affected callbacks. No guarantee I've found them all though, though a test run against PHP 8.2 with the testsuite of this codebase no longer shows this particular error with the patch applied.

Fixes #1168

I've searches the code base to see if I could find all affected callbacks. No guarantee I've found them all though.

Fixes 1168
@jrfnl jrfnl force-pushed the feature/1168-fix-php-8.2-error-callables branch from dc5c70d to f09b080 Compare March 15, 2022 07:48
@jrfnl jrfnl changed the title PHP 8.2: fix "Use of "parent" in callables is deprecated" notice PHP 8.2 | Fix "Use of "parent" in callables is deprecated" notice Mar 15, 2022
@davedevelopment davedevelopment merged commit a60f28f into mockery:1.3 Apr 12, 2022
@jrfnl jrfnl deleted the feature/1168-fix-php-8.2-error-callables branch April 12, 2022 10:34
@driesvints
Copy link

Can we maybe get a release for this? Right now, we can't add passing PHP 8.2 builds to Laravel and some of our first party libraries because of the deprecation notices. This is one of the few things that's still blocking us so would be cool to see this getting a tag! : )

@jrfnl
Copy link
Contributor Author

jrfnl commented Sep 6, 2022

@driesvints FYI: There are actually still some more PHP 8.2 issues to be fixed in Mockery (or to find work-arounds for). I still need to find the time to write those up properly.

@driesvints
Copy link

@jrfnl definitely. But right now, the code of this PR is the only thing we encounter ourselves. Is there a chance we can get that released so you can do the remaining ones in an upcoming release? Dave mentioned he wanted to check into this tomorrow: https://twitter.com/davedevelopment/status/1567170288642572296

@jrfnl
Copy link
Contributor Author

jrfnl commented Sep 6, 2022

Is there a chance we can get that released so you can do the remaining ones in an upcoming release?

Not my decision (or responsibility). Just like you, I'm just a user of Mockery and I fully support a release with this fix, even if it's only partial PHP 8.2 support, it gets rid of most issues for most code bases using Mockery.

@driesvints
Copy link

Thanks @jrfnl!

@cmanley
Copy link

cmanley commented Mar 6, 2024

Shouldn't this:
call_user_func(get_parent_class($this) . '::__isset', $name);
be written as
call_user_func(parent::class . '::__isset', $name);
?
Because $this doesn't have to be an instance of the current class: it could be a child class in which case you'll end up with infinite recursion.

@jrfnl
Copy link
Contributor Author

jrfnl commented Mar 6, 2024

Shouldn't this: call_user_func(get_parent_class($this) . '::__isset', $name); be written as call_user_func(parent::class . '::__isset', $name); ? Because $this doesn't have to be an instance of the current class: it could be a child class in which case you'll end up with infinite recursion.

@cmanley The call is conditional and the code as per this PR follows the code in the condition:

if (false === stripos($name, '_mockery_') && get_parent_class($this) && method_exists(get_parent_class($this), '__isset')) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants