“Calling get_class() without arguments is deprecated” in WordPress (PHP 8.3)
Short answer
It’s a deprecation notice from PHP 8.3 and later: a plugin or theme asks for the name of its own class with get_class() and no arguments. The code keeps working and gives the same result. PHP wants it written explicitly instead: self::class (or static::class) inside a class. Update the plugin, or send the message to its developer.
The message, exactly
An invoicing plugin writes which class created a document. PHP 8.2 runs it silently; PHP 8.3 adds the notice:
example.php
<?php
class Invoice {
public function describe(): string {
return 'Created by ' . get_class();
}
}
echo (new Invoice())->describe(), "\n";
Created by InvoiceDeprecated: Calling get_class() without arguments is deprecated in /var/www/html/example.php on line 4
Created by Invoicephp.net, in the PHP 8.3 deprecations: “Calling get_class() and get_parent_class() without arguments is now deprecated.” (php.net)
Is it urgent?
No. The output is the same on PHP 8.2 and 8.3. It needs fixing at some point, because a future PHP version is expected to remove what is deprecated today.
Who fixes it
- Find the plugin or theme: the folder after
wp-content/plugins/orwp-content/themes/in the message. - Update it (Dashboard → Updates).
- Already on the latest version? Send one full line of the message to its developer.
- Keep notices off your pages: the WordPress debug log shows how.
A check that reads code finds every call while your site still runs PHP 8.2:
The other PHP 8.3 changes are in WordPress and PHP 8.3.
Key takeaways
- It’s a deprecation notice from PHP 8.3 and later; the result is the same as before.
get_parent_class()without arguments gets the same notice.- The fix inside a class is
self::class(orstatic::classwhen child classes should report their own name). - A check that reads code finds every call before you upgrade.
Frequently asked questions
Is it dangerous?
No. The code works and returns the same class name; PHP only adds the notice. A future PHP version is expected to remove the call without arguments.
What’s the difference between self::class and static::class?
self::class is the class where the code is written; static::class is the class of the object it runs on, which can be a child class. get_class() without arguments behaved like self::class.
Check your own site before you upgrade
CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.
Sources
About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.