Search code examples
symfonydoctrine-ormdoctrinedqltype-hinting

Symfony asks to type-hint SqlWalker constructor parameters


I have a problem. I am creating a custom walker for Doctrine DQL query and it extends the SqlWalker class.

class UseIndexWalker extends SqlWalker

And the symfony asks to autowire the args of SqlWalker __construct.

Cannot autowire service "App\Object\UseIndexWalker": argument "$query" of method "__construct()" has no type-hint, you should configure its value explicitly.

This is how I add walker to query in controller/repository.

$queryBuilder->getQuery()
   ->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, UseIndexWalker::class)
   ->setHint(UseIndexWalker::HINT_USE_INDEX, 'event_search1_location_idx')->getResult();

How would one fix such a problem?


Solution

  • I fixed it by adding the file to excludes property of services.yaml file