From 0f009ade785e30361dfa066497c8e4878565ac29 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 26 Apr 2025 22:09:19 +1000 Subject: [PATCH 1/9] Update PHP and required packages to the latest versions This change updates the Composer configuration to only support PHP 8.2, 8.3, and 8.4, and then updates the relevant packages to the latest version that supports at least PHP 8.2 as well. Along with that, it updates PHPUnit to version 11 as it's the latest version that at least supports PHP 8.2. --- composer.json | 6 +++--- phpunit.xml.dist | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index aaa7372..423ece6 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ } }, "require": { - "php": "^7.4|^8.0", - "symfony/yaml": "^4.0|^5.0|^6.0|^7.0", + "php": "^8.2||^8.3||^8.4", + "symfony/yaml": "^7.0", "league/commonmark": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^11.0" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 93a96e8..b9122d8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,15 +2,18 @@ - + From 803e15885ceba90798856ea325332c4d97cedc81 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 26 Apr 2025 22:11:22 +1000 Subject: [PATCH 2/9] Remove deprecated code This change removes usage of deprecated code in the codebase, either replacing it with the recommended replacement, or the standard replacement. So, MarkdownConverterInterface was replaced with the recommended replacement of ConverterInterface, and the applicable function call was replaced. Then, getMockForAbstractClass, which is deprecated without replacement in PHPUnit 12 was replaced with createMock. --- src/Bridge/CommonMark/CommonMarkParser.php | 8 +++---- tests/ParserTest.php | 28 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Bridge/CommonMark/CommonMarkParser.php b/src/Bridge/CommonMark/CommonMarkParser.php index b1fc2c0..7c94ada 100644 --- a/src/Bridge/CommonMark/CommonMarkParser.php +++ b/src/Bridge/CommonMark/CommonMarkParser.php @@ -3,7 +3,7 @@ namespace Mni\FrontYAML\Bridge\CommonMark; use League\CommonMark\CommonMarkConverter; -use League\CommonMark\MarkdownConverterInterface; +use League\CommonMark\ConverterInterface; use Mni\FrontYAML\Markdown\MarkdownParser; /** @@ -11,15 +11,15 @@ */ class CommonMarkParser implements MarkdownParser { - private MarkdownConverterInterface $parser; + private ConverterInterface|null $parser; - public function __construct(MarkdownConverterInterface $commonMarkConverter = null) + public function __construct(ConverterInterface|null $commonMarkConverter = null) { $this->parser = $commonMarkConverter ?: new CommonMarkConverter; } public function parse(string $markdown): string { - return $this->parser->convertToHtml($markdown)->getContent(); + return $this->parser->convert($markdown)->getContent(); } } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 056902d..b657361 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -71,13 +71,13 @@ public function testParseFrontYAMLPregMatchDelimiter() public function testParseYAML() { - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->once()) ->method('parse') ->with('foo') ->willReturn('bar'); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->never()) ->method('parse'); @@ -97,13 +97,13 @@ public function testParseYAML() public function testParseYAMLMarkdown() { - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->once()) ->method('parse') ->with('foo') ->willReturn('bar'); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->once()) ->method('parse') ->with('bim') @@ -125,11 +125,11 @@ public function testParseYAMLMarkdown() public function testParseMarkdownNoYAML1Line() { - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->never()) ->method('parse'); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->once()) ->method('parse') ->with('bim') @@ -148,11 +148,11 @@ public function testParseMarkdownNoYAML1Line() public function testParseMarkdownNoYAML2Lines() { - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->never()) ->method('parse'); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->once()) ->method('parse') ->willReturn('foo'); @@ -171,9 +171,9 @@ public function testParseMarkdownNoYAML2Lines() public function testMarkdownParserNotCalled() { - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->never()) ->method('parse'); @@ -185,13 +185,13 @@ public function testParseFrontYAMLEdgeCaseDelimiters() { $start = '*_-\)``.|.``(/-_*'; $end = '--({@}{._.}{@})--'; - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->once()) ->method('parse') ->with('foo: bar') ->willReturn(['foo' => 'bar']); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->never()) ->method('parse'); @@ -211,13 +211,13 @@ public function testParseFrontYAMLArrayDelimiters() { $start = ['---','']; - $yamlParser = $this->getMockForAbstractClass(YAMLParser::class); + $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->exactly(2)) ->method('parse') ->with('foo: bar') ->willReturn(['foo' => 'bar']); - $markdownParser = $this->getMockForAbstractClass(MarkdownParser::class); + $markdownParser = $this->createMock(MarkdownParser::class); $markdownParser->expects($this->never()) ->method('parse'); From cd4c2dd60551cba4ae182dfc0abd5acd1f61a97a Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 26 Apr 2025 22:13:29 +1000 Subject: [PATCH 3/9] Add complete type support This change makes explicit use of types throughout the codebase wherever they were missing. In addition, it uses union types for nulls, as that's required in PHP 8.4. --- src/Bridge/Symfony/SymfonyYAMLParser.php | 2 +- src/Document.php | 7 +++---- src/Parser.php | 14 ++++---------- src/YAML/YAMLParser.php | 4 +--- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/Bridge/Symfony/SymfonyYAMLParser.php b/src/Bridge/Symfony/SymfonyYAMLParser.php index bf22d88..940d8cc 100644 --- a/src/Bridge/Symfony/SymfonyYAMLParser.php +++ b/src/Bridge/Symfony/SymfonyYAMLParser.php @@ -17,7 +17,7 @@ public function __construct() $this->parser = new Parser; } - public function parse(string $yaml) + public function parse(string $yaml): mixed { return $this->parser->parse($yaml); } diff --git a/src/Document.php b/src/Document.php index 4af4e8d..5df9973 100644 --- a/src/Document.php +++ b/src/Document.php @@ -4,8 +4,7 @@ class Document { - /** @var mixed */ - private $yaml; + private mixed $yaml; private string $content; @@ -13,7 +12,7 @@ class Document * @param mixed $yaml YAML content. * @param string $content Content of the document. */ - public function __construct($yaml, string $content) + public function __construct(mixed $yaml, string $content) { $this->yaml = $yaml; $this->content = $content; @@ -22,7 +21,7 @@ public function __construct($yaml, string $content) /** * @return mixed YAML content. */ - public function getYAML() + public function getYAML(): mixed { return $this->yaml; } diff --git a/src/Parser.php b/src/Parser.php index 2aa7fd4..ab7a987 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -12,15 +12,9 @@ */ class Parser { - /** - * @var YAMLParser - */ - private $yamlParser; + private YAMLParser|null $yamlParser; - /** - * @var MarkdownParser - */ - private $markdownParser; + private MarkdownParser|null $markdownParser; private array $startSep; @@ -31,8 +25,8 @@ class Parser * @param string|string[] $endSep */ public function __construct( - ?YAMLParser $yamlParser = null, - ?MarkdownParser $markdownParser = null, + YAMLParser|null $yamlParser = null, + MarkdownParser|null $markdownParser = null, $startSep = '---', $endSep = '---' ) { diff --git a/src/YAML/YAMLParser.php b/src/YAML/YAMLParser.php index 0b4c6c2..4e53efc 100644 --- a/src/YAML/YAMLParser.php +++ b/src/YAML/YAMLParser.php @@ -9,8 +9,6 @@ interface YAMLParser { /** * Parses a YAML string. - * - * @return mixed */ - public function parse(string $yaml); + public function parse(string $yaml): mixed; } From ec93b3c45e5dccf17683c482d5b39e0830ed828e Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 26 Apr 2025 22:18:33 +1000 Subject: [PATCH 4/9] Update the GitHub Workflow This change updates the GitHub Workflow to support only PHP 8.2 - 8.4. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e81e5ba..27c7746 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.4', '8.0'] + php-versions: ['8.2', '8.3', '8.4'] name: PHP ${{ matrix.php-versions }} steps: - uses: actions/checkout@v2 From 567a89da0a14271bd761644020c1bac69bbff9c7 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Sat, 26 Apr 2025 22:29:33 +1000 Subject: [PATCH 5/9] Update actions/cache to v4 On attempting to run the workflow, I encountered the following error: "Missing download info for actions/cache@v2". After some searching on the error, the recommended fix was to update from version 2 to 4. So, this change is being made to test the solution and, all being well, correct the issue. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27c7746..f58f53f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: composer-${{ hashFiles('**/composer.json') }} From 63175325ddbc725a0e2255228fe3b797878a0983 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Mon, 28 Apr 2025 18:16:57 +1000 Subject: [PATCH 6/9] Revert addition of union type in Parser As was pointed out by @mnapoli, https://github.com/mnapoli/FrontYAML/pull/32/files#r2061309338, yamlParser and markdownParser should not be allowed to be null. So, this change removes that, specific, part of cd4c2dd. --- src/Parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index ab7a987..0fc62b9 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -12,9 +12,9 @@ */ class Parser { - private YAMLParser|null $yamlParser; + private YAMLParser $yamlParser; - private MarkdownParser|null $markdownParser; + private MarkdownParser $markdownParser; private array $startSep; From 7f27a4c25ee0b174b5790af6dec236c9c4c5a38a Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Mon, 28 Apr 2025 18:20:55 +1000 Subject: [PATCH 7/9] Revert allowing CommonMarkParser::parser to be null This reverts the change to CommonMarkParser in 803e1588 allowing $parser to be both null and an instance of ConverterInterface, as pointed out by @mnapoli in https://github.com/mnapoli/FrontYAML/pull/32#discussion_r2062635303. --- src/Bridge/CommonMark/CommonMarkParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridge/CommonMark/CommonMarkParser.php b/src/Bridge/CommonMark/CommonMarkParser.php index 7c94ada..b271fed 100644 --- a/src/Bridge/CommonMark/CommonMarkParser.php +++ b/src/Bridge/CommonMark/CommonMarkParser.php @@ -11,7 +11,7 @@ */ class CommonMarkParser implements MarkdownParser { - private ConverterInterface|null $parser; + private ConverterInterface $parser; public function __construct(ConverterInterface|null $commonMarkConverter = null) { From 286d13256af3f3dcad751b6fef60792b8ffb7bb5 Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Fri, 10 Oct 2025 21:43:39 +1000 Subject: [PATCH 8/9] Revert BC break in CommonMarkParser Thank you to @mnapoli for pointing out that the original change would have been a BC break. --- src/Bridge/CommonMark/CommonMarkParser.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Bridge/CommonMark/CommonMarkParser.php b/src/Bridge/CommonMark/CommonMarkParser.php index b271fed..dd90e8b 100644 --- a/src/Bridge/CommonMark/CommonMarkParser.php +++ b/src/Bridge/CommonMark/CommonMarkParser.php @@ -1,25 +1,27 @@ -parser = $commonMarkConverter ?: new CommonMarkConverter; + $this->parser = $commonMarkConverter ?: new CommonMarkConverter(); } public function parse(string $markdown): string { - return $this->parser->convert($markdown)->getContent(); + return $this->parser?->convertToHtml($markdown)?->getContent() ?? ''; } } From ea7f166717e20e384aa8eeb46f30d3747e519ecc Mon Sep 17 00:00:00 2001 From: Matthew Setter Date: Fri, 10 Oct 2025 21:52:03 +1000 Subject: [PATCH 9/9] Continue adding type support This change continues adding type declarations, where applicable, both in source and test code, and makes a few minor style changes. --- src/Bridge/Symfony/SymfonyYAMLParser.php | 4 +- src/Document.php | 2 +- src/Parser.php | 28 ++++++++------ .../CommonMark/CommonMarkParserTest.php | 8 ++-- tests/FunctionalTest.php | 32 ++++++++-------- tests/ParserTest.php | 38 ++++++++++--------- 6 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/Bridge/Symfony/SymfonyYAMLParser.php b/src/Bridge/Symfony/SymfonyYAMLParser.php index 940d8cc..b186ebc 100644 --- a/src/Bridge/Symfony/SymfonyYAMLParser.php +++ b/src/Bridge/Symfony/SymfonyYAMLParser.php @@ -8,13 +8,13 @@ /** * Bridge to the Symfony YAML parser */ -class SymfonyYAMLParser implements YAMLParser +final class SymfonyYAMLParser implements YAMLParser { private Parser $parser; public function __construct() { - $this->parser = new Parser; + $this->parser = new Parser(); } public function parse(string $yaml): mixed diff --git a/src/Document.php b/src/Document.php index 5df9973..a80e159 100644 --- a/src/Document.php +++ b/src/Document.php @@ -2,7 +2,7 @@ namespace Mni\FrontYAML; -class Document +final class Document { private mixed $yaml; diff --git a/src/Parser.php b/src/Parser.php index 0fc62b9..8efdfd1 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -7,10 +7,18 @@ use Mni\FrontYAML\Markdown\MarkdownParser; use Mni\FrontYAML\YAML\YAMLParser; +use function array_filter; +use function array_map; +use function implode; +use function ltrim; +use function preg_match; +use function preg_quote; +use function trim; + /** * YAML Front matter parser */ -class Parser +final class Parser { private YAMLParser $yamlParser; @@ -20,20 +28,16 @@ class Parser private array $endSep; - /** - * @param string|string[] $startSep - * @param string|string[] $endSep - */ public function __construct( YAMLParser|null $yamlParser = null, MarkdownParser|null $markdownParser = null, - $startSep = '---', - $endSep = '---' + string|array $startSep = '---', + string|array $endSep = '---' ) { - $this->yamlParser = $yamlParser ?: new SymfonyYAMLParser; - $this->markdownParser = $markdownParser ?: new CommonMarkParser; - $this->startSep = array_filter((array) $startSep, 'is_string') ?: ['---']; - $this->endSep = array_filter((array) $endSep, 'is_string') ?: ['---']; + $this->yamlParser = $yamlParser ?? new SymfonyYAMLParser(); + $this->markdownParser = $markdownParser ?? new CommonMarkParser(); + $this->startSep = array_filter((array) $startSep, 'is_string') ?: ['---']; + $this->endSep = array_filter((array) $endSep, 'is_string') ?: ['---']; } /** @@ -45,7 +49,7 @@ public function parse(string $str, bool $parseMarkdown = true): Document { $yaml = null; - $quote = static function ($str) { + $quote = static function (string $str): string { return preg_quote($str, "~"); }; diff --git a/tests/Bridge/CommonMark/CommonMarkParserTest.php b/tests/Bridge/CommonMark/CommonMarkParserTest.php index ae2998b..14ab83c 100644 --- a/tests/Bridge/CommonMark/CommonMarkParserTest.php +++ b/tests/Bridge/CommonMark/CommonMarkParserTest.php @@ -10,7 +10,7 @@ class CommonMarkParserTest extends TestCase { - public function testParseWithDefaultParser() + public function testParseWithDefaultParser(): void { $parser = new CommonMarkParser(); @@ -19,10 +19,10 @@ public function testParseWithDefaultParser() $this->assertSame("

This is a title

\n", $html); } - public function testParseWithCustomParser() + public function testParseWithCustomParser(): void { - $environment = new Environment; - $environment->addExtension(new CommonMarkCoreExtension); + $environment = new Environment(); + $environment->addExtension(new CommonMarkCoreExtension()); $converter = new MarkdownConverter($environment); $parser = new CommonMarkParser($converter); diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index c518cf4..ffb6e48 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -5,11 +5,13 @@ use Mni\FrontYAML\Parser; use PHPUnit\Framework\TestCase; -class FunctionalTest extends TestCase +use function str_replace; + +final class FunctionalTest extends TestCase { - public function testSimpleDocument() + public function testSimpleDocument(): void { - $parser = new Parser; + $parser = new Parser(); $str = <<assertSame("

This strong

\n", $document->getContent()); } - public function testEscaping() + public function testEscaping(): void { - $parser = new Parser; + $parser = new Parser(); $str = <<assertSame("

Foo

\n", $document->getContent()); } - public function testMultilineMarkdown() + public function testMultilineMarkdown(): void { - $parser = new Parser; - $str = <<assertEquals($this->normalizeEOL($expected), $this->normalizeEOL($document->getContent())); } - public function testCrossOsMultiline() + public function testCrossOsMultiline(): void { - $parser = new Parser; + $parser = new Parser(); $content = <<assertSame($this->normalizeEOL($expectedHtml), $this->normalizeEOL($dosYaml['multiline'])); } - public function testNonGreedySeparator() + public function testNonGreedySeparator(): void { - $parser = new Parser; - $content = <<parse($content); - $this->assertSame(array('lorem' => 'ipsum'), $document->getYAML()); + $this->assertSame(['lorem' => 'ipsum'], $document->getYAML()); } - private function normalizeEOL($str) + private function normalizeEOL(string $str): string|array { return str_replace("\r", '', $str); } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index b657361..2e54fc2 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -2,14 +2,16 @@ namespace Mni\FrontYAML\Test; +use Mni\FrontYAML\Markdown\MarkdownParser; use Mni\FrontYAML\Parser; -use PHPUnit\Framework\TestCase; use Mni\FrontYAML\YAML\YAMLParser; -use Mni\FrontYAML\Markdown\MarkdownParser; +use PHPUnit\Framework\TestCase; + +use function trim; -class ParserTest extends TestCase +final class ParserTest extends TestCase { - public function testParseEmptyString() + public function testParseEmptyString(): void { $parser = new Parser(); $document = $parser->parse('', false); @@ -17,7 +19,7 @@ public function testParseEmptyString() $this->assertSame('', $document->getContent()); } - public function testParseNoYAML() + public function testParseNoYAML(): void { $parser = new Parser(); $document = $parser->parse('foo', false); @@ -25,7 +27,7 @@ public function testParseNoYAML() $this->assertSame('foo', $document->getContent()); } - public function testParseNoYAML2() + public function testParseNoYAML2(): void { $parser = new Parser(); $str = <<assertSame($str, $document->getContent()); } - public function testParseFrontYAMLDelimiter() + public function testParseFrontYAMLDelimiter(): void { $parser = new Parser(); $document = $parser->parse('---', false); @@ -45,7 +47,7 @@ public function testParseFrontYAMLDelimiter() $this->assertSame('---', $document->getContent()); } - public function testParseFrontYAMLDelimiters() + public function testParseFrontYAMLDelimiters(): void { $parser = new Parser(); $str = <<assertSame('', $document->getContent()); } - public function testParseFrontYAMLPregMatchDelimiter() + public function testParseFrontYAMLPregMatchDelimiter(): void { $parser = new Parser(null, null, '~', '~'); $str = <<assertSame('', $document->getContent()); } - public function testParseYAML() + public function testParseYAML(): void { $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->once()) @@ -95,7 +97,7 @@ public function testParseYAML() $this->assertSame('bim', $document->getContent()); } - public function testParseYAMLMarkdown() + public function testParseYAMLMarkdown(): void { $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->once()) @@ -123,7 +125,7 @@ public function testParseYAMLMarkdown() $this->assertSame('bam', $document->getContent()); } - public function testParseMarkdownNoYAML1Line() + public function testParseMarkdownNoYAML1Line(): void { $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->never()) @@ -146,7 +148,7 @@ public function testParseMarkdownNoYAML1Line() $this->assertSame('bam', $document->getContent()); } - public function testParseMarkdownNoYAML2Lines() + public function testParseMarkdownNoYAML2Lines(): void { $yamlParser = $this->createMock(YAMLParser::class); $yamlParser->expects($this->never()) @@ -169,7 +171,7 @@ public function testParseMarkdownNoYAML2Lines() $this->assertSame('foo', $document->getContent()); } - public function testMarkdownParserNotCalled() + public function testMarkdownParserNotCalled(): void { $yamlParser = $this->createMock(YAMLParser::class); @@ -181,7 +183,7 @@ public function testMarkdownParserNotCalled() $parser->parse('foo', false); } - public function testParseFrontYAMLEdgeCaseDelimiters() + public function testParseFrontYAMLEdgeCaseDelimiters(): void { $start = '*_-\)``.|.``(/-_*'; $end = '--({@}{._.}{@})--'; @@ -203,11 +205,11 @@ public function testParseFrontYAMLEdgeCaseDelimiters() bim EOF; $document = $parser->parse($str, false); - $this->assertSame(array('foo' => 'bar'), $document->getYAML()); + $this->assertSame(['foo' => 'bar'], $document->getYAML()); $this->assertSame('bim', trim($document->getContent())); } - public function testParseFrontYAMLArrayDelimiters() + public function testParseFrontYAMLArrayDelimiters(): void { $start = ['---','']; @@ -236,7 +238,7 @@ public function testParseFrontYAMLArrayDelimiters() EOF; $document1 = $parser->parse($str1, false); $document2 = $parser->parse($str2, false); - $this->assertSame(array('foo' => 'bar'), $document1->getYAML()); + $this->assertSame(['foo' => 'bar'], $document1->getYAML()); $this->assertSame('bim', trim($document1->getContent())); $this->assertSame($document1->getYAML(), $document2->getYAML()); $this->assertSame($document1->getContent(), $document2->getContent());