Replace deprecated static::method() calls for PHP 8.2

Created on 23 July 2022, over 2 years ago
Updated 5 January 2024, 12 months ago

Problem/Motivation

Partially supported callables are deprecated in PHP 8.2 but core has some usage to clean-up for compatibility

- https://wiki.php.net/rfc/deprecate_partially_supported_callables
- https://wiki.php.net/rfc/partially-supported-callables-expand-deprecatio...

"self::method"       -> self::class . "::method"
"parent::method"     -> parent::class . "::method"
"static::method"     -> static::class . "::method"
["self", "method"]   -> [self::class, "method"]
["parent", "method"] -> [parent::class, "method"]
["static", "method"] -> [static::class, "method"]
If compatibility with PHP < 8.1 is not desired, use of the first-class callable syntax self::method(...) is also possible.

This clean-up could be done in 📌 Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...) Needs work

Steps to reproduce

Run \Drupal\Tests\views\Kernel\ModuleTest::testLoadFunctions() on PHP 8.2

https://dispatcher.drupalci.org/job/drupal_patches/138888/testReport/jun...

Unsilenced deprecation notices (10)

  10x: Use of "static" in callables is deprecated
    10x in ModuleTest::testLoadFunctions from Drupal\Tests\views\Kernel

Proposed resolution

- replace usage with recommended in RFC
- decide about formalization to Callables in 📌 Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...) Needs work

Remaining tasks

patch/review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

🐛 Bug report
Status

Fixed

Version

10.0

Component
Other 

Last updated 1 day ago

Created by

🇫🇷France andypost

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy senzaesclusiva

    Sorry for reopen
    Is this the same problem i've founded while checking db tables?
    I'm on D10.2.0, MySQL 5.7.39, php 8.2
    Many thanks for your answer

    Deprecation Notice in ./vendor/webmozart/assert/src/Assert.php#1973
     Use of "static" in callables is deprecated
    
    Backtrace
    
    Mixin.php#81: Webmozart\Assert\Assert::__callStatic(
    string 'allStringNotEmpty',
    array,
    )
    CheckController.php#51: Webmozart\Assert\Assert::allStringNotEmpty(array)
    Routing.php#192: PhpMyAdmin\Controllers\Table\Maintenance\CheckController->__invoke(
    ,
    array,
    )
    ./../../../../../../../../../../Users/xstage/Sites/karma/web/index.php#44: PhpMyAdmin\Routing::callControllerForRoute(
    ,
    string '/table/maintenance/check',
    ,
    ,
    )
    
  • 🇮🇳India rahul_ Alirajpur

    Same error i am facing with below configration.
    PHP 8.2
    Drupal 10.2
    Drush 8.4.12

    ~/project/docroot (main) $ drush uli
    
    Deprecated: Use of "static" in callables is deprecated in phar:///usr/local/bin/drush/vendor/webmozart/assert/src/Assert.php on line 1973
    
    Deprecated: Use of "static" in callables is deprecated in phar:///usr/local/bin/drush/vendor/webmozart/assert/src/Assert.php on line 1973
  • 🇨🇭Switzerland berdir Switzerland

    Those are from old drush versions and its dependencies, not Drupal core. You need to update drush.

  • 🇮🇳India rahul_ Alirajpur

    we are already on latest drush

    $ drush --version
    Drush Launcher Version: 0.10.1
    
    Deprecated: Use of "static" in callables is deprecated in phar:///usr/local/bin/drush/vendor/webmozart/assert/src/Assert.php on line 1973
    
    Deprecated: Use of "static" in callables is deprecated in phar:///usr/local/bin/drush/vendor/webmozart/assert/src/Assert.php on line 1973
    Drush Commandline Tool 12.4.3.0
  • 🇨🇭Switzerland berdir Switzerland

    You are using drush-launcher which is no longer supported, that message might be from that, see https://github.com/drush-ops/drush-launcher.

  • 🇮🇳India rahul_ Alirajpur

    It is fixed after update Drush Launcher version 0.10.2

    https://github.com/drush-ops/drush-launcher/issues/102

    Thanks

  • 🇮🇹Italy senzaesclusiva

    Thanks for your all answers
    I'm not using the drush-launcer

    BTW issues seems to be solved with last update of Drush 12.4.3.0 and Composer 2.6.6
    Thanks again

Production build 0.71.5 2024