Verified Commit 6a60affd authored by Jess's avatar Jess
Browse files

fix: #3634044 symfony/error-handler 8.1.10 - DrupalDebugClassLoader throws...

fix: #3634044 symfony/error-handler 8.1.10 - DrupalDebugClassLoader throws TypeError when Symfony records NULL metadata for generic return types

By: joelpittet
By: longwave
By: xjm
(cherry picked from commit 6dca401f9c99261e44025e499fa1db17d484af5c)
parent fdce680b
Loading
Loading
Loading
Loading
Loading
+8
Changes for core/tests/Drupal/TestTools/ErrorHandler/DrupalDebugClassLoader.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -58,6 +58,14 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array {
      : $class;

    foreach ($returnTypes as $method => $returnTypeData) {
      // PHPDoc template return types have no equivalent native PHP type. Symfony
      // stores NULL to stop child classes from inheriting return type data from
      // their interfaces. Skip this entry. It has no return type or declaring
      // class for the cross-extension deprecation check.
      // @see \Symfony\Component\ErrorHandler\DebugClassLoader::setReturnType()
      if ($returnTypeData === NULL) {
        continue;
      }
      [$normalizedType, , $declaringClass] = $returnTypeData;

      // Skip if no cross-extension boundary: empty declaring class (magic
+1
Changes for core/tests/Drupal/Tests/TestTools/ErrorHandler/DrupalDebugClassLoaderTest.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public function testCrossModuleReturnTypeDeprecation(): void {
  #[TestWith(['Drupal\drupal_debug_test_other\ChildWithReturnAnnotation'])]
  #[TestWith(['Drupal\drupal_debug_test_other\ChildWithDeprecatedMethod'])]
  #[TestWith(['Drupal\drupal_debug_test_other\ChildWithoutOverride'])]
  #[TestWith(['Drupal\drupal_debug_test_core\ClassWithGenericReturn'], 'generic return type')]
  public function testNoDeprecation(string $class): void {
    $this->assertEmpty($this->getReturnTypeDeprecations($class));
  }
+20
Changes for core/tests/fixtures/TestTools/drupal_debug_classloader_test_classes.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -42,6 +42,26 @@ public function testMethod() {

}

/**
 * Fixture: class with a generic PHPDoc return type.
 */
class ClassWithGenericReturn {

  /**
   * @template TRuntime of object
   *
   * @param class-string<TRuntime> $class
   *   The runtime class name.
   *
   * @return TRuntime
   *   The runtime instance.
   */
  public function getRuntime(string $class) {
    return new $class();
  }

}

namespace Drupal\drupal_debug_test_other;

use Drupal\drupal_debug_test_core\ParentWithReturn;