-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Milestone
Description
Symfony version(s) affected
7.0
Description
In a Symfony bundle (https://github.com/symfonycorp/connect) we have this:
namespace SymfonyCorp\Connect;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class SymfonyConnectBundle extends Bundle
{
public function getContainerExtension(): ?ExtensionInterface
{
if (null === $this->extension) {
$this->extension = new SymfonyConnectExtension();
}
return $this->extension;
}
// ...
}
It works fine in all Symfony versions up to and including 6.4.
But, in 7.0 (beta2) we're seeing this error:
Typed property Symfony\Component\HttpKernel\Bundle\Bundle::$extension
must not be accessed before initialization.
The error happens because this line in 6.4:
protected $extension; |
Turned into this line in 7.0:
protected ExtensionInterface|false $extension; |
If I make this change in Symfony code, everything works again:
-protected ExtensionInterface|false $extension;
+protected ExtensionInterface|false|null $extension = null;
So, what should we do here? Thanks!
How to reproduce
Use this bundle https://github.com/symfonycorp/connect in a Symfony 7 application.
Possible Solution
No response
Additional Context
No response