Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
- '~^Call to an undefined method FluentDOM\\DOM\\Node\\.+?::getNodePath\(\)\.$~'
- '~^Cannot call method (end|([a-z]+)Node)\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\.$~'
- '~^Service "csa_guzzle\.mock\.storage" is not registered in the container\.$~'
- '~^Call to method PHPUnit\\Framework\\Assert::assert(True|False)\(\) with (true|false) will always evaluate to (true|false)\.$~'
level: max
paths:
- bin/console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

Expand All @@ -21,7 +21,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;
Expand All @@ -21,7 +22,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
$title = $object->ownerDocument->xpath()
->firstOf('jats:article-meta/jats:title-group/jats:article-title', $object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ContextAwareTranslation;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Symfony\Contracts\Translation\TranslatorInterface;
use function sprintf;
Expand All @@ -24,7 +25,7 @@ public function __construct(TranslatorInterface $translator, array $translationK
$this->translationKeys = $translationKeys;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
$items = $view->getArgument('items') ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ContextAwareTranslation;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -25,7 +26,7 @@ public function __construct(ViewConverter $converter, TranslatorInterface $trans
$this->translator = $translator;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
$meta = $this->converter
->convert($object, '@LiberoPatterns/content-meta.html.twig', $view->getContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ContextAwareTranslation;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -28,7 +29,7 @@ public function __construct(ViewConverter $converter, TranslatorInterface $trans
$this->translator = $translator;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
$items = $view->getArgument('items') ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsLists;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function array_filter;
Expand All @@ -26,7 +27,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
/** @var DOMNodeList<Element> $keywordGroups */
$keywordGroups = $object->ownerDocument->xpath()
Expand All @@ -40,7 +41,7 @@ protected function handle(Element $object, View $view) : View
array_filter(
array_map(
function (View $tagList) : array {
return $tagList->getArguments();
return $tagList instanceof TemplateView ? $tagList->getArguments() : [];
},
$this->convertList($keywordGroups, '@LiberoPatterns/tag-list.html.twig', $view->getContext())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Libero\ViewsBundle\Views\ContextAwareTranslation;
use Libero\ViewsBundle\Views\ConvertsLists;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -28,7 +29,7 @@ public function __construct(ViewConverter $converter, TranslatorInterface $trans
$this->translator = $translator;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
/** @var DOMNodeList<Element> $subjects */
$subjects = $object->ownerDocument->xpath()->evaluate(
Expand All @@ -50,7 +51,7 @@ protected function handle(Element $object, View $view) : View
),
],
'items' => array_map(
function (View $link) : array {
function (TemplateView $link) : array {
return ['content' => $link->getArguments()];
},
$this->convertList($subjects, '@LiberoPatterns/link.html.twig', $view->getContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;
Expand All @@ -22,7 +23,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
if ($view->hasContext('level')) {
$view = $view->withArgument('level', $view->getContext('level'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

Expand All @@ -21,7 +21,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Libero\ViewsBundle\Views\ContextAwareTranslation;
use Libero\ViewsBundle\Views\ConvertsLists;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -31,7 +32,7 @@ public function __construct(ViewConverter $converter, TranslatorInterface $trans
$this->translationKeys = $translationKeys;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
$title = $object->ownerDocument->xpath()
->firstOf('jats:title', $object);
Expand All @@ -46,8 +47,13 @@ protected function handle(Element $object, View $view) : View
$type = $object->getAttribute('kwd-group-type');

if ($title instanceof Element) {
$title = $this->converter->convert($title, '@LiberoPatterns/heading.html.twig', $view->getContext())
->getArguments();
$title = $this->converter->convert($title, '@LiberoPatterns/heading.html.twig', $view->getContext());

if (!$title instanceof TemplateView) {
return $view;
}

$title = $title->getArguments();
} elseif (!isset($this->translationKeys[$type])) {
return $view;
} else {
Expand All @@ -60,7 +66,7 @@ protected function handle(Element $object, View $view) : View
'list',
[
'items' => array_map(
function (View $link) : array {
function (TemplateView $link) : array {
return ['content' => $link->getArguments()];
},
$this->convertList($keywords, '@LiberoPatterns/link.html.twig', $view->getContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;
Expand All @@ -24,7 +25,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : View
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

Expand All @@ -23,7 +23,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use FluentDOM\DOM\Node\NonDocumentTypeChildNode;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function array_map;
use function iterator_to_array;
Expand All @@ -27,7 +27,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
if (!$view->hasContext('level')) {
$view = $view->withContext(['level' => 1]);
Expand All @@ -54,7 +54,7 @@ protected function handle(Element $object, View $view) : View
return $view->withArgument(
'content',
array_map(
function (NonDocumentTypeChildNode $child) use ($childContext) : View {
function (NonDocumentTypeChildNode $child) use ($childContext) : TemplateView {
return $this->converter->convert($child, null, $childContext);
},
iterator_to_array($children)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

Expand All @@ -21,7 +21,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\ConvertsChildren;
use Libero\ViewsBundle\Views\OptionalTemplateListener;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

Expand All @@ -21,7 +21,7 @@ public function __construct(ViewConverter $converter)
$this->converter = $converter;
}

protected function handle(Element $object, View $view) : View
protected function handle(Element $object, TemplateView $view) : TemplateView
{
return $view->withArgument('text', $this->convertChildren($object, $view->getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use FluentDOM\DOM\Element;
use Libero\LiberoPageBundle\Event\CreatePagePartEvent;
use Libero\ViewsBundle\Views\ConvertsLists;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\ViewConverter;
use function count;
use const Libero\LiberoPatternsBundle\CONTENT_GRID_PRIMARY;
Expand Down Expand Up @@ -36,7 +37,7 @@ public function onCreatePagePart(CreatePagePartEvent $event) : void

$itemTags = $this->converter->convert($front, '@LiberoPatterns/item-tags.html.twig', $context);

if (0 === count($itemTags->getArguments())) {
if (!$itemTags instanceof TemplateView || 0 === count($itemTags->getArguments())) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Libero\JatsContentBundle\EventListener\BodyListener;
use Libero\LiberoPageBundle\Event\CreatePagePartEvent;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\TemplateView;
use PHPUnit\Framework\TestCase;
use tests\Libero\LiberoPageBundle\PageTestCase;
use tests\Libero\LiberoPageBundle\ViewConvertingTestCase;
Expand Down Expand Up @@ -101,8 +101,8 @@ public function it_adds_the_body_content(string $xml, array $context, array $exp

$this->assertEquals(
array_map(
function (array $block) : View {
return new View(null, $block);
function (array $block) : TemplateView {
return new TemplateView(null, $block);
},
$expectedBody
),
Expand Down
Loading