@vladislav997

Почему сыпится ошибка при перебрасывании сервиса в параметры контроллера?

Подскажите, почему сыпится ошибка при перебрасывании сервиса в параметры контроллера?

use App\Service\CustomService;

// где "...." - в этом месте еще куча разных сервисов подключаются, но они работают
public function index(...., CustomService $customService): Response
{
        $telegramBot = new \TelegramBot\Api\Client($bot->getToken());
        // logic
        $telegramBot->on(function (\TelegramBot\Api\Types\Update $update) use ($telegramBot, $customService) {
                $customService->customMethod(
                        $parametr1 = '...',
                        $parametr2 = '...',
                        $parametr3 = '...',
                );
        }, function () {
            return true;
        });
}

и вот что говорит:

request.CRITICAL: Uncaught PHP Exception RuntimeException: "Controller "App\Controller\TestController::index()" requires that you provide a value for the "$customService" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one." at /var/www/project/vendor/symfony/http-kernel/Controller/ArgumentResolver.php line 80 {"exception":"[object] (RuntimeException(code: 0): Controller \"App\\Controller\\TestController::index()\" requires that you provide a value for the \"$customService\" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one. at /var/www/maracuna/vendor/symfony/http-kernel/Controller/ArgumentResolver.php:80)"} []


Как это пофиксить?
  • Вопрос задан
  • 205 просмотров
Решения вопроса 1
@vladislav997 Автор вопроса
нужно было просто сделать cache:clear
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
SilenceOfWinter
@SilenceOfWinter Куратор тега PHP
та еще зажигалка...
index(...., CustomService $customService)
это в какой версии php так работает?
+ потерял закрывающую скобку у on(
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
YCLIENTS Москва
от 200 000 до 350 000 ₽
Ведисофт Екатеринбург
от 25 000 ₽
ИТЦ Аусферр Магнитогорск
от 100 000 до 160 000 ₽