Verified Commit a5f4685c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3320315 by Wim Leers, Anchal_gupta, alexpott, longwave: Allow uppercase...

Issue #3320315 by Wim Leers, Anchal_gupta, alexpott, longwave: Allow uppercase service IDs/names — necessary for autowiring support
parent 71433155
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -41,9 +41,6 @@ public function __construct(ParameterBagInterface $parameterBag = NULL) {
   *   services in a frozen builder.
   */
  public function set($id, $service) {
    if (strtolower($id) !== $id) {
      throw new \InvalidArgumentException("Service ID names must be lowercase: $id");
    }
    SymfonyContainer::set($id, $service);
  }

@@ -51,9 +48,6 @@ public function set($id, $service) {
   * {@inheritdoc}
   */
  public function register($id, $class = NULL): Definition {
    if (strtolower($id) !== $id) {
      throw new \InvalidArgumentException("Service ID names must be lowercase: $id");
    }
    $definition = new Definition($class);
    // As of Symfony 5.2 all services are private by default, but in Drupal
    // services are still public by default.
+0 −21
Original line number Diff line number Diff line
@@ -24,17 +24,6 @@ public function testGet() {
    $this->assertInstanceOf(BarClass::class, $result);
  }

  /**
   * @covers ::set
   */
  public function testSetException() {
    $container = new ContainerBuilder();
    $class = new BarClass();
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('Service ID names must be lowercase: Bar');
    $container->set('Bar', $class);
  }

  /**
   * @covers ::setParameter
   */
@@ -45,16 +34,6 @@ public function testSetParameterException() {
    $container->setParameter('Buzz', 'buzz');
  }

  /**
   * @covers ::register
   */
  public function testRegisterException() {
    $container = new ContainerBuilder();
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('Service ID names must be lowercase: Bar');
    $container->register('Bar');
  }

  /**
   * @covers ::register
   */