Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd62c2d

Browse files
committed
feature #45680 [DependencyInjection] use #[Required] for ServiceSubscriberTrait::setContainer() (kbond)
This PR was merged into the 6.1 branch. Discussion ---------- [DependencyInjection] use `#[Required]` for `ServiceSubscriberTrait::setContainer()` | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #45679 | License | MIT | Doc PR | n/a Can't use for `Symfony\Bundle\FrameworkBundle\Controller::setContainer()` until we bump the min version of `service-contracts`. Commits ------- 24646c4 [DI] add `#[Required]` where applicable
2 parents c7dbcc9 + 24646c4 commit cd62c2d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use Symfony\Component\Serializer\SerializerInterface;
4343
use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener;
4444
use Symfony\Component\WebLink\GenericLinkProvider;
45+
use Symfony\Contracts\Service\Attribute\Required;
4546
use Symfony\Contracts\Service\ServiceSubscriberInterface;
4647
use Twig\Environment;
4748

@@ -60,6 +61,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
6061
/**
6162
* @required
6263
*/
64+
#[Required]
6365
public function setContainer(ContainerInterface $container): ?ContainerInterface
6466
{
6567
$previous = $this->container;

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Contracts\Service;
1313

1414
use Psr\Container\ContainerInterface;
15+
use Symfony\Contracts\Service\Attribute\Required;
1516
use Symfony\Contracts\Service\Attribute\SubscribedService;
1617

1718
/**
@@ -67,9 +68,7 @@ public static function getSubscribedServices(): array
6768
return $services;
6869
}
6970

70-
/**
71-
* @required
72-
*/
71+
#[Required]
7372
public function setContainer(ContainerInterface $container): ?ContainerInterface
7473
{
7574
$this->container = $container;

0 commit comments

Comments
 (0)