diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..160a262 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +vendor +*.cache +composer.lock +tools/php-cs-fixer/composer.lock +.git +.idea +Dockerfile diff --git a/.github/workflows/CI.yaml b/.github/workflows/ci.yml similarity index 99% rename from .github/workflows/CI.yaml rename to .github/workflows/ci.yml index ede417b..ae8fc6b 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/ci.yml @@ -1,5 +1,4 @@ name: CI - on: [push] jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4554748..992e3d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Sclable XML Lint - Changelog ============================ +0.5.0 +----- + +* Add support for PHP 8.1 +* Drop support for PHP 7.3 +* Chores: remove Travis integration + 0.4.0 ----- diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..23d2102 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +ARG PHP_VERSION +FROM php:${PHP_VERSION}-cli-alpine AS dependencies +ARG PHP_CS_FIXER +RUN apk add --update --no-cache zip unzip php-zip +COPY --from=composer /usr/bin/composer /usr/bin/composer +RUN addgroup -S php && adduser -S php -G php \ + && mkdir -p /usr/src/xml-lint \ + && chown php:php -R /usr/src/xml-lint +WORKDIR /usr/src/xml-lint +COPY --chown=php:php . ./ +USER php +RUN composer install --prefer-dist -o -a -n --no-progress \ + && \ + if [[ -n "${PHP_CS_FIXER}" ]]; then \ + composer install --working-dir=tools/php-cs-fixer --prefer-dist -o -a -n --no-progress; \ + fi + +FROM php:${PHP_VERSION}-cli-alpine AS test +ARG PHP_CS_FIXER +RUN addgroup -S php && adduser -S php -G php \ + && mkdir -p /usr/src/xml-lint \ + && chown php:php -R /usr/src/xml-lint + +WORKDIR /usr/src/xml-lint +COPY --from=dependencies --chown=php:php /usr/src/xml-lint ./ +USER php + +RUN if [[ -n "${PHP_CS_FIXER}" ]]; then \ + php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run -v; \ + fi +RUN php vendor/bin/phpunit +RUN php vendor/bin/behat + +FROM dependencies AS build_production +WORKDIR /usr/src/xml-lint + +RUN rm -rf tools/ tests/ \ + && composer install --prefer-dist -o -a -n --no-progress --no-dev + +FROM php:${PHP_VERSION}-cli-alpine AS production +WORKDIR /usr/src/xml-lint +COPY --from=build_production /usr/src/xml-lint ./ +RUN ln -s /usr/src/xml-lint/bin/xmllint /usr/bin/xml-lint +WORKDIR /usr/src +ENTRYPOINT ["php", "/usr/src/xml-lint/bin/xmllint"] +CMD ["--help"] \ No newline at end of file diff --git a/README.md b/README.md index 136ebd4..ed3099f 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,40 @@ To lint a directory and all its subdirectories: * `-s` skip the xsd validation +Development +----------- + +### Run tests + +```shell +# check code style +php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run -v + +# run tests +php vendor/bin/phpunit +php vendor/bin/behat +``` + +Using docker: + +```shell +# Example +docker build -t xml-lint:php-8.1 --build-arg=PHP_VERSION="8.1" . + +# PHP_VERSION: choose between 7.4, 8.0 and 8.1 +docker build -t xml-lint:php-7.4 --build-arg=PHP_VERSION="7.4" . +docker build -t xml-lint:php-8.0 --build-arg=PHP_VERSION="8.0" . +docker build -t xml-lint:php-8.1 --build-arg=PHP_VERSION="8.1" . + +# Run with code style check +docker build -t xml-lint:php-7.4 --build-arg=PHP_VERSION="7.4" --build-arg=PHP_CS_FIXER=true . + +# Use this image to run xml-lint: +cd tests/functional/_testdata +docker run -it --rm -v "$PWD":/var/src -w /var/src xml-lint:php-7.4 -r -v -- ./ +``` + + Changelog --------- diff --git a/composer.json b/composer.json index 8cc4287..78d5da7 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,11 @@ ], "bin": ["bin/xmllint"], "require": { - "php": "7.3.*|7.4.*|8.0.*", - "symfony/console": "3.4.*|4.4.*|5.*", - "symfony/finder": "3.4.*|4.4.*|5.*", + "php": "~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0", + "ext-dom": "*", "ext-libxml": "*", - "ext-dom": "*" + "symfony/console": "^3.4 || ^4.4 || ^5 || ^6", + "symfony/finder": "^3.4 || ^4.4 || ^5 || ^6" }, "require-dev": { "behat/behat": "^3.0", diff --git a/src/php/console/application/Application.php b/src/php/console/application/Application.php index 59a3ecb..a5b5211 100644 --- a/src/php/console/application/Application.php +++ b/src/php/console/application/Application.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -42,7 +42,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') /** * {@inheritdoc} */ - protected function getDefaultCommands() + protected function getDefaultCommands(): array { parent::getDefaultCommands(); @@ -57,7 +57,7 @@ protected function getDefaultCommands() * * @SuppressWarnings(PHPMD.Superglobals) */ - public function run(InputInterface $input = null, OutputInterface $output = null) + public function run(InputInterface $input = null, OutputInterface $output = null): int { if (null === $input) { // rewrite the input for single command usage diff --git a/src/php/console/command/Command.php b/src/php/console/command/Command.php index a5fc5cd..8d83b8d 100644 --- a/src/php/console/command/Command.php +++ b/src/php/console/command/Command.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -26,7 +26,7 @@ class Command extends BaseCommand * * @SuppressWarnings(PHPMD.Superglobals) */ - public function getSynopsis($short = false) + public function getSynopsis($short = false): string { $key = $short ? 'short' : 'long'; diff --git a/src/php/console/command/HelpCommand.php b/src/php/console/command/HelpCommand.php index 902e104..540d852 100644 --- a/src/php/console/command/HelpCommand.php +++ b/src/php/console/command/HelpCommand.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -60,12 +60,12 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->setCommand( $this->getApplication()->find(LintCommand::COMMAND_NAME) ); - parent::execute($input, $output); + return parent::execute($input, $output); } } diff --git a/src/php/console/command/LintCommand.php b/src/php/console/command/LintCommand.php index 797f056..60d0ca4 100644 --- a/src/php/console/command/LintCommand.php +++ b/src/php/console/command/LintCommand.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/data/FileReport.php b/src/php/data/FileReport.php index 494eec5..0a0563b 100644 --- a/src/php/data/FileReport.php +++ b/src/php/data/FileReport.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/data/ValidationProblem.php b/src/php/data/ValidationProblem.php index 60588ee..0d67248 100644 --- a/src/php/data/ValidationProblem.php +++ b/src/php/data/ValidationProblem.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/LintValidation.php b/src/php/validator/LintValidation.php index ea7f597..cc43237 100644 --- a/src/php/validator/LintValidation.php +++ b/src/php/validator/LintValidation.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/ValidationCollection.php b/src/php/validator/ValidationCollection.php index 0d6581f..b49dfc6 100644 --- a/src/php/validator/ValidationCollection.php +++ b/src/php/validator/ValidationCollection.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/ValidationFactory.php b/src/php/validator/ValidationFactory.php index ceb48bb..a9b4031 100644 --- a/src/php/validator/ValidationFactory.php +++ b/src/php/validator/ValidationFactory.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/ValidationInterface.php b/src/php/validator/ValidationInterface.php index bf33ecf..636ed90 100644 --- a/src/php/validator/ValidationInterface.php +++ b/src/php/validator/ValidationInterface.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/XsdValidation.php b/src/php/validator/XsdValidation.php index 9f886f7..da825bc 100644 --- a/src/php/validator/XsdValidation.php +++ b/src/php/validator/XsdValidation.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/php/validator/helper/LibXmlErrorFormatter.php b/src/php/validator/helper/LibXmlErrorFormatter.php index 03b31cb..f926ca6 100644 --- a/src/php/validator/helper/LibXmlErrorFormatter.php +++ b/src/php/validator/helper/LibXmlErrorFormatter.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/functional/contexts/FeatureContext.php b/tests/functional/contexts/FeatureContext.php index e8a3d40..1c06e10 100644 --- a/tests/functional/contexts/FeatureContext.php +++ b/tests/functional/contexts/FeatureContext.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/bootstrap.inc.php b/tests/unit/bootstrap.inc.php index 706dbfc..f3a92cb 100644 --- a/tests/unit/bootstrap.inc.php +++ b/tests/unit/bootstrap.inc.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/check-coverage.php b/tests/unit/check-coverage.php index aa1bbbc..dd29e52 100644 --- a/tests/unit/check-coverage.php +++ b/tests/unit/check-coverage.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/data/FileReportTest.php b/tests/unit/data/FileReportTest.php index f1caaee..e591968 100644 --- a/tests/unit/data/FileReportTest.php +++ b/tests/unit/data/FileReportTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/data/ValidationProblemTest.php b/tests/unit/data/ValidationProblemTest.php index ee53601..a6253e2 100644 --- a/tests/unit/data/ValidationProblemTest.php +++ b/tests/unit/data/ValidationProblemTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/validator/LintValidationTest.php b/tests/unit/validator/LintValidationTest.php index 0996487..c5e4c02 100644 --- a/tests/unit/validator/LintValidationTest.php +++ b/tests/unit/validator/LintValidationTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/validator/ValidationCollectionTest.php b/tests/unit/validator/ValidationCollectionTest.php index 4cd8856..39088bf 100644 --- a/tests/unit/validator/ValidationCollectionTest.php +++ b/tests/unit/validator/ValidationCollectionTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/validator/ValidationFactoryTest.php b/tests/unit/validator/ValidationFactoryTest.php index a3c7be7..1a6a66f 100644 --- a/tests/unit/validator/ValidationFactoryTest.php +++ b/tests/unit/validator/ValidationFactoryTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/validator/XsdValidationTest.php b/tests/unit/validator/XsdValidationTest.php index 9d4006a..45b4596 100644 --- a/tests/unit/validator/XsdValidationTest.php +++ b/tests/unit/validator/XsdValidationTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/tests/unit/validator/helper/LibXmlErrorFormatterTest.php b/tests/unit/validator/helper/LibXmlErrorFormatterTest.php index 795f19a..2cf432a 100644 --- a/tests/unit/validator/helper/LibXmlErrorFormatterTest.php +++ b/tests/unit/validator/helper/LibXmlErrorFormatterTest.php @@ -3,7 +3,7 @@ /** * This file is part of the Sclable Xml Lint Package. * - * @copyright (c) 2020 Sclable Business Solutions GmbH + * @copyright (c) 2022 Sclable Business Solutions GmbH * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code.