From c25d39f3b38c4562b94243664651cff0710f95c6 Mon Sep 17 00:00:00 2001 From: Lexidor Digital <31805625+lexidor@users.noreply.github.com> Date: Mon, 13 Jan 2020 17:38:47 +0100 Subject: [PATCH] disallow_array_literal (#10) * disallow_array_literal * Mismatched (v)array return type * Allow array literals because of required hhvm 4.18 support --- src/inlines/AutoLinkExtension.php | 2 +- src/inlines/RawHTML.php | 2 +- src/render/MarkdownRenderer.php | 2 +- tests/EdgeCaseTest.php | 4 ++-- tests/SpecTest.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/inlines/AutoLinkExtension.php b/src/inlines/AutoLinkExtension.php index 963e860..db4844c 100644 --- a/src/inlines/AutoLinkExtension.php +++ b/src/inlines/AutoLinkExtension.php @@ -43,7 +43,7 @@ public static function consume( $string = Str\slice($markdown, $offset); - $matches = []; + $matches = darray[]; $result = \preg_match_with_matches( '/^(?'.self::PREFIX.')(?'.self::DOMAIN.')/i', $string, diff --git a/src/inlines/RawHTML.php b/src/inlines/RawHTML.php index 26c7c7b..07bdaac 100644 --- a/src/inlines/RawHTML.php +++ b/src/inlines/RawHTML.php @@ -53,7 +53,7 @@ public static function consume( $slice = Str\slice($string, $offset); - $matches = []; + $matches = darray[]; if ( \preg_match_with_matches( '/^('.self::OPEN_TAG.'|'.self::CLOSING_TAG.'|'.self::DECLARATION.')/i', diff --git a/src/render/MarkdownRenderer.php b/src/render/MarkdownRenderer.php index b688601..f46b6b8 100644 --- a/src/render/MarkdownRenderer.php +++ b/src/render/MarkdownRenderer.php @@ -314,7 +314,7 @@ protected function renderInlineWithPlainTextContent( return \mb_encode_numericentity( $node->getContent(), // start, end, offset, mask - [0, 0xffff, 0, 0xffff], + varray[0, 0xffff, 0, 0xffff], 'UTF-8', ); } diff --git a/tests/EdgeCaseTest.php b/tests/EdgeCaseTest.php index 2293b2d..b98b881 100644 --- a/tests/EdgeCaseTest.php +++ b/tests/EdgeCaseTest.php @@ -15,8 +15,8 @@ final class EdgeCaseTest extends TestCase { public function getManualExamples( - ): array<(string, string)> { - return [ + ): varray<(string, string)> { + return varray[ tuple("- foo\n\n", "\n"), tuple("- foo\n\n\n", "\n"), tuple( diff --git a/tests/SpecTest.php b/tests/SpecTest.php index 1423851..463aa96 100644 --- a/tests/SpecTest.php +++ b/tests/SpecTest.php @@ -21,7 +21,7 @@ final class SpecTest extends TestCase { // Sanity check - make sure it matches the last one in the spec const int EXAMPLE_COUNT = 649; - public function getSpecExamples(): array<(string, string, string, ?string)> { + public function getSpecExamples(): varray<(string, string, string, ?string)> { $text = \file_get_contents(__DIR__.'/../third-party/spec.txt'); $raw_examples = vec[]; $offset = 0; @@ -45,7 +45,7 @@ public function getSpecExamples(): array<(string, string, string, ?string)> { $offset = $end + Str\length(self::EXAMPLE_END); } - $examples = []; + $examples = varray[]; foreach ($raw_examples as list($example, $extension)) { $parts = Str\split($example, "\n.\n");