Roots Discourse

Upgrading to PHP 7.4 Fatal error Class not found

After upgrading PHP 7.3.5 to 7.4, we got this error:

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Class 'TaxonomyLocale' not found in /tmp/sage-cache/tempfile.php

This is caused by calling a function from a class extends Controller in the blade template /resources/views/taxonomy-locale.blade.php

Code below:
<div class="location-wrap {{ TaxonomyLocale::featured_class($i, $num, $mod) }}">

TaxonomyLocale class is declared in ‘app/controllers/taxonomy-locale.php’:

namespace App;
use Sober\Controller\Controller;
use WP_Query;

class TaxonomyLocale extends Controller

public static function featured_class($count, $total, $mod) {..}


If anyone could help, I would appreciate it very much.

Does this work:

<div class="location-wrap {{ \App\TaxonomyLocale::featured_class($i, $num, $mod) }}">

Thanks, @alwaysblank! That definitely helps! Still not sure why it is not working on PHP 7.4. Maybe autoload has some problem we are still using the Sage 9.0.0-beta4 version.

But the page still got a bunch of undefined variables. These are also coming from the same controller.

I tried to load the namespace via use App\TaxonomyLocale it is working with functions without prefix with \App\TaxonomyLocale but not sure why it is not working with variables.