diff --git a/.check-author.yml b/.check-author.yml new file mode 100644 index 0000000..6834a73 --- /dev/null +++ b/.check-author.yml @@ -0,0 +1,8 @@ +exclude: + languages + +mapping: + "Ingolf Steinhardt ": + - "xantippe " + - "zonky2 " + - "Ingolf Steinhardt " diff --git a/.composer-require-checker.json b/.composer-require-checker.json new file mode 100644 index 0000000..4887b86 --- /dev/null +++ b/.composer-require-checker.json @@ -0,0 +1,10 @@ +{ + "symbol-whitelist": [ + "array", "bool", "false", "int", "null", "self", "static", "parent", "string", "true", "void", + "ampersand", "array_insert", "array_is_assoc", "nl2br_html5", "TL_ERROR", + "Contao\\ManagerBundle\\ContaoManagerBundle", + "Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface", + "Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig", + "Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface" + ] +} diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..2af1a5c --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,66 @@ +# How to contribute + +We are really glad you're reading this, because we need volunteer developers to +help this project come to fruition. + +If you haven't already, come find us in IRC (#contao.cca on freenode). +We want you working on things you're excited about. + +The following is a set of guidelines for contributing to DC_General, which +is hosted in the [Contao Community Alliance organization][1] on GitHub. These +are just guidelines, not rules, use your best judgement and feel free to +propose changes to this document in a pull request. + +## Submitting issues + +* Use the search function to see if a similar issue has already been submitted. +* Describe the issue in detail and include all the steps to follow in order to + reproduce the bug. +* Include the version of Contao, PHP and DC_General you are using (if possible + with a detailed list of other installed extensions that might be related). +* Include screenshots or screencasts if possible; they are immensely helpful. +* If you are reporting a bug, please include any related error message you are + seeing and also check the `system/logs/error.log` file. The error message is + not just the message but also the complete(!) stack trace below the message. + This trace is a long list of function calls which helps us to diagnose the + problem en detail. + +## Submitting changes + +* Please send a [GitHub Pull Request to Contao Community Alliance][1] with a + clear list of what you've done (read more about [pull requests][2]). +* When you send a pull request, we will love you forever if you include + phpunit tests. We can always use more test coverage. +* Please follow the [phpcq 2.0][3] coding standards. +* Please make sure all of your commits are atomic (only one feature or fix per + commit). +* We use phpcq/all-tasks in these projects, so please check your changes + using phpcq when submitting a pull request. +* Create your pull request against the [`master`][4] branch for bug fixes or the + [`develop`][5] branch for new features. +* Include screenshots in your pull request whenever possible. + +Always write a clear log message for your commits. +One-line messages are fine for small changes, but bigger changes should look +like this: + + $ git commit -m "A brief summary of the commit + > + > A paragraph describing what changed and its impact." + +## Testing + +We have a handful of unit tests. Please write unit tests for new code you +create. + +## Git commit messages + +* Use the present tense ("Add feature" not "Added feature"). +* Use the imperative mood ("Move cursor to …" not "Moves cursor to …"). +* Reference issues and pull requests liberally. + +[1]: https://github.com/contao-community-alliance +[2]: http://help.github.com/pull-requests/ +[3]: https://github.com/phpcq/coding-standard +[4]: https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/pull/new/master +[5]: https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/pull/new/develop diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..5948d48 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,39 @@ +## Checklist before I submit this issue report + +I confirm that: +- [ ] I have tested this with the latest version available +- [ ] I have checked the Contao community forums for references https://community.contao.org/ +- [ ] I have checked existing issues for duplicates and found none @ https://github.com/contao-community-alliance/contao-textfield-multiple-bundle/issues?q=is%3Aissue + +## My environment is: + +(Please fill in the actual values from your environment) + +| Key | Value | Comments | +| ----------------------------------- | ---------| ---------------------------------| +| PHP version: | | | +| Contao version: | | | +| DC_General version: | | | +| Installation via composer: | (yes/no) | | + +## Issue description + +(Describe the problem you are having) + +## Steps to reproduce + +1. [First Step] +2. [Second Step] +3. [and so on…] + +## Describe the behaviour of the application + +(Tell us what happens) + +## Describe the expected behaviour of the application + +(Tell us what should have happened) + +## Screenshots + +(Add some visual love or even a video if you can) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ac28856 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +## Description + +Please explain the detailed changes you made here. +Reference any issue number this pull request fixes. + +## Checklist +- [ ] Read and understood the [CONTRIBUTING guidelines](CONTRIBUTING.md) +- [ ] Created tests, if possible +- [ ] All tests passing +- [ ] Extended the README / documentation, if necessary +- [ ] Added myself to the `@authors` in touched PHP files +- [ ] Checked the changes with phpcq and introduced no new issues diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index df7f86b..36e2365 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -1,52 +1,75 @@ -name: CCA contao-textfield-multiple-bundle +name: Code Quality Diagnostics on: - push: - branches-ignore: - - '**-translation' pull_request: + push: + branches: jobs: build: runs-on: ubuntu-latest + name: 'PHP: ${{ matrix.php }} Contao: ${{ matrix.contao }}' strategy: + fail-fast: false matrix: - php: [7.4] - contao: [~4.9.0] + php: [ '8.1', '8.2' ] + contao: [ '~4.13.0' ] + phpcq_install: [ 'update' ] + output: [ '-o github-action -o default' ] steps: - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Pull source - uses: actions/checkout@v2 - with: - fetch-depth: 0 + - name: Pull source + uses: actions/checkout@v4 - # see https://github.com/shivammathur/setup-php - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Setup PHP. + - name: Setup PHP with PECL extension uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: none - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache composer cache directory - uses: actions/cache@v1 + # setup caches + - name: Cache composer cache directory + uses: actions/cache@v4 env: cache-name: composer-cache-dir with: path: ~/.cache/composer - key: ${{ runner.os }}-build-${{ env.cache-name }} + key: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }} - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache vendor directory - uses: actions/cache@v1 + - name: Cache vendor directory + uses: actions/cache@v4 env: - cache-name: composer-vendor + cache-name: vendor with: path: vendor - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.contao }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-${{ matrix.php }}-${{ matrix.contao }}-build-${{ env.cache-name }}- - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Install composer dependencies - run: composer update --prefer-dist --no-interaction --no-suggest + - name: Cache phpcq directory + uses: actions/cache@v4 + env: + cache-name: phpcq + with: + path: .phpcq + key: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/.phpcq.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }}- + + # install dependencies and tools + - name: Install composer dependencies + run: | + composer require contao/core-bundle ${{ matrix.contao }} --no-update + composer install + - name: Install phpcq toolchain + run: ./vendor/bin/phpcq ${{ matrix.phpcq_install }} -v - - name: PHP ${{ matrix.php }} ${{ matrix.contao }} Run tests - run: ant -keep-going + # run tests + - name: Run tests + run: ./vendor/bin/phpcq run -v ${{ matrix.output }} + + - name: Upload build directory to artifact + uses: actions/upload-artifact@v4 + if: ${{ success() }} || ${{ failure() }} + with: + name: phpcq-builds-php-${{ matrix.php }}-${{ matrix.contao }} + path: .phpcq/build/ diff --git a/.phpcq.lock b/.phpcq.lock new file mode 100644 index 0000000..52ac3b1 --- /dev/null +++ b/.phpcq.lock @@ -0,0 +1 @@ +{"plugins":{"phpunit":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpunit/phpunit-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0"},"tool":{"phpunit":"^6.0 || ^7.0 || ^8.0 || ^9.0"}},"checksum":{"type":"sha-512","value":"c73f15658e3ba62665f09492ec91c3a6a715760bfaa88473a987538439fff442540148e086e46a6aa18ce55a3ea2fbf76caaa581384cb84a38859fcc609ae7e4"},"tools":{"phpunit":{"version":"9.6.20","url":"https://phar.phpunit.de/phpunit-9.6.20.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-xml":"*","ext-xmlwriter":"*"}},"checksum":{"type":"sha-256","value":"4b49fdf48a3fdb5f4f4b5b18c43a542e75787edaf6a6ab39713f579d0a018210"},"signature":"https://phar.phpunit.de/phpunit-9.6.20.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.25.0","url":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.25.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.11.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.11.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcs.phar.asc"},"phpcbf":{"version":"3.10.2","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist new file mode 100644 index 0000000..56a2c6e --- /dev/null +++ b/.phpcq.yaml.dist @@ -0,0 +1,113 @@ +phpcq: + repositories: + - https://phpcq.github.io/repository/repository.json + directories: + - src + - tests + artifact: .phpcq/build + + plugins: + phpunit: + version: ^1.0 + signed: false + psalm: + version: ^1.1 + signed: false + composer-require-checker: + version: ^1.0 + signed: false + requirements: + composer-require-checker: + signed: false + version: ^4.0 + phpmd: + version: ^1.0 + signed: false + requirements: + phpmd: + signed: false + phpcpd: + version: ^1.0 + signed: false + requirements: + phpcpd: + version: ^6.0 + phploc: + version: ^1.0 + signed: false + phpcs: + version: ^1.0 + signed: false + composer-normalize: + version: ^1.0 + signed: false + trusted-keys: + # sb@sebastian-bergmann.de + - 4AA394086372C20A + # psalm + - 8A03EA3B385DBAA1 + - 12CE0F1D262429A5 + # magl@magll.net + - D2CCAC42F6295E7D + # PHP_CodeSniffer + - 31C7E470E2138192 + - A978220305CD5C32 + # Composer normalize + - C00543248C87FB13 + # phpmd + - 0F9684B8B16B7AB0 + - A4E55EA12C7C085C + - 9093F8B32E4815AA + # composer-require-checker + - 033E5F8D801A2F8D + +tasks: + fix: + - composer-normalize-fix + - phpcbf + verify: + - composer-require-checker + - composer-normalize + analyze: + - phploc + - phpcpd + - phpmd + - phpcs + - psalm + - phpunit + default: + - verify + - analyze + + phpmd: + plugin: phpmd + config: + ruleset: + - ./.phpmd.xml + + composer-normalize: + config: &composer-normalize-config + ignore_output: + - '#> pre-command-run: Contao\\ManagerPlugin\\Composer\\ArtifactsPlugin->preCommandRun#' + + composer-normalize-fix: + plugin: composer-normalize + config: + dry_run: false + + composer-require-checker: + plugin: composer-require-checker + config: + config_file: '.composer-require-checker.json' + + phpcs: + plugin: phpcs + config: &phpcs-config + standard: PSR12 + custom_flags: + - '--extensions=php' + + phpcbf: + plugin: phpcs + config: + <<: *phpcs-config diff --git a/.phpmd.xml b/.phpmd.xml new file mode 100644 index 0000000..70c17ee --- /dev/null +++ b/.phpmd.xml @@ -0,0 +1,37 @@ + + + + PHPMD rule set + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json index 5aa6362..53c6d7b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,8 @@ { "name": "contao-community-alliance/contao-textfield-multiple-bundle", - "type": "contao-bundle", "description": "Contao FormTextField with eval multiple and size support", + "license": "LGPL-3.0-or-later", + "type": "contao-bundle", "keywords": [ "contao resources", "frontend", @@ -9,8 +10,6 @@ "metamodels", "cca" ], - "homepage": "https://c-c-a.org/", - "license": "LGPL-3.0-or-later", "authors": [ { "name": "Richard Henkenjohann", @@ -18,18 +17,23 @@ "role": "Developer" } ], + "homepage": "https://c-c-a.org/", "support": { "issues": "https://github.com/contao-community-alliance/contao-textfield-multiple-bundle/issues", "source": "https://github.com/contao-community-alliance/contao-textfield-multiple-bundle" }, "require": { - "php": "^7.4", - "contao/core-bundle": "^4.9.0, <4.13.0" + "php": "^8.1", + "contao-community-alliance/dc-general-contao-frontend": "dev-hotfix/update_phpcq as 2.3.1", + "contao/core-bundle": "^4.13.0 <5.0", + "symfony/config": "^5.4", + "symfony/dependency-injection": "^5.4", + "symfony/http-kernel": "^5.4" }, "require-dev": { - "phpcq/all-tasks": "~1.2", - "contao/manager-bundle": "~4.9", - "contao-community-alliance/dc-general-contao-frontend": "^2.2" + "contao/manager-bundle": "^4.13.0 <5.0", + "phpcq/runner-bootstrap": "^1.0@dev", + "roave/security-advisories": "dev-latest" }, "autoload": { "psr-4": { @@ -41,11 +45,17 @@ "ContaoCommunityAlliance\\FormTextFieldMultipleBundle\\Test\\": "tests/" } }, + "config": { + "allow-plugins": { + "contao-components/installer": false, + "contao/manager-plugin": true, + "php-http/discovery": true + } + }, "extra": { - "contao-manager-plugin": "ContaoCommunityAlliance\\FormTextFieldMultipleBundle\\ContaoManager\\Plugin", "branch-alias": { - "dev-support/1.0.x": "1.0.x-dev", - "dev-master": "2.2.x-dev" - } + "dev-feature/2.3.0": "2.3.x-dev" + }, + "contao-manager-plugin": "ContaoCommunityAlliance\\FormTextFieldMultipleBundle\\ContaoManager\\Plugin" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..3403bd9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + + + + ./tests/ + + + + + + ./src/ + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..ceb6754 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/Contao/Widget/FormTextFieldMultiple.php b/src/Contao/Widget/FormTextFieldMultiple.php index b92c332..ff0c097 100644 --- a/src/Contao/Widget/FormTextFieldMultiple.php +++ b/src/Contao/Widget/FormTextFieldMultiple.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/contao-textfield-multiple-bundle. * - * (c) 2021 Contao Community Alliance. + * (c) 2021-2024 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -13,7 +13,7 @@ * @package contao-community-alliance/contao-textfield-multiple-bundle * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. + * @copyright 2021-2024 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE * LGPL-3.0-or-later * @filesource @@ -25,6 +25,12 @@ use Contao\FormTextField; +/** + * This class is used for the contao frontend view as template. + * + * @psalm-suppress PropertyNotSetInConstructor + * @psalm-suppress UndefinedThisPropertyFetch + */ class FormTextFieldMultiple extends FormTextField { /** @@ -37,17 +43,17 @@ class FormTextFieldMultiple extends FormTextField /** * Parse the template file and return it as string * - * @param array $attributes An optional attributes array + * @param array $arrAttributes An optional attributes array * * @return string The template markup */ - public function parse($attributes = null) + public function parse($arrAttributes = null): string { if (!$this->multiple) { $this->strTemplate = 'form_textfield'; } - return parent::parse($attributes); + return parent::parse($arrAttributes); } /** @@ -55,7 +61,7 @@ public function parse($attributes = null) * * @return string */ - public function generate() + public function generate(): string { if (!$this->multiple) { return parent::generate(); @@ -64,17 +70,19 @@ public function generate() $return = ''; $originalName = $this->strName; - $originalId = $this->strId; + $originalId = (string) $this->strId; $this->strName = $originalName . '[]'; for ($i = 0; $i < $this->size; $i++) { + /** @psalm-suppress InvalidPropertyAssignmentValue - incorrect annotation of Contao */ $this->strId = $originalId . '_' . $i; $return .= parent::generate(); } $this->strName = $originalName; - $this->strId = $originalId; + /** @psalm-suppress InvalidPropertyAssignmentValue - incorrect annotation of Contao */ + $this->strId = $originalId; return $return; } diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php index bd21947..34bd242 100644 --- a/src/ContaoManager/Plugin.php +++ b/src/ContaoManager/Plugin.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/contao-textfield-multiple-bundle. * - * (c) 2021 Contao Community Alliance. + * (c) 2021 - 2022 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,9 +11,8 @@ * This project is provided in good faith and hope to be usable by anyone. * * @package contao-community-alliance/contao-textfield-multiple-bundle - * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. + * @copyright 2021 - 2022 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE * LGPL-3.0-or-later * @filesource diff --git a/src/DcGeneral/Widget/TextFieldMultiple.php b/src/DcGeneral/Widget/TextFieldMultiple.php index 90e5eee..9abd3be 100644 --- a/src/DcGeneral/Widget/TextFieldMultiple.php +++ b/src/DcGeneral/Widget/TextFieldMultiple.php @@ -11,7 +11,6 @@ * This project is provided in good faith and hope to be usable by anyone. * * @package contao-community-alliance/contao-textfield-multiple-bundle - * @author Richard Henkenjohann * @author Ingolf Steinhardt * @copyright 2021 - 2022 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE diff --git a/src/DependencyInjection/FormTextFieldMultipleBundleExtension.php b/src/DependencyInjection/FormTextFieldMultipleBundleExtension.php deleted file mode 100644 index 3ec4302..0000000 --- a/src/DependencyInjection/FormTextFieldMultipleBundleExtension.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. - * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE - * LGPL-3.0-or-later - * @filesource - */ - -namespace ContaoCommunityAlliance\FormTextFieldMultipleBundle\DependencyInjection; - -use Symfony\Component\Config\FileLocator; -use Contao\CoreBundle\DependencyInjection\Configuration; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; - -class FormTextFieldMultipleBundleExtension extends Extension -{ - /** - * {@inheritdoc} - */ - public function getConfiguration(array $config, ContainerBuilder $container) - { - // Add the resource to the container - parent::getConfiguration($config, $container); - - #return new Configuration( - # $container->getParameter('kernel.debug'), - # $container->getParameter('kernel.project_dir'), - # $container->getParameter('kernel.root_dir'), - # $container->getParameter('kernel.default_locale') - #); - } - - public function load(array $configs, ContainerBuilder $container) - { - $loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__) . '/Resources/config')); - $loader->load('services.yml'); - } -} diff --git a/src/DependencyInjection/FormTextFieldMultipleExtension.php b/src/DependencyInjection/FormTextFieldMultipleExtension.php index a750e02..f417c3e 100644 --- a/src/DependencyInjection/FormTextFieldMultipleExtension.php +++ b/src/DependencyInjection/FormTextFieldMultipleExtension.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/contao-textfield-multiple-bundle. * - * (c) 2021 Contao Community Alliance. + * (c) 2021-2024 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,54 +11,33 @@ * This project is provided in good faith and hope to be usable by anyone. * * @package contao-community-alliance/contao-textfield-multiple-bundle - * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. + * @copyright 2021-2024 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE * LGPL-3.0-or-later * @filesource */ -declare(strict_types=1); - namespace ContaoCommunityAlliance\FormTextFieldMultipleBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; -use Contao\CoreBundle\DependencyInjection\Configuration; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension; -final class FormTextFieldMultipleExtension extends Extension +class FormTextFieldMultipleExtension extends Extension { /** * {@inheritdoc} */ - #public function getConfiguration(array $config, ContainerBuilder $container) - #{ - // Add the resource to the container - # parent::getConfiguration($config, $container); - - # return new Configuration( - # $container->getParameter('kernel.debug'), - # $container->getParameter('kernel.project_dir'), - # $container->getParameter('kernel.root_dir'), - # $container->getParameter('kernel.default_locale') - # ); - #} - - /** - * {@inheritDoc} - */ - /*protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void + public function getConfiguration(array $config, ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(\dirname(__DIR__) . '/Resources/config')); - $loader->load('services.yml'); - }*/ + // Add the resource to the container + parent::getConfiguration($config, $container); + } /** - * {@inheritDoc} + * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container): void { diff --git a/src/FormTextFieldMultipleBundle.php b/src/FormTextFieldMultipleBundle.php index 6f0506f..c3f5935 100644 --- a/src/FormTextFieldMultipleBundle.php +++ b/src/FormTextFieldMultipleBundle.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/contao-textfield-multiple-bundle. * - * (c) 2021 Contao Community Alliance. + * (c) 2021 - 2022 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,9 +11,8 @@ * This project is provided in good faith and hope to be usable by anyone. * * @package contao-community-alliance/contao-textfield-multiple-bundle - * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. + * @copyright 2021 - 2022 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE * LGPL-3.0-or-later * @filesource diff --git a/src/Resources/config/dc-general/widget.yml b/src/Resources/config/dc-general/widget.yml index 001ee71..70ba077 100644 --- a/src/Resources/config/dc-general/widget.yml +++ b/src/Resources/config/dc-general/widget.yml @@ -1,7 +1,7 @@ services: - ContaoCommunityAlliance\FormTextFieldMultipleBundle\DcGeneral\Widget\TextFieldMultiple: - public: false - tags: - - name: kernel.event_listener - event: dc-general.contao-frontend.build-widget - priority: 512 + ContaoCommunityAlliance\FormTextFieldMultipleBundle\DcGeneral\Widget\TextFieldMultiple: + public: false + tags: + - name: kernel.event_listener + event: dc-general.contao-frontend.build-widget + priority: 512 diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 8e1e145..a3c2538 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -1,2 +1,2 @@ imports: - - resource: dc-general/widget.yml + - resource: dc-general/widget.yml diff --git a/src/Resources/contao/config/config.php b/src/Resources/contao/config/config.php index 3909f67..775f619 100644 --- a/src/Resources/contao/config/config.php +++ b/src/Resources/contao/config/config.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/contao-textfield-multiple-bundle. * - * (c) 2021 Contao Community Alliance. + * (c) 2021 - 2022 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -11,9 +11,8 @@ * This project is provided in good faith and hope to be usable by anyone. * * @package contao-community-alliance/contao-textfield-multiple-bundle - * @author Richard Henkenjohann * @author Ingolf Steinhardt - * @copyright 2021 Contao Community Alliance. + * @copyright 2021 - 2022 Contao Community Alliance. * @license https://github.com/contao-community-alliance/contao-community-alliance/contao-textfield-multiple-bundle/blob/master/LICENSE * LGPL-3.0-or-later * @filesource diff --git a/tests/.empty b/tests/.empty new file mode 100644 index 0000000..e69de29