Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"

dependencies:
- "lowest"
Expand Down Expand Up @@ -87,8 +89,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"

dependencies:
- "lowest"
Expand Down Expand Up @@ -121,8 +125,10 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"

dependencies:
- "lowest"
Expand Down
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,23 @@
}
],
"require": {
"php": ">=8.4",
"php": ">=8.1",
"cuyz/valinor": "^2.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"setono/html-element": "^1.0",
"symfony/options-resolver": "^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"setono/code-quality-pack": "^3.4"
"ergebnis/composer-normalize": "^2.45",
"infection/infection": "^0.28 || ^0.29 || ^0.32",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^10.5 || ^11.5",
"rector/rector": "^2.0",
"shipmonk/composer-dependency-analyser": "^1.8",
"sylius-labs/coding-standard": "^4.5"
},
"prefer-stable": true,
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php84: true)
->withPhpSets(php81: true)
->withAttributesSets(phpunit: true)
->withSets([
PHPUnitSetList::PHPUNIT_100,
Expand Down
4 changes: 2 additions & 2 deletions src/Block/Image/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Setono\EditorJS\Block\Image;

// todo right now it doesn't support the extra data you can set on the File object (see https://github.com/editor-js/image#providing-custom-uploading-methods)
final readonly class File
final class File
{
public function __construct(public string $url)
public function __construct(public readonly string $url)
{
}
}
4 changes: 2 additions & 2 deletions src/Block/ListBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

final class ListBlock extends Block
{
public const string STYLE_ORDERED = 'ordered';
public const STYLE_ORDERED = 'ordered';

public const string STYLE_UNORDERED = 'unordered';
public const STYLE_UNORDERED = 'unordered';

/**
* This is a helper property containing the html tag for the list (i.e. ol/ul)
Expand Down
3 changes: 1 addition & 2 deletions src/BlockRenderer/DelimiterBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function render(Block $block): HtmlElement

$tag = $this->getOption('tag');

return new HtmlElement(is_string($tag) ? $tag : 'hr')->withClass($this->getClassOption('class'));
return (new HtmlElement(is_string($tag) ? $tag : 'hr'))->withClass($this->getClassOption('class'));
}

/**
Expand All @@ -29,7 +29,6 @@ public function supports(Block $block): bool
return $block instanceof DelimiterBlock;
}

#[\Override]
protected function configureOptions(OptionsResolver $optionsResolver): void
{
parent::configureOptions($optionsResolver);
Expand Down
1 change: 0 additions & 1 deletion src/BlockRenderer/EmbedBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function render(Block $block): HtmlElement
)->withClass($this->getClassOption('containerClass'));
}

#[\Override]
protected function configureOptions(OptionsResolver $optionsResolver): void
{
parent::configureOptions($optionsResolver);
Expand Down
2 changes: 1 addition & 1 deletion src/BlockRenderer/HeaderBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function render(Block $block): HtmlElement
{
UnsupportedBlockException::assert($this->supports($block), $block, $this);

return new HtmlElement(sprintf('h%d', $block->level), $block->text)
return (new HtmlElement(sprintf('h%d', $block->level), $block->text))
->withClass($this->getClassOption('class'))
;
}
Expand Down
1 change: 0 additions & 1 deletion src/BlockRenderer/ImageBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function render(Block $block): HtmlElement
return $container;
}

#[\Override]
protected function configureOptions(OptionsResolver $optionsResolver): void
{
parent::configureOptions($optionsResolver);
Expand Down
5 changes: 2 additions & 3 deletions src/BlockRenderer/ListBlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ public function render(Block $block): HtmlElement
{
UnsupportedBlockException::assert($this->supports($block), $block, $this);

return new HtmlElement($block->tag, ...array_map(
return (new HtmlElement($block->tag, ...array_map(
fn (string $item) => HtmlElement::li($item)->withClass($this->getClassOption('itemClass')),
$block->items,
))
)))
->withClass($this->getClassOption('class'))
;
}

#[\Override]
protected function configureOptions(OptionsResolver $optionsResolver): void
{
parent::configureOptions($optionsResolver);
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function parse(string $json): ParserResult
public function getMapperBuilder(): MapperBuilder
{
if (null === $this->mapperBuilder) {
$this->mapperBuilder = new MapperBuilder()
$this->mapperBuilder = (new MapperBuilder())
->allowSuperfluousKeys()
->allowPermissiveTypes()
;
Expand Down
8 changes: 4 additions & 4 deletions src/Parser/ParserResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Setono\EditorJS\Block\Block;

final readonly class ParserResult
final class ParserResult
{
public function __construct(
public \DateTimeImmutable $time,
public string $version,
public readonly \DateTimeImmutable $time,
public readonly string $version,
/** @var list<Block> $blocks */
public array $blocks,
public readonly array $blocks,
) {
}
}
2 changes: 1 addition & 1 deletion tests/Renderer/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function it_throws_exception_if_block_is_not_supported(): void
new HeaderBlock('id', 'Header', 1),
]);

self::assertSame('<h1>Header</h1><p>Lorem ipsum</p>', new Renderer()->render($parserResult));
self::assertSame('<h1>Header</h1><p>Lorem ipsum</p>', (new Renderer())->render($parserResult));
}

#[\PHPUnit\Framework\Attributes\Test]
Expand Down
Loading