After PHP 7.4 -> PHP 8.2 & Laravel 8.x -> 10.x upgrade (through Rector, Laravel Shift) I'm getting the above error in one of my routes. The route can be found at https://github.com/Wotuu/keystone.guru/blob/development/app/Http/Controllers/Ajax/AjaxDungeonRouteController.php#L80. I've been unable to figure out why this suddenly happens. It doesn't happen locally on my machine, but it does happen on my staging environment which is running on a dedicated server. This then subsequently prevents me from releasing this to prod.
For some reason laravel-serializable-closure can't serialize my function? I figured this is used for route caching. Directly uploading the offending file with a stripped out version of the route, and running php artisan route:clear does not resolve the situation. The error message also doesn't change if I re-upload the file with changes. It contains the full source for that function but if I enter a dd() on the first line it doesn't change it in the error message, for example. Yes, the file is actually changed on the server.
Quite stumped with this one and Google didn't give me any help either, so I'm asking here. What's causing this? I reverted any changes done by Rector/Shift for this function but to no avail. Thanks in advance for any help.