diff --git a/core/lib/Drupal/Core/DependencyInjection/Container.php b/core/lib/Drupal/Core/DependencyInjection/Container.php index 3c8b631..aef2323 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Container.php +++ b/core/lib/Drupal/Core/DependencyInjection/Container.php @@ -362,7 +362,7 @@ protected function createService(array $definition, $id) { * {@inheritdoc} */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { - if (isset($service)) { + if (isset($service) && is_object($service)) { $service->_serviceId = $id; } $this->services[$id] = $service; @@ -456,7 +456,8 @@ protected function resolveServicesAndParameters($arguments) { $name = $argument->name; if (!isset($this->parameters[$name])) { $arguments[$key] = $this->getParameter($name); - // This can never be reached as getParameter() throws an Exception. + // This can never be reached as getParameter() throws an Exception, + // because we already checked that the parameter is not set above. } // Update argument. diff --git a/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php index d433375..dcf7227 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -369,7 +369,7 @@ protected function dumpCallable($callable) { protected function getPrivateServiceCall($id, Definition $definition, $shared = FALSE) { $service_definition = $this->getServiceDefinition($definition); if (!$id) { - $hash = sha1(serialize($service_definition)); + $hash = hash('sha1', serialize($service_definition)); $id = 'private__' . $hash; } return (object) array( diff --git a/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php index 4ca94fa..2de82b0 100644 --- a/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php +++ b/core/lib/Drupal/Core/DependencyInjection/PhpArrayContainer.php @@ -247,7 +247,8 @@ protected function resolveServicesAndParameters($arguments) { $name = substr($argument, 1, -1); if (!isset($this->parameters[$name])) { $arguments[$key] = $this->getParameter($name); - // This can never be reached as getParameter() throws an Exception. + // This can never be reached as getParameter() throws an Exception, + // because we already checked that the parameter is not set above. } $argument = $this->parameters[$name]; $arguments[$key] = $argument; @@ -264,7 +265,9 @@ protected function resolveServicesAndParameters($arguments) { if (isset($this->services[$id])) { $arguments[$key] = $this->services[$id]; } - $arguments[$key] = $this->get($id, $invalid_behavior); + else { + $arguments[$key] = $this->get($id, $invalid_behavior); + } } } diff --git a/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php b/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php index 15120a5..8a6d3bc 100644 --- a/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php +++ b/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php @@ -31,7 +31,7 @@ class ServiceProviderWebTest extends WebTestBase { */ public function testServiceProviderRegistrationIntegration() { $this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service has been registered to the DIC'); - // The event subscriber method in the test class calls drupal_set_message + // The event subscriber method in the test class calls drupal_set_message() // with a message saying it has fired. This will fire on every page request // so it should show up on the front page. $this->drupalGet(''); diff --git a/core/modules/update/src/Tests/UpdateTestBase.php b/core/modules/update/src/Tests/UpdateTestBase.php index 33ee105..faec496 100644 --- a/core/modules/update/src/Tests/UpdateTestBase.php +++ b/core/modules/update/src/Tests/UpdateTestBase.php @@ -35,7 +35,7 @@ protected function setUp() { // Change the root path which Update Manager uses to install and update // projects to be inside the testing site directory. See - // \Drupal\updateUpdateRootFactory::get() for equivalent changes to the + // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the // test child site. $request = \Drupal::request(); $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request); diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php index ca8cf98..f4d05e9 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php @@ -239,7 +239,7 @@ public function testGetForCircularServices() { } /** - * Tests that Container::get() for non-existant services works properly. + * Tests that Container::get() for non-existent services works properly. * * @covers ::get * @covers ::createService @@ -273,7 +273,7 @@ public function testGetForSerializedServiceDefinition() { } /** - * Tests that Container::get() for non-existant parameters works properly. + * Tests that Container::get() for non-existent parameters works properly. * * @covers ::get * @covers ::createService @@ -303,7 +303,7 @@ public function testGetForParameterDependencyWithExceptionOnSecondCall() { } /** - * Tests that Container::get() for non-existant parameters works properly. + * Tests that Container::get() for non-existent parameters works properly. * * @covers ::get * @covers ::createService @@ -328,7 +328,7 @@ public function testGetForNonExistantServiceDependency() { } /** - * Tests that Container::get() for non-existant dependencies works properly. + * Tests that Container::get() for non-existent dependencies works properly. * * @covers ::get * @covers ::createService @@ -342,7 +342,7 @@ public function testGetForNonExistantServiceDependencyWithException() { } /** - * Tests that Container::get() for non-existant services works properly. + * Tests that Container::get() for non-existent services works properly. * * @covers ::get * @covers ::createService diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index 62c9a35..5659108 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -585,7 +585,7 @@ protected function getParameterCall($name) { namespace Symfony\Component\ExpressionLanguage { if (!class_exists('\Symfony\Component\ExpressionLanguage\Expression')) { /** - * Dummy class to ensure non-existant Symfony component can be tested. + * Dummy class to ensure non-existent Symfony component can be tested. */ class Expression {