Hello,
when using the module on D10.1.6 version on PHP8.2.0, I got the following error message:
Deprecated function: Use of "self" in callables is deprecated in Drupal\unused_modules\UnusedModulesHelperService::getAvailableModules() (line 55 of modules/contrib/unused_modules/src/UnusedModulesHelperService.php).

How to fix it?

CommentFileSizeAuthor
#2 3404077-1.patch1.22 KBsandeepsingh199
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

webmestre created an issue. See original summary.

sandeepsingh199’s picture

Status: Active » Needs review
StatusFileSize
new1.22 KB

Hi @webmestre, The warning "Deprecated function: Use of 'self' in callables is deprecated" typically occurs when a class method references itself using the self keyword in a way that involves a callable. This is a change introduced in PHP >=8.1. You can modify your code to use the static keyword instead of self. The static keyword refers to the class in which it is used, allowing for late static binding. This change ensures compatibility with PHP >=8.1 and eliminates the deprecation warning.

In my case I am not facing any deprecated function error, but if you getting this error, try with this patch.

cosmin-hm’s picture

Thank you for the patch. However, the PHP message is now:
Deprecated function: Use of "static" in callables is deprecated in Drupal\unused_modules\UnusedModulesHelperService::getEnabledModules() (line 75 of /modules/contrib/unused_modules/src/UnusedModulesHelperService.php)
PHP 8.2.16, Drupal 10.2.4

delacosta456’s picture

hi
as mentioned by @cosmin-hodis-mindras after applying patch on my own side too the error message changed to exactly message reported (#3) . i am on D10.2.5 and php8.2.17

Thanks

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Version: 8.x-1.5 » 8.x-1.x-dev

I was able to reproduce it by using PHP 8.2 version.

Should work now.

astonvictor’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.