Skip to content

Commit 5249bae

Browse files
author
roadiz-ci
committed
Merge branch hotfix/v2.6.22
1 parent 3855592 commit 5249bae

8 files changed

Lines changed: 42 additions & 78 deletions

File tree

.github/workflows/run-test.yml

Lines changed: 1 addition & 3 deletions
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.1', '8.2', '8.3']
22+
php-version: ['8.3', '8.4']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:
@@ -35,7 +35,5 @@ 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
4038
- name: Run PHPStan
4139
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2024 Ambroise Maupate
3+
Copyright © 2025 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

Makefile

Lines changed: 0 additions & 3 deletions
This file was deleted.

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.1",
7-
"league/commonmark": "^2.2.0",
8-
"twig/twig": "^3.1",
6+
"php": ">=8.3",
97
"doctrine/collections": ">=1.6",
10-
"symfony/stopwatch": "6.4.*"
8+
"league/commonmark": "^2.2.0",
9+
"symfony/stopwatch": "7.3.*",
10+
"twig/twig": "^3.21"
1111
},
1212
"require-dev": {
13-
"squizlabs/php_codesniffer": "^3.5",
14-
"phpstan/phpstan": "^1.5.3"
13+
"phpstan/phpstan": "^1.5.3",
14+
"phpstan/phpdoc-parser": "<2"
1515
},
1616
"license": "MIT",
1717
"authors": [
@@ -29,8 +29,8 @@
2929
},
3030
"extra": {
3131
"branch-alias": {
32-
"dev-master": "2.3.x-dev",
33-
"dev-develop": "2.4.x-dev"
32+
"dev-master": "2.6.x-dev",
33+
"dev-develop": "2.7.x-dev"
3434
}
3535
}
3636
}

phpcs.xml.dist

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/CommonMark.php

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

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

20-
public function text(string $markdown = null): string
20+
#[\Override]
21+
public function text(?string $markdown = null): string
2122
{
2223
if (null === $markdown) {
2324
return '';
2425
}
25-
$this->stopwatch?->start(CommonMark::class . '::text');
26+
$this->stopwatch?->start(CommonMark::class.'::text');
2627
$html = $this->textConverter->convert($markdown)->getContent();
27-
$this->stopwatch?->stop(CommonMark::class . '::text');
28+
$this->stopwatch?->stop(CommonMark::class.'::text');
29+
2830
return $html;
2931
}
3032

31-
public function textExtra(string $markdown = null): string
33+
#[\Override]
34+
public function textExtra(?string $markdown = null): string
3235
{
3336
if (null === $markdown) {
3437
return '';
3538
}
36-
$this->stopwatch?->start(CommonMark::class . '::textExtra');
39+
$this->stopwatch?->start(CommonMark::class.'::textExtra');
3740
$html = $this->textExtraConverter->convert($markdown)->getContent();
38-
$this->stopwatch?->stop(CommonMark::class . '::textExtra');
41+
$this->stopwatch?->stop(CommonMark::class.'::textExtra');
42+
3943
return $html;
4044
}
4145

42-
public function line(string $markdown = null): string
46+
#[\Override]
47+
public function line(?string $markdown = null): string
4348
{
4449
if (null === $markdown) {
4550
return '';
4651
}
47-
$this->stopwatch?->start(CommonMark::class . '::line');
52+
$this->stopwatch?->start(CommonMark::class.'::line');
4853
$html = $this->lineConverter->convert($markdown)->getContent();
49-
$this->stopwatch?->stop(CommonMark::class . '::line');
54+
$this->stopwatch?->stop(CommonMark::class.'::line');
55+
5056
return $html;
5157
}
5258
}

src/MarkdownInterface.php

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

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

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

src/Twig/MarkdownExtension.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,53 +14,42 @@ public function __construct(private readonly MarkdownInterface $markdown)
1414
{
1515
}
1616

17+
#[\Override]
1718
public function getFilters(): array
1819
{
1920
return [
20-
new TwigFilter('markdown', [$this, 'markdown'], ['is_safe' => ['html']]),
21-
new TwigFilter('inlineMarkdown', [$this, 'inlineMarkdown'], ['is_safe' => ['html']]),
22-
new TwigFilter('inline_markdown', [$this, 'inlineMarkdown'], ['is_safe' => ['html']]),
23-
new TwigFilter('markdownExtra', [$this, 'markdownExtra'], ['is_safe' => ['html']]),
24-
new TwigFilter('markdown_extra', [$this, 'markdownExtra'], ['is_safe' => ['html']]),
21+
new TwigFilter('markdown', $this->markdown(...), ['is_safe' => ['html']]),
22+
new TwigFilter('inlineMarkdown', $this->inlineMarkdown(...), ['is_safe' => ['html']]),
23+
new TwigFilter('inline_markdown', $this->inlineMarkdown(...), ['is_safe' => ['html']]),
24+
new TwigFilter('markdownExtra', $this->markdownExtra(...), ['is_safe' => ['html']]),
25+
new TwigFilter('markdown_extra', $this->markdownExtra(...), ['is_safe' => ['html']]),
2526
];
2627
}
2728

28-
/**
29-
* @param string|null $input
30-
*
31-
* @return string
32-
*/
3329
public function markdown(?string $input): string
3430
{
3531
if (null === $input) {
3632
return '';
3733
}
34+
3835
return $this->markdown->text($input);
3936
}
4037

41-
/**
42-
* @param string|null $input
43-
*
44-
* @return string
45-
*/
4638
public function inlineMarkdown(?string $input): string
4739
{
4840
if (null === $input) {
4941
return '';
5042
}
43+
5144
return $this->markdown->line($input);
5245
}
5346

54-
/**
55-
* @param string|null $input
56-
*
57-
* @return string
58-
*/
5947
public function markdownExtra(?string $input): string
6048
{
6149
if (null === $input) {
6250
return '';
6351
}
52+
6453
return $this->markdown->textExtra($input);
6554
}
6655
}

0 commit comments

Comments
 (0)