diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index b2ae539..98f1239 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['8.1', '8.2', '8.3'] + php-version: ['8.0', '8.1'] steps: - uses: shivammathur/setup-php@v2 with: diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..eb3285d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: php +sudo: required +php: + - 8.0 + - 8.1 + - nightly +install: + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev --no-interaction +script: + - vendor/bin/phpcs --report=full --report-file=./report.txt -p ./ + - vendor/bin/phpstan analyse -c phpstan.neon +jobs: + allow_failures: + - php: nightly diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..90114a2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Ambroise Maupate and Julien Blanchet + +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. diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 8e18fa6..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -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. diff --git a/composer.json b/composer.json index 6d6d59e..7a28588 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,10 @@ "description": "Roadiz sub-package which generates Markdown documentation skeleton based on your schema", "type": "library", "require": { - "php": ">=8.1", + "php": ">=8.0", "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.1.x-dev", + "dev-develop": "2.2.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); + } } }