[PHP 8.3] Fix get_class() deprecations#152
[PHP 8.3] Fix get_class() deprecations#152Ayesh wants to merge 1 commit intowintercms:developfrom Ayesh:php83/get_class-deprecation
get_class() deprecations#152Conversation
In PHP 8.3, [calling `get_class()` and `get_parent_class()` functions without arguments is deprecated](https://php.watch/versions/8.3/get_class-get_parent_class-parameterless-deprecated). This fixes them with identical alternatives that do not cause the deprecation notice. References: - [PHP RFC: Deprecate functions with overloaded signatures](https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures) - [PHP 8.3: get_class() and get_parent_class() function calls without arguments deprecated](https://php.watch/versions/8.3/get_class-get_parent_class-parameterless-deprecated)
|
@Ayesh unfortunately that won't work - we have tried that before. We'll have to refactor the |
|
@bennothommo why does it not work? |
|
@LukeTowers I think it's a quirk of traits - the |
|
Should we log that as an issue with PHP 8.3 then? |
|
Evidentally, it's an issue with PHP 8.0-8.2 as well, going by our tests. I'm just about to roll out a PR that does what we need with Reflection classes. It should be way more reliable. |
This uses Reflection to instead determine the parent class and available magic methods to pass through to. In order to prevent infinite looping (which could've potentially been a problem before), it will also ignore any "extendable" classes when determining the parent. Also fixed some tests that were using undefined class properties, and were also throwing deprecation errors. Replaces #152
|
@Ayesh if that's the case are you able to figure out why the tests failed in our case with this PR? I would prefer the simpler approach of just passing $this if we can make that work, although I haven't dug into @bennothommo's PR too deeply yet. |
In PHP 8.3, calling
get_class()andget_parent_class()functions without arguments is deprecated.This fixes them with identical alternatives that do not cause the deprecation notice.
References: