diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 5f7efa2..1a24c5b 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..87d3a8b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +language: php +sudo: required +php: + - 8.0 + - 8.1 + - nightly +env: + - XDEBUG_MODE=coverage +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 --extensions=php --warning-severity=0 --standard=PSR12 -p ./src + - vendor/bin/phpstan analyse -c phpstan.neon + - vendor/bin/atoum -f tests/units/* +jobs: + allow_failures: + - php: nightly diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9e67c84 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Roadiz + +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 d4d8a00..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License (MIT) - -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: - -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 aff7aec..bd4e42d 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=8.1", + "php": ">=8.0", "ext-json": "*", "roadiz/nodetype-contracts": "~1.1.2", "symfony/string": "5.4.*", @@ -37,8 +37,8 @@ }, "extra": { "branch-alias": { - "dev-main": "2.2.x-dev", - "dev-develop": "2.3.x-dev" + "dev-main": "2.1.x-dev", + "dev-develop": "2.2.x-dev" } } } diff --git a/src/EntityGenerator.php b/src/EntityGenerator.php index bfc258b..808de9b 100644 --- a/src/EntityGenerator.php +++ b/src/EntityGenerator.php @@ -191,9 +191,9 @@ protected function getClassHeader(): string ]; if ($this->options['use_api_platform_filters'] === true) { - $useStatements[] = 'use ApiPlatform\Metadata\ApiFilter;'; - $useStatements[] = 'use ApiPlatform\Doctrine\Orm\Filter as OrmFilter;'; - $useStatements[] = 'use ApiPlatform\Serializer\Filter\PropertyFilter;'; + $useStatements[] = 'use ApiPlatform\Core\Annotation\ApiFilter;'; + $useStatements[] = 'use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter as OrmFilter;'; + $useStatements[] = 'use ApiPlatform\Core\Serializer\Filter\PropertyFilter;'; } /* * BE CAREFUL, USE statements are required for field generators which diff --git a/src/Field/NonVirtualFieldGenerator.php b/src/Field/NonVirtualFieldGenerator.php index 9a9df5e..4c51820 100644 --- a/src/Field/NonVirtualFieldGenerator.php +++ b/src/Field/NonVirtualFieldGenerator.php @@ -52,6 +52,18 @@ protected function getFieldLength(): ?int }; } + protected function getMaxDefaultValuesLength(): int + { + // get max length of exploded default values + $max = 0; + foreach (explode(',', $this->field->getDefaultValues()) as $value) { + $value = trim($value); + $max = max($max, \mb_strlen($value)); + } + + return $max > 0 ? $max : 250; + } + protected function isExcludingFieldFromJmsSerialization(): bool { return false; diff --git a/tests/mocks/GeneratedNodesSources/NSMock.php b/tests/mocks/GeneratedNodesSources/NSMock.php index 0b16aed..7349831 100644 --- a/tests/mocks/GeneratedNodesSources/NSMock.php +++ b/tests/mocks/GeneratedNodesSources/NSMock.php @@ -13,9 +13,9 @@ use Symfony\Component\Serializer\Annotation as SymfonySerializer; use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; -use ApiPlatform\Metadata\ApiFilter; -use ApiPlatform\Doctrine\Orm\Filter as OrmFilter; -use ApiPlatform\Serializer\Filter\PropertyFilter; +use ApiPlatform\Core\Annotation\ApiFilter; +use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter as OrmFilter; +use ApiPlatform\Core\Serializer\Filter\PropertyFilter; /** * DO NOT EDIT diff --git a/tests/mocks/GeneratedNodesSourcesWithRepository/NSMock.php b/tests/mocks/GeneratedNodesSourcesWithRepository/NSMock.php index 1f25db5..f9013e8 100644 --- a/tests/mocks/GeneratedNodesSourcesWithRepository/NSMock.php +++ b/tests/mocks/GeneratedNodesSourcesWithRepository/NSMock.php @@ -13,9 +13,9 @@ use Symfony\Component\Serializer\Annotation as SymfonySerializer; use Gedmo\Mapping\Annotation as Gedmo; use Doctrine\ORM\Mapping as ORM; -use ApiPlatform\Metadata\ApiFilter; -use ApiPlatform\Doctrine\Orm\Filter as OrmFilter; -use ApiPlatform\Serializer\Filter\PropertyFilter; +use ApiPlatform\Core\Annotation\ApiFilter; +use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter as OrmFilter; +use ApiPlatform\Core\Serializer\Filter\PropertyFilter; /** * DO NOT EDIT