Skip to content

Commit 4865433

Browse files
committed
Remove useless docblocks + use native types
1 parent 82ca3d0 commit 4865433

39 files changed

+85
-372
lines changed

src/CliRenderer.php

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,26 @@
99
use League\CommonMark\Inline\Element\AbstractInline;
1010
use RuntimeException;
1111

12-
/**
13-
* Class CliRenderer
14-
* @package PhpWorkshop\PhpWorkshop\Md
15-
* @author Aydin Hassan <aydin@hotmail.co.uk>
16-
*/
1712
class CliRenderer
1813
{
19-
2014
/**
21-
* @var CliBlockRendererInterface[]
15+
* @var array<CliBlockRendererInterface>
2216
*/
23-
private $renderers = [];
17+
private $renderers;
2418

2519
/**
26-
* @var CliInlineRendererInterface[]
20+
* @var array<CliInlineRendererInterface>
2721
*/
28-
private $inlineRenderers = [];
22+
private $inlineRenderers;
2923

3024
/**
3125
* @var Color
3226
*/
3327
private $color;
3428

3529
/**
36-
* @param CliBlockRendererInterface[] $renderers
37-
* @param CliInlineRendererInterface[] $inlineRenderers
30+
* @param array<CliBlockRendererInterface> $renderers
31+
* @param array<CliInlineRendererInterface> $inlineRenderers
3832
* @param Color $color
3933
*/
4034
public function __construct(array $renderers, array $inlineRenderers, Color $color)
@@ -49,9 +43,8 @@ public function __construct(array $renderers, array $inlineRenderers, Color $col
4943
* @param array<string>|string $colourOrStyle
5044
*
5145
* @return string
52-
*
5346
*/
54-
public function style($string, $colourOrStyle)
47+
public function style(string $string, $colourOrStyle): string
5548
{
5649
if (is_array($colourOrStyle)) {
5750
$this->color->__invoke($string);
@@ -70,7 +63,7 @@ public function style($string, $colourOrStyle)
7063
*
7164
* @return string
7265
*/
73-
public function renderInlines(array $inlines)
66+
public function renderInlines(array $inlines): string
7467
{
7568
return implode(
7669
"",
@@ -90,14 +83,7 @@ function (AbstractInline $inline) {
9083
);
9184
}
9285

93-
/**
94-
* @param AbstractBlock $block
95-
*
96-
* @throws RuntimeException
97-
*
98-
* @return string
99-
*/
100-
public function renderBlock(AbstractBlock $block)
86+
public function renderBlock(AbstractBlock $block): string
10187
{
10288
$renderer = $this->getBlockRendererForClass(get_class($block));
10389
if (!$renderer) {
@@ -114,7 +100,7 @@ public function renderBlock(AbstractBlock $block)
114100
*
115101
* @return string
116102
*/
117-
public function renderBlocks(array $blocks)
103+
public function renderBlocks(array $blocks): string
118104
{
119105
return implode(
120106
"\n",
@@ -128,11 +114,10 @@ function (AbstractBlock $block) {
128114
}
129115

130116
/**
131-
* @param string $inlineBlockClass
132-
*
133-
* @return null|CliInlineRendererInterface
117+
* @param class-string $inlineBlockClass
118+
* @return CliInlineRendererInterface|null
134119
*/
135-
private function getInlineRendererForClass($inlineBlockClass)
120+
private function getInlineRendererForClass(string $inlineBlockClass): ?CliInlineRendererInterface
136121
{
137122
if (!isset($this->inlineRenderers[$inlineBlockClass])) {
138123
return null;
@@ -142,11 +127,11 @@ private function getInlineRendererForClass($inlineBlockClass)
142127
}
143128

144129
/**
145-
* @param string $blockClass
130+
* @param class-string $blockClass
146131
*
147-
* @return null|CliBlockRendererInterface
132+
* @return CliBlockRendererInterface|null
148133
*/
149-
private function getBlockRendererForClass($blockClass)
134+
private function getBlockRendererForClass($blockClass): ?CliBlockRendererInterface
150135
{
151136
if (!isset($this->renderers[$blockClass])) {
152137
return null;

src/CliRendererFactory.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,9 @@
3434
use League\CommonMark\Inline\Element\Strong;
3535
use League\CommonMark\Inline\Element\Newline;
3636

37-
/**
38-
* Class CliRendererFactory
39-
* @package AydinHassan\CliMdRenderer
40-
* @author Aydin Hassan <aydin@hotmail.co.uk>
41-
*/
4237
class CliRendererFactory
4338
{
44-
/**
45-
* @return CliRenderer
46-
*/
47-
public function __invoke()
39+
public function __invoke(): CliRenderer
4840
{
4941

5042
$codeRender = new FencedCodeRenderer();

src/Highlighter/PhpHighlighter.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,19 @@
77
use Kadet\Highlighter\KeyLighter;
88
use Kadet\Highlighter\Language\Php;
99

10-
/**
11-
* @author Aydin Hassan <aydin@hotmail.co.uk>
12-
*/
1310
class PhpHighlighter implements SyntaxHighlighterInterface
1411
{
15-
1612
/**
1713
* @var KeyLighter
1814
*/
1915
private $keyLighter;
2016

21-
/**
22-
* @param KeyLighter $keyLighter
23-
*/
2417
public function __construct(KeyLighter $keyLighter)
2518
{
2619
$this->keyLighter = $keyLighter;
2720
}
2821

29-
/**
30-
* @param string $code
31-
* @return string
32-
*/
33-
public function highlight($code)
22+
public function highlight(string $code): string
3423
{
3524
return $this->keyLighter->highlight($code, new Php(), new CliFormatter());
3625
}

src/InlineRenderer/CliInlineRendererInterface.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,7 @@
55
use League\CommonMark\Inline\Element\AbstractInline;
66
use AydinHassan\CliMdRenderer\CliRenderer;
77

8-
/**
9-
* Interface CliInlineRendererInterface
10-
* @package PhpWorkshop\PhpWorkshop\Md\InlineRenderer
11-
* @author Aydin Hassan <aydin@hotmail.co.uk>
12-
*/
138
interface CliInlineRendererInterface
149
{
15-
16-
/**
17-
* @param AbstractInline $inline
18-
* @param CliRenderer $renderer
19-
*
20-
* @return string
21-
*/
22-
public function render(AbstractInline $inline, CliRenderer $renderer);
10+
public function render(AbstractInline $inline, CliRenderer $renderer): string;
2311
}

src/InlineRenderer/CodeRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\AbstractInline;
77
use League\CommonMark\Inline\Element\Code;
88

9-
/**
10-
* Class CodeRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class CodeRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Code)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

src/InlineRenderer/EmphasisRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\Emphasis;
77
use AydinHassan\CliMdRenderer\CliRenderer;
88

9-
/**
10-
* Class EmphasisRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class EmphasisRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Emphasis)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

src/InlineRenderer/LinkRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\Link;
77
use AydinHassan\CliMdRenderer\CliRenderer;
88

9-
/**
10-
* Class LinkRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class LinkRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Link)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

src/InlineRenderer/NewlineRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\Newline;
77
use AydinHassan\CliMdRenderer\CliRenderer;
88

9-
/**
10-
* Class NewlineRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class NewlineRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Newline)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

src/InlineRenderer/StrongRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\Strong;
77
use AydinHassan\CliMdRenderer\CliRenderer;
88

9-
/**
10-
* Class StrongRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class StrongRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Strong)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

src/InlineRenderer/TextRenderer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,9 @@
66
use League\CommonMark\Inline\Element\Text;
77
use AydinHassan\CliMdRenderer\CliRenderer;
88

9-
/**
10-
* Class TextRenderer
11-
* @package AydinHassan\CliMdRenderer\InlineRenderer
12-
* @author Aydin Hassan <aydin@hotmail.co.uk>
13-
*/
149
class TextRenderer implements CliInlineRendererInterface
1510
{
16-
17-
/**
18-
* @param AbstractInline $inline
19-
* @param CliRenderer $renderer
20-
*
21-
* @return string
22-
*/
23-
public function render(AbstractInline $inline, CliRenderer $renderer)
11+
public function render(AbstractInline $inline, CliRenderer $renderer): string
2412
{
2513
if (!($inline instanceof Text)) {
2614
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));

0 commit comments

Comments
 (0)