Skip to content

Commit ac41298

Browse files
author
roadiz-ci
committed
chore: bumped
1 parent 0ace806 commit ac41298

7 files changed

Lines changed: 72 additions & 32 deletions

File tree

.github/workflows/run-test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
php-version: ['8.2', '8.3']
22+
php-version: ['8.1', '8.2', '8.3']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:
@@ -35,5 +35,7 @@ jobs:
3535
${{ runner.os }}-php-${{ matrix.php-version }}-
3636
- name: Install Dependencies
3737
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
38+
- name: Run PHP Code Sniffer
39+
run: vendor/bin/phpcs --extensions=php --warning-severity=0 --standard=PSR12 -p ./src
3840
- name: Run PHPStan
3941
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test:
2+
vendor/bin/phpcs --report=full --report-file=./report.txt -p ./src
3+
vendor/bin/phpstan analyse -c phpstan.neon

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"description": "Markdown services and Twig extension for Roadiz",
44
"type": "library",
55
"require": {
6-
"php": ">=8.2",
7-
"doctrine/collections": ">=1.6",
6+
"php": ">=8.1",
87
"league/commonmark": "^2.2.0",
9-
"symfony/stopwatch": "6.4.*",
10-
"twig/twig": "^3.16"
8+
"twig/twig": "^3.1",
9+
"doctrine/collections": ">=1.6",
10+
"symfony/stopwatch": "6.4.*"
1111
},
1212
"require-dev": {
13-
"phpstan/phpstan": "^1.5.3",
14-
"phpstan/phpdoc-parser": "<2"
13+
"squizlabs/php_codesniffer": "^3.5",
14+
"phpstan/phpstan": "^1.5.3"
1515
},
1616
"license": "MIT",
1717
"authors": [
@@ -29,8 +29,8 @@
2929
},
3030
"extra": {
3131
"branch-alias": {
32-
"dev-master": "2.5.x-dev",
33-
"dev-develop": "2.6.x-dev"
32+
"dev-master": "2.3.x-dev",
33+
"dev-develop": "2.4.x-dev"
3434
}
3535
}
3636
}

phpcs.xml.dist

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
4+
5+
<arg name="basepath" value="."/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
10+
<rule ref="PSR12">
11+
<exclude name="Generic.Files.LineLength"/>
12+
</rule>
13+
<file>./src</file>
14+
</ruleset>

src/CommonMark.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,46 @@
77
use League\CommonMark\MarkdownConverter;
88
use Symfony\Component\Stopwatch\Stopwatch;
99

10-
final readonly class CommonMark implements MarkdownInterface
10+
final class CommonMark implements MarkdownInterface
1111
{
1212
public function __construct(
13-
private MarkdownConverter $textConverter,
14-
private MarkdownConverter $textExtraConverter,
15-
private MarkdownConverter $lineConverter,
16-
private ?Stopwatch $stopwatch = null,
13+
private readonly MarkdownConverter $textConverter,
14+
private readonly MarkdownConverter $textExtraConverter,
15+
private readonly MarkdownConverter $lineConverter,
16+
private readonly ?Stopwatch $stopwatch = null
1717
) {
1818
}
1919

20-
public function text(?string $markdown = null): string
20+
public function text(string $markdown = null): string
2121
{
2222
if (null === $markdown) {
2323
return '';
2424
}
25-
$this->stopwatch?->start(CommonMark::class.'::text');
25+
$this->stopwatch?->start(CommonMark::class . '::text');
2626
$html = $this->textConverter->convert($markdown)->getContent();
27-
$this->stopwatch?->stop(CommonMark::class.'::text');
28-
27+
$this->stopwatch?->stop(CommonMark::class . '::text');
2928
return $html;
3029
}
3130

32-
public function textExtra(?string $markdown = null): string
31+
public function textExtra(string $markdown = null): string
3332
{
3433
if (null === $markdown) {
3534
return '';
3635
}
37-
$this->stopwatch?->start(CommonMark::class.'::textExtra');
36+
$this->stopwatch?->start(CommonMark::class . '::textExtra');
3837
$html = $this->textExtraConverter->convert($markdown)->getContent();
39-
$this->stopwatch?->stop(CommonMark::class.'::textExtra');
40-
38+
$this->stopwatch?->stop(CommonMark::class . '::textExtra');
4139
return $html;
4240
}
4341

44-
public function line(?string $markdown = null): string
42+
public function line(string $markdown = null): string
4543
{
4644
if (null === $markdown) {
4745
return '';
4846
}
49-
$this->stopwatch?->start(CommonMark::class.'::line');
47+
$this->stopwatch?->start(CommonMark::class . '::line');
5048
$html = $this->lineConverter->convert($markdown)->getContent();
51-
$this->stopwatch?->stop(CommonMark::class.'::line');
52-
49+
$this->stopwatch?->stop(CommonMark::class . '::line');
5350
return $html;
5451
}
5552
}

src/MarkdownInterface.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@ interface MarkdownInterface
88
{
99
/**
1010
* Convert Markdown to HTML using standard Markdown syntax.
11+
*
12+
* @param string|null $markdown
13+
*
14+
* @return string
1115
*/
12-
public function text(?string $markdown = null): string;
16+
public function text(string $markdown = null): string;
1317

1418
/**
1519
* Convert Markdown to HTML using standard Markdown Extra syntax.
20+
*
21+
* @param string|null $markdown
22+
*
23+
* @return string
1624
*/
17-
public function textExtra(?string $markdown = null): string;
25+
public function textExtra(string $markdown = null): string;
1826

1927
/**
2028
* Convert Markdown to HTML using only inline HTML elements.
29+
*
30+
* @param string|null $markdown
31+
*
32+
* @return string
2133
*/
22-
public function line(?string $markdown = null): string;
34+
public function line(string $markdown = null): string;
2335
}

src/Twig/MarkdownExtension.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,42 @@ public function getFilters(): array
2525
];
2626
}
2727

28+
/**
29+
* @param string|null $input
30+
*
31+
* @return string
32+
*/
2833
public function markdown(?string $input): string
2934
{
3035
if (null === $input) {
3136
return '';
3237
}
33-
3438
return $this->markdown->text($input);
3539
}
3640

41+
/**
42+
* @param string|null $input
43+
*
44+
* @return string
45+
*/
3746
public function inlineMarkdown(?string $input): string
3847
{
3948
if (null === $input) {
4049
return '';
4150
}
42-
4351
return $this->markdown->line($input);
4452
}
4553

54+
/**
55+
* @param string|null $input
56+
*
57+
* @return string
58+
*/
4659
public function markdownExtra(?string $input): string
4760
{
4861
if (null === $input) {
4962
return '';
5063
}
51-
5264
return $this->markdown->textExtra($input);
5365
}
5466
}

0 commit comments

Comments
 (0)