diff --git a/LICENSE.md b/LICENSE.md index 8e18fa6..d4d8a00 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright © 2024 Ambroise Maupate +Copyright © 2023 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: diff --git a/composer.json b/composer.json index 6d6d59e..fe2f1ed 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,8 @@ "require": { "php": ">=8.1", "roadiz/nodetype-contracts": "~1.1.2", - "symfony/translation": "6.4.*", - "symfony/http-foundation": "6.4.*" + "symfony/translation": "5.4.*", + "symfony/http-foundation": "5.4.*" }, "license": "MIT", "authors": [ @@ -28,8 +28,8 @@ }, "extra": { "branch-alias": { - "dev-main": "2.3.x-dev", - "dev-develop": "2.4.x-dev" + "dev-main": "2.2.x-dev", + "dev-develop": "2.3.x-dev" } } } diff --git a/phpstan.neon b/phpstan.neon index 8711646..2359c3d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,7 @@ parameters: - level: 7 + level: max paths: - src reportUnmatchedIgnoredErrors: false - ignoreErrors: - - identifier: missingType.iterableValue - - identifier: missingType.generics + checkGenericClassInNonGenericObjectType: false + checkMissingIterableValueType: false diff --git a/src/Generators/MarkdownGeneratorFactory.php b/src/Generators/MarkdownGeneratorFactory.php index c38925e..b277298 100644 --- a/src/Generators/MarkdownGeneratorFactory.php +++ b/src/Generators/MarkdownGeneratorFactory.php @@ -11,10 +11,17 @@ final class MarkdownGeneratorFactory { - public function __construct( - private readonly ParameterBag $nodeTypesBag, - private readonly TranslatorInterface $translator - ) { + private ParameterBag $nodeTypesBag; + private TranslatorInterface $translator; + + /** + * @param ParameterBag $nodeTypesBag + * @param TranslatorInterface $translator + */ + public function __construct(ParameterBag $nodeTypesBag, TranslatorInterface $translator) + { + $this->nodeTypesBag = $nodeTypesBag; + $this->translator = $translator; } public function getHumanBool(bool $bool): string @@ -43,11 +50,16 @@ public function createForNodeType(NodeTypeInterface $nodeType): NodeTypeGenerato */ public function createForNodeTypeField(NodeTypeFieldInterface $field): AbstractFieldGenerator { - return match (true) { - $field->isNodes() => new NodeReferencesFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), - $field->isChildrenNodes() => new ChildrenNodeFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), - $field->isMultiple(), $field->isEnum() => new DefaultValuedFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), - default => new CommonFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), - }; + switch (true) { + case $field->isNodes(): + return new NodeReferencesFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); + case $field->isChildrenNodes(): + return new ChildrenNodeFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); + case $field->isMultiple(): + case $field->isEnum(): + return new DefaultValuedFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); + default: + return new CommonFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); + } } }