Skip to content

Conversation

@andrasguseo
Copy link

@andrasguseo andrasguseo commented Sep 17, 2025

Loading the Community Submission page generates the following notice for two lines:
DeprecatedCalling get_class() without arguments is deprecatedwp-content/plugins/the-events-calendar-community-events/vendor/the-events-calendar/wp-router/WP_Router_Sample.class.php

get_class() without arguments is deprecated in PHP 8.0+, and get_class($this) won't work here because we're in a static method context.

The solution is to use __CLASS__ instead of get_class(). The __CLASS__ magic constant returns the name of the current class and works perfectly in static contexts.

Screenshot before the fix with the deprecation message.
Screenshot after the fix without the deprecation message.

There is a slightly different PR here using get_called_class().

get_called_class() vs CLASS

get_called_class():

  • Returns the name of the class that was actually called (supports late static binding)
  • If a child class calls the parent's static method, it returns the child class name
  • More dynamic and inheritance-aware

__CLASS__:

  • Returns the name of the class where the code is written
  • Always returns the same class name regardless of which class actually called it
  • More predictable and explicit

@Camwyn Camwyn merged commit 7b6159a into the-events-calendar:master Sep 18, 2025
@andrasguseo andrasguseo deleted the fix/CE-333-php82-compat branch September 18, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants