The last submitted patch, 38: 2652694-38.patch, failed testing. View results β
- Status changed to Needs work
almost 2 years ago 7:27am 10 April 2023 - π¨πSwitzerland stefanos.petrakis@gmail.com Biel, Switzerland
IMO the change in the exception message from #37 to #38
- does not implement $interface, or its namespace cannot be resolved.
+ does not have an existing class $interface.
is restoring some confusion to the dev/reader, i.e. it does little to inform that the providedclass:
for the collected service does not exist. The$interface
variable will be generated based on the service collector's definition and not the collected service.Even more, the actual change in code could focus explicitly on this case, e.g.:
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandl ersPass.php @@ -178,6 +178,9 @@ protected function processServiceCollectorPass( array $pass, $consumer_id, Contai foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { // Validate the interface. $handler = $container->getDefinition($id); + if (class_exists($handler->getClass()) === FALSE) { + throw new LogicException("Service '$id' for consumer '$con sumer_id' does not have a corresponding existing class " . $handler ->getClass()); + } if (!is_subclass_of($handler->getClass(), $interface)) { throw new LogicException("Service '$id' for consumer '$con sumer_id' does not implement $interface."); }
That would mean a small change in the first one of the new tests to capture the new exception for non-existing classes.
And a small change in the second test, if we stick to the original exception message (Service '$id' for consumer '$consumer_id' does not implement $interface.