2

I recently upgraded my project from Symfony 3.4 to 4.4. I am stil working on the upgradation but I am stuck in this Fatal error which says

Compile Error: Declaration of ContainerGWHmz1B\srcApp_KernelDevDebugContainer::getParameter(string $name) must be compatible with Symfony\Component\DependencyInjection\Container::getParameter($name)

This happens when Symfony generates a cache of all the services and classes stored inside /var/cache/dev/ContainerGWHmz1B/srcApp_KernelDevDebugContainer

From the error it totally makes sense because in my compiled container this is the definition

public function getParameter(string $name) while in the Container class which this class extends this is the definition

public function getParameter($name).

The error is quite clear but how can I stop it from happening? Thanks for your help.

rashidkhan
  • 462
  • 8
  • 24
  • 2
    technically you're correct. multiple options that I would try to check: are all dependencies on v4.4 in symfony (specifically the dependency-injection. Secondly clear the cache (maybe even remove the "var" dir, where all codefiles access it. If the problem still persists, come back and tell us what you've learned (maybe post your composer.json ^^) – Jakumi Apr 04 '21 at 00:06
  • 1
    Please share more details, like your debugging attempts – Nico Haase Apr 04 '21 at 21:19
  • @rashidkhan did you find solution ? – Yatin Mistry Oct 08 '21 at 06:37
  • @YatinMistry This is my side project co couldn't work on it for some time. But this issue is not happening anymore. But at that I think I had made the argument typed i.e. `Symfony\Component\DependencyInjection\Container::getParameter(string $name)`. Which you should never do in a real project. But that was temporary and now it's working. – rashidkhan Oct 08 '21 at 15:21
  • @rashidkhan thanks for the reply. yeah, you're right. We can do it temporarily. Need proper solution. – Yatin Mistry Oct 11 '21 at 08:08

2 Answers2

0

I had a same problem. I had to manually clear the cache because of the previous version.

rm -rf var/cache/dev/*
pevac
  • 591
  • 4
  • 8
-1

I had same problem, go to var/cache and look for dev or prod directory and try cleaning the directory using following command.

  • rm -rf var/cache/dev/*
  • rm -rf var/cache/prod/*

This would solve the issue.

  • Please don't duplicate existing answers, unless you want to share new insights. If this is the case here, please add some explanation to your answer such that others can learn from it – Nico Haase May 22 '23 at 08:38