diff --git a/core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php b/core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php index f79ce9d4ad..0f857dba98 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/FrontMatterTest.php @@ -6,6 +6,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\Component\FrontMatter\FrontMatterTest as ComponentFrontMatterTest; use Symfony\Component\DependencyInjection\Definition; +use Twig\Error\Error; use Twig\Error\SyntaxError; /** @@ -56,7 +57,7 @@ public function register(ContainerBuilder $container) { * @return string * The absolute path to the temporary file. */ - protected function createTwigTemplate($content = '') { + protected function createTwigTemplate(string $content = ''): string { $file = tempnam(sys_get_temp_dir(), 'twig') . ".html.twig"; file_put_contents($file, $content); return $file; @@ -113,7 +114,7 @@ public function testFrontMatter($yaml, $line, $content = ComponentFrontMatterTes try { $this->twig->load($name); } - catch (\Twig_Error $error) { + catch (Error $error) { $this->assertEquals($line, $error->getTemplateLine()); } @@ -121,7 +122,7 @@ public function testFrontMatter($yaml, $line, $content = ComponentFrontMatterTes try { $this->twig->createTemplate($source)->render(); } - catch (\Twig_Error $error) { + catch (Error $error) { $this->assertEquals($line, $error->getTemplateLine()); } } diff --git a/core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php b/core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php index 090d5914c0..03bde3f57e 100644 --- a/core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php +++ b/core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php @@ -24,7 +24,7 @@ class FrontMatterTest extends TestCase { /** * Creates a front matter source string. * - * @param array|null $yaml + * @param array $yaml * The YAML array to prepend as a front matter block. * @param string $content * The source contents. @@ -32,7 +32,7 @@ class FrontMatterTest extends TestCase { * @return string * The new source. */ - public static function createFrontMatterSource($yaml = [], $content = self::SOURCE) { + public static function createFrontMatterSource(array $yaml = [], string $content = self::SOURCE): string { // Encode YAML and wrap in a front matter block. $frontMatter = ''; if (is_array($yaml)) { @@ -49,7 +49,7 @@ public static function createFrontMatterSource($yaml = [], $content = self::SOUR * @covers ::create */ public function testFrontMatterSerializerException() { - $this->expectException('AssertionError'); + $this->expectException(\AssertionError::class); $this->expectExceptionMessage('The $serializer parameter must reference a class that implements Drupal\Component\Serialization\SerializationInterface.'); FrontMatter::create('', ''); }