Skip to content

Commit

Permalink
Merge branch hotfix/v2.3.28
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Sep 24, 2024
1 parent 4a32910 commit 979b56a
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.0', '8.1']
php-version: ['8.1', '8.2', '8.3']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand Down
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © 2024 Ambroise Maupate

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "Markdown services and Twig extension for Roadiz",
"type": "library",
"require": {
"php": ">=8.0",
"php": ">=8.1",
"league/commonmark": "^2.2.0",
"twig/twig": "^3.1",
"doctrine/collections": ">=1.6",
"symfony/stopwatch": "5.4.*"
"symfony/stopwatch": "6.4.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
Expand All @@ -29,8 +29,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev",
"dev-develop": "2.2.x-dev"
"dev-master": "2.3.x-dev",
"dev-develop": "2.4.x-dev"
}
}
}
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
parameters:
level: max
level: 7
paths:
- src
excludePaths:
- */node_modules/*
- */bower_components/*
- */static/*
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Instantiated class Memcached not found#'
- '#Instantiated class Redis not found#'
reportUnmatchedIgnoredErrors: false
47 changes: 10 additions & 37 deletions src/CommonMark.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,22 @@

final class CommonMark implements MarkdownInterface
{
private ?Stopwatch $stopwatch;
private MarkdownConverter $textConverter;
private MarkdownConverter $lineConverter;
private MarkdownConverter $textExtraConverter;

/**
* @param MarkdownConverter $textConverter
* @param MarkdownConverter $textExtraConverter
* @param MarkdownConverter $lineConverter
* @param Stopwatch|null $stopwatch
*/
public function __construct(
MarkdownConverter $textConverter,
MarkdownConverter $textExtraConverter,
MarkdownConverter $lineConverter,
?Stopwatch $stopwatch = null
private readonly MarkdownConverter $textConverter,
private readonly MarkdownConverter $textExtraConverter,
private readonly MarkdownConverter $lineConverter,
private readonly ?Stopwatch $stopwatch = null
) {
$this->textConverter = $textConverter;
$this->textExtraConverter = $textExtraConverter;
$this->lineConverter = $lineConverter;
$this->stopwatch = $stopwatch;
}

public function text(string $markdown = null): string
{
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::text');
}
$this->stopwatch?->start(CommonMark::class . '::text');
$html = $this->textConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::text');
}
$this->stopwatch?->stop(CommonMark::class . '::text');
return $html;
}

Expand All @@ -52,13 +33,9 @@ public function textExtra(string $markdown = null): string
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::textExtra');
}
$this->stopwatch?->start(CommonMark::class . '::textExtra');
$html = $this->textExtraConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::textExtra');
}
$this->stopwatch?->stop(CommonMark::class . '::textExtra');
return $html;
}

Expand All @@ -67,13 +44,9 @@ public function line(string $markdown = null): string
if (null === $markdown) {
return '';
}
if (null !== $this->stopwatch) {
$this->stopwatch->start(CommonMark::class . '::line');
}
$this->stopwatch?->start(CommonMark::class . '::line');
$html = $this->lineConverter->convert($markdown)->getContent();
if (null !== $this->stopwatch) {
$this->stopwatch->stop(CommonMark::class . '::line');
}
$this->stopwatch?->stop(CommonMark::class . '::line');
return $html;
}
}
5 changes: 1 addition & 4 deletions src/Twig/MarkdownExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

final class MarkdownExtension extends AbstractExtension
{
private MarkdownInterface $markdown;

public function __construct(MarkdownInterface $markdown)
public function __construct(private readonly MarkdownInterface $markdown)
{
$this->markdown = $markdown;
}

public function getFilters(): array
Expand Down

0 comments on commit 979b56a

Please sign in to comment.