mundschenk-at / wp-typography

Improve your WordPress micro typography.
https://code.mundschenk.at/wp-typography/
Other
22 stars 3 forks source link

[PHP8.0] Plugin uses deprecated function in library #292

Closed larsschellhas closed 2 years ago

larsschellhas commented 2 years ago

Issue Overview

When using PHP 8.0, the following errors are printed (many times):

Deprecated: Method ReflectionParameter::getClass() is deprecated in /home/www/doc/33488/klarissenkloster.de/www/wp-content/plugins/wp-typography/vendor-scoped/level-2/dice/Dice.php on line 184

This is obviously a library issue and has been fixed in the latest release of the library, as can be seen here.

Steps to Reproduce (for bugs)

  1. Activate PHP 8.0

PHP 8.0 WordPress 5.8.1 wp-typography 5.7.2

Expected Behavior

No errors because of deprecated functions should be shown.

Current Behavior

See above

Possible Solution

Update dependency

Related Issues and/or PRs

Coming

larsschellhas commented 2 years ago

Updating the DICE dependency (while keeping the modified namespace name.... why though? Makes updating dependencies harder than it should be, doesn't it?) leads to the following fatal error:

Fatal error: Uncaught TypeError: 
WP_Typography\Plugin_Controller::__construct(): Argument #2 ($components) must be of type array, null given, 
called in mywebsite/www/wp-content/plugins/wp-typography/vendor-scoped/level-2/dice/Dice.php on line 119 and 
defined in mywebsite/www/wp-content/plugins/wp-typography/includes/wp-typography/class-plugin-controller.php:61 

Stack trace: 
#0 mywebsite/www/wp-content/plugins/wp-typography/vendor-scoped/level-2/dice/Dice.php(119): WP_Typography\Plugin_Controller->__construct() 
#1 mywebsite/www/wp-content/plugins/wp-typography/vendor-scoped/level-2/dice/Dice.php(96): WP_Typography\Vendor\Dice\Dice->WP_Typography\Vendor\Dice\{closure}() 
#2 mywebsite/www/wp-content/plugins/wp-typography/wp-typography.php(75): WP_Typography\Vendor\Dice\Dice->create() 
#3 mywebsite/www/wp-content/plugins/wp-typography/wp-typography.php(81): wp_typography_run() 
#4 mywebsite/www/wp-settings.php(409): include_once('...') 
#5 mywebsite/www/wp-config.php(90): require_once('...') 
#6 mywebsite/www/wp-load.php(50): require_once('...') 
#7 mywebsite/www/wp-admin/admin.php(34): require_once('...') 
#8 mywebsite/www/wp-admin/plugin-editor.php(10): require_once('...') 
#9 {main} 
thrown in mywebsite/www/wp-content/plugins/wp-typography/includes/wp-typography/class-plugin-controller.php on line 61

I can see where the type error results from, however, I am not a PHP dev and don't know how to solve this in the correct way for your plugin. I hope, you can quickly resolve these little issues 😊 Thank you very much for your work and support. I appreciate it a lot.

mundschenk-at commented 2 years ago

@larsschellhas Scoping is necessary to prevent conflicts with other plugins that include the same dependency. As you discovered, switching the Dice version needs some code adaption as well. It's on my todo list, but I've not gotten around to it yet (as PHP-Typography also needs to be checked for PHP 8 compatibility).

larsschellhas commented 2 years ago

Thank you for the explanation! 😊 I just thought, I would open an issue since I hadn't seen any for this, yet. Thank you for your efforts!