You’re using an extremely outdated method of creating a widget. You should be using the __construct()
function, not a named function, as the constructor, as documented.
namespace App;
class My_Widget extends \WP_Widget {
function __construct() {
$widget_ops = [
'name' => 'My widget',
'description' => 'My description'
];
parent::__construct( 'My_Widget', 'My widget', $widget_ops );
}
}
function load_widget() {
register_widget( 'App\\my_widget' );
}
add_action( 'widgets_init', __NAMESPACE__ . '\\load_widget' );