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 #3259716: Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...)

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 #3259716: Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...)

Remaining tasks

patch/review/commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

CommentFileSizeAuthor
#5 3299327-5.patch5.64 KBandypost
#5 interdiff.txt562 bytesandypost
#3 3299327-3.patch5.09 KBandypost

Comments

andypost created an issue. See original summary.

andypost’s picture

Issue summary: View changes
andypost’s picture

Status: Active » Needs review
StatusFileSize
new5.09 KB
berdir’s picture

Status: Needs review » Needs work

There's one more instance with ['self', '''] in \Drupal\views\ViewsDataHelper::fetchFields.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new562 bytes
new5.64 KB

Thanks, missed this one and can't find the message in tests

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, not sure if that needs to be self, I guess not, but lets not change that here.

  • catch committed 876e17f on 10.1.x
    Issue #3299327 by andypost, Berdir: Replace deprecated static::method()...

  • catch committed f54a2c3 on 10.0.x
    Issue #3299327 by andypost, Berdir: Replace deprecated static::method()...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Yes let's leave the self as-is here, not a class that's going to get subclassed anyway, could be a small task follow-up to change.

Committed/pushed to 10.1.x and cherry-picked to 10.0.x, thanks!

andypost’s picture

Status: Fixed » Closed (fixed)

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

andypost’s picture

Filed follow-up for the missed conversion #3309750: Fix callable syntax for PHP 8.2 in Views.php

senzaesclusiva’s picture

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',
,
,
)
rahul_’s picture

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
berdir’s picture

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

rahul_’s picture

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
berdir’s picture

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

rahul_’s picture

It is fixed after update Drush Launcher version 0.10.2

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

Thanks

senzaesclusiva’s picture

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