Skip to content

Commit

Permalink
Make Phpstan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel committed Mar 19, 2024
1 parent 551f8f6 commit a9849e2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Renderer/Block/HtmlBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s

// We ignore $node->getType() here, as we want to render all HTML blocks the same way.

/** @var string $htmlInput */
$htmlInput = $this->config->get('html_input');

return HtmlFilter::filter($node->getLiteral(), $htmlInput);
Expand Down
1 change: 1 addition & 0 deletions src/Renderer/Inline/HtmlInlineRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s
{
HtmlInline::assertInstanceOf($node);

/** @var string $htmlInput */
$htmlInput = $this->config->get('html_input');

return HtmlFilter::filter($node->getLiteral(), $htmlInput);
Expand Down
1 change: 1 addition & 0 deletions src/Renderer/Inline/ImageRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s
{
Image::assertInstanceOf($node);

/** @var array<string, string> $attrs */
$attrs = $node->data->get('attributes');

$forbidUnsafeLinks = ! $this->config->get('allow_unsafe_links');
Expand Down
1 change: 1 addition & 0 deletions src/Renderer/Inline/LinkRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s
{
Link::assertInstanceOf($node);

/** @var array<string, string> $attrs */
$attrs = $node->data->get('attributes');

$forbidUnsafeLinks = ! $this->config->get('allow_unsafe_links');
Expand Down
1 change: 1 addition & 0 deletions src/Renderer/Inline/NewlineRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer): s
return "\n";
}

/** @phpstan-var string */
return $this->config->get('renderer/soft_break');
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Renderer/MarkdownRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ public function renderNodes(iterable $nodes): string

public function getBlockSeparator(): string
{
/** @phpstan-var string */
return $this->environment->getConfiguration()->get('renderer/block_separator');
}

public function getInnerSeparator(): string
{
/** @phpstan-var string */
return $this->environment->getConfiguration()->get('renderer/inner_separator');
}
}
2 changes: 1 addition & 1 deletion tests/MarkdownRendererExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function test_markdown_renderer_extension_works(string $markdown, array $
}

/**
* @return iterable<array<mixed>>
* @return \Iterator
*/
public static function getTestData(): \Iterator
{
Expand Down
6 changes: 6 additions & 0 deletions tests/Renderer/Block/FencedCodeRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ protected function setUp(): void
$this->renderer = new FencedCodeRenderer();
}

/**
* @param array<int> $fencedArgs
*/
#[Test]
#[DataProvider('provide_fenced_code')]
public function it_renders_fenced_code(array $fencedArgs, string $expected): void
Expand All @@ -41,6 +44,9 @@ public function it_renders_fenced_code(array $fencedArgs, string $expected): voi
$this->assertEquals($expected, $result);
}

/**
* @return array<string, array<string, array<int, int|string>|string>>
*/
public function provide_fenced_code(): array
{
return [
Expand Down
2 changes: 2 additions & 0 deletions tests/Renderer/MarkdownRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function it_renders_ast_to_markdown(): void
#[Test]
public function it_parses_and_renders_kitchen_sink(): void
{
/** @var string $contentKitchenSink */
$contentKitchenSink = file_get_contents(__DIR__ . '/../stubs/kitchen-sink.md');
$contentKitchenSinkExpected = file_get_contents(__DIR__ . '/../stubs/kitchen-sink-expected.md');

Expand All @@ -53,6 +54,7 @@ public function it_parses_and_renders_kitchen_sink(): void
#[Test]
public function it_parses_kitchen_sink_and_parsing_the_result_again_returns_the_same_result(): void
{
/** @var string $contentKitchenSink */
$contentKitchenSink = file_get_contents(__DIR__ . '/../stubs/kitchen-sink.md');
$contentKitchenSinkExpected = file_get_contents(__DIR__ . '/../stubs/kitchen-sink-expected.md');

Expand Down

0 comments on commit a9849e2

Please sign in to comment.