Verified Commit cf771503 authored by Andrei Mateescu's avatar Andrei Mateescu
Browse files

task: #3578630 Check that services definitions match their argument count

By: longwave
By: smustgrave
parent 34fee670
Loading
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -62,6 +62,12 @@ public function testCoreServiceAliases(): void {
          $aliases[$id] = substr($service, 1);
        }
        elseif (isset($service['class']) && class_exists($service['class'])) {
          // Check that the number of arguments matches the constructor.
          if (isset($service['arguments'])) {
            $constructor = new \ReflectionMethod($service['class'], '__construct');
            $this->assertLessThanOrEqual($constructor->getNumberOfParameters(), count($service['arguments']), sprintf('%s (%s): %d arguments defined, but constructor only accepts %d', $id, $service['class'], count($service['arguments']), $constructor->getNumberOfParameters()));
          }

          // Ignore services named by their own class.
          if ($id === $service['class']) {
            continue;