diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..d5c5bb64 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,57 @@ +# yamllint disable rule:line-length +# yamllint disable rule:braces + +name: CI + +on: + pull_request: + push: + branches: + - "master" + +jobs: + phpunit: + name: "PHPUnit" + runs-on: "ubuntu-20.04" + + strategy: + fail-fast: false + matrix: + symfony-version: + - '^4.4' + - '^5.4' + php-version: + - "7.4" + - "8.0" + - "8.1" + dependencies: + - "lowest" + - "highest" + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + ini-values: "zend.assertions=1" + + - name: Configure symfony version + uses: php-actions/composer@v6 + with: + command: config + args: extra.symfony.require ${{ matrix.symfony-version }} + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "${{ matrix.composer-options }}" + + - name: Run tests + run: | + SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/simple-phpunit ${PHPUNIT_FLAGS} diff --git a/.github/workflows/coding-standards.yaml b/.github/workflows/coding-standards.yaml new file mode 100644 index 00000000..40c98e65 --- /dev/null +++ b/.github/workflows/coding-standards.yaml @@ -0,0 +1,35 @@ +name: "Coding Standards" + +on: + pull_request: + push: + branches: + - "master" + +jobs: + coding-standards: + name: "Coding Standards" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + tools: "cs2pr" + extensions: pdo_sqlite + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + + - name: "Run PHP_CodeSniffer" + run: "vendor/bin/phpcs" diff --git a/.gitignore b/.gitignore index 1bc9c776..23a0948e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,38 @@ vendor/ .phpunit.result.cache .phpcs-cache phpcs.xml + + +/bin/ +/config/ +/public/ +/src/ +/templates +/tests +/translations +/var/ +/.env* +/.phpunit.result.cache + +.idea/ +/symfony.lock + +###> symfony/framework-bundle ### +/.env.local +/.env.local.php +/.env.*.local +/config/secrets/prod/prod.decrypt.private.php +/public/bundles/ +/var/ +/vendor/ +###< symfony/framework-bundle ### + +###> squizlabs/php_codesniffer ### +/.phpcs-cache +/phpcs.xml +###< squizlabs/php_codesniffer ### + +###> symfony/phpunit-bridge ### +.phpunit.result.cache +/phpunit.xml +###< symfony/phpunit-bridge ### diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d2aa294..00000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -language: php - -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -php: - - 7.2 - - 7.3 - - 7.4 - - 8.0 - -env: - global: - - TARGET=test - -matrix: - fast_finish: true - - include: - - php: 7.2 - env: COMPOSER_FLAGS="--prefer-lowest" - - php: 7.2 - env: TARGET=cs - - php: 7.2 - env: SYMFONY_VERSION=^3.4 - - php: 7.3 - env: SYMFONY_VERSION=^3.4 - - php: 7.4 - env: SYMFONY_VERSION=^3.4 - - php: 7.2 - env: SYMFONY_VERSION=^4.4 - - php: 7.3 - env: SYMFONY_VERSION=^4.4 - - php: 7.4 - env: SYMFONY_VERSION=^4.4 - - php: 8.0 - env: SYMFONY_VERSION=^4.4 - - php: 7.2 - env: SYMFONY_VERSION=^5.2 - - php: 7.3 - env: SYMFONY_VERSION=^5.2 - - php: 7.4 - env: SYMFONY_VERSION=^5.2 - - php: 8.0 - env: SYMFONY_VERSION=^5.2 - -install: - - if [ -x .travis/install_${TARGET}.sh ]; then .travis/install_${TARGET}.sh; fi; - -script: - - if [ -x .travis/script_${TARGET}.sh ]; then .travis/script_${TARGET}.sh; fi; - -after_success: - - if [ -x .travis/success_${TARGET}.sh ]; then .travis/success_${TARGET}.sh; fi; diff --git a/.travis/install_cs.sh b/.travis/install_cs.sh deleted file mode 100755 index 4dd1c034..00000000 --- a/.travis/install_cs.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -composer self-update --1 - -phpenv config-rm xdebug.ini - -composer update -n diff --git a/.travis/install_test.sh b/.travis/install_test.sh deleted file mode 100755 index c9df7224..00000000 --- a/.travis/install_test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -composer self-update --1 - -if [[ $SYMFONY_VERSION ]]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi - -COMPOSER_MEMORY_LIMIT=-1 composer update ${COMPOSER_FLAGS} --no-interaction diff --git a/.travis/script_cs.sh b/.travis/script_cs.sh deleted file mode 100755 index f1d9c4fa..00000000 --- a/.travis/script_cs.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -vendor/bin/phpcs diff --git a/.travis/script_test.sh b/.travis/script_test.sh deleted file mode 100755 index 1d759f3e..00000000 --- a/.travis/script_test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -vendor/bin/phpunit $PHPUNIT_FLAGS -phpenv config-rm xdebug.ini || true diff --git a/.travis/success_test.sh b/.travis/success_test.sh deleted file mode 100755 index 043daada..00000000 --- a/.travis/success_test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi -if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi diff --git a/Tests/Functional/Controller/ApiControllerTest.php b/Tests/Functional/Controller/ApiControllerTest.php index 14a13c08..d63c0a37 100644 --- a/Tests/Functional/Controller/ApiControllerTest.php +++ b/Tests/Functional/Controller/ApiControllerTest.php @@ -27,10 +27,13 @@ public function testUpdateAction() $this->assertTrue($written !== false && $written > 0); $client->request('POST', '/_trans/api/configs/app/domains/navigation/locales/en/messages?id=main.home', ['_method' => 'PUT', 'message' => 'Away']); + + $fileContent = is_file($file) ? file_get_contents($file) : ''; + unlink($file); $this->assertEquals(200, $client->getResponse()->getStatusCode()); // Verify that the file has new content - $array = Yaml::parse(file_get_contents($file)); + $array = Yaml::parse($fileContent); if ($isSf4) { $this->assertTrue(isset($array['main.home']), print_r($array, true)); @@ -40,8 +43,5 @@ public function testUpdateAction() $this->assertTrue(isset($array['main']['home'])); $this->assertEquals('Away', $array['main']['home']); } - - // Remove the file - unlink($file); } } diff --git a/Tests/Functional/config/framework.yml b/Tests/Functional/config/framework.yml index 53f86e6e..4d136549 100644 --- a/Tests/Functional/config/framework.yml +++ b/Tests/Functional/config/framework.yml @@ -6,9 +6,10 @@ framework: storage_id: session.storage.mock_file form: true csrf_protection: true + annotations: true + property_access: true validation: enabled: true - enable_annotations: true translator: enabled: true router: diff --git a/Tests/Functional/config/routing.yml b/Tests/Functional/config/routing.yml index 5c249b41..7e829169 100644 --- a/Tests/Functional/config/routing.yml +++ b/Tests/Functional/config/routing.yml @@ -5,4 +5,4 @@ JMSTranslationBundle_ui: TestBundle: type: annotation - resource: "@TestBundle/Controller/" \ No newline at end of file + resource: "@TestBundle/Controller/" diff --git a/Tests/Translation/Extractor/File/Fixture/MyFormModel.php b/Tests/Translation/Extractor/File/Fixture/MyFormModel.php index 964388e2..3838c5aa 100644 --- a/Tests/Translation/Extractor/File/Fixture/MyFormModel.php +++ b/Tests/Translation/Extractor/File/Fixture/MyFormModel.php @@ -32,7 +32,9 @@ class MyFormModel implements TranslationContainerInterface 'bar' => 'form.label.choice.bar', ]; - /** @Assert\NotBlank(message = "form.error.name_required") */ + /** + * @Assert\NotBlank(message = "form.error.name_required") + */ public $name; public static function getTranslationMessages() diff --git a/Translation/Extractor/File/DefaultPhpFileExtractor.php b/Translation/Extractor/File/DefaultPhpFileExtractor.php index 910a52d3..4d9287c3 100644 --- a/Translation/Extractor/File/DefaultPhpFileExtractor.php +++ b/Translation/Extractor/File/DefaultPhpFileExtractor.php @@ -162,7 +162,7 @@ public function enterNode(Node $node) $index = $this->methodsToExtractFrom[strtolower($methodCallNodeName)]; $domainArg = null; - if (isset($node->args[$index]) && $node->args[$index] instanceof Node\Arg && null === $node->args[$index]->name ) { + if (isset($node->args[$index]) && $node->args[$index] instanceof Node\Arg && null === $node->args[$index]->name) { $domainArg = $node->args[$index]; } else { foreach ($node->args as $arg) { diff --git a/Translation/Loader/XliffLoader.php b/Translation/Loader/XliffLoader.php index 05726cd9..129c328a 100644 --- a/Translation/Loader/XliffLoader.php +++ b/Translation/Loader/XliffLoader.php @@ -129,6 +129,7 @@ private function libxmlDisableEntityLoader(bool $disable): bool return true; } + // phpcs:ignore return libxml_disable_entity_loader($disable); } } diff --git a/composer.json b/composer.json index 3bed42e7..553c3adb 100644 --- a/composer.json +++ b/composer.json @@ -21,39 +21,50 @@ } ], "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "nikic/php-parser": "^4.9", - "symfony/console": "^3.4 || ^4.3 || ^5.0", - "symfony/expression-language": "^3.4 || ^4.3 || ^5.0", - "symfony/framework-bundle": "^3.4.31 || ^4.3 || ^5.0", - "symfony/translation": "^3.4 || ^4.3 || ^5.0", + "symfony/console": "^4.3 || ^5.4", + "symfony/expression-language": "^4.3 || ^5.4", + "symfony/framework-bundle": "^4.3 || ^5.4", + "symfony/translation": "^4.3 || ^5.4", "symfony/translation-contracts": "^1.1 || ^2.0", - "symfony/validator": "^3.4 || ^4.3 || ^5.0", + "symfony/validator": "^4.3 || ^5.4", "twig/twig": "^1.42.4 || ^2.12.5 || ^3.0" }, "require-dev": { - "doctrine/annotations": "^1.8", - "doctrine/coding-standard": "^8.0", + "doctrine/annotations": "^1.11", + "doctrine/coding-standard": "^8.2.1", "matthiasnoback/symfony-dependency-injection-test": "^4.1", "nyholm/nsa": "^1.0.1", - "phpunit/phpunit": "^8.3", + "symfony/phpunit-bridge": ">=5.4", "psr/log": "^1.0", - "sensio/framework-extra-bundle": "^5.4", - "symfony/asset": "^3.4 || ^4.3 || ^5.0", - "symfony/browser-kit": "^3.4 || ^4.3 || ^5.0", - "symfony/css-selector": "^3.4 || ^4.3 || ^5.0", - "symfony/filesystem": "^3.4 || ^4.3 || ^5.0", - "symfony/form": "^3.4 || ^4.3 || ^5.0", - "symfony/security-csrf": "^3.4 || ^4.3 || ^5.0", - "symfony/templating": "^3.4 || ^4.3 || ^5.0", - "symfony/twig-bundle": "^3.4.37 || ^4.3.11 || ^5.0" + "sensio/framework-extra-bundle": "^5.5.4", + "symfony/asset": "^4.3 || ^5.4", + "symfony/browser-kit": "^4.3 || ^5.4", + "symfony/css-selector": "^4.3 || ^5.4", + "symfony/filesystem": "^4.3 || ^5.4", + "symfony/form": "^4.3 || ^5.4", + "symfony/security-csrf": "^4.3 || ^5.4", + "symfony/templating": "^4.3 || ^5.4", + "symfony/property-access": "^4.3 || ^5.4", + "symfony/routing": "^4.4.15 || ^5.4", + "symfony/twig-bundle": "^4.3.11 || ^5.4", + "symfony/flex": "^1.19 || ^2.0" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "symfony/flex": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" + }, + "symfony": { + "allow-contrib": true, + "require": "^5.4" } }, "autoload": { @@ -61,5 +72,10 @@ "JMS\\TranslationBundle\\": "" } }, - "minimum-stability": "stable" + "scripts": { + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + } + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 4f50e4d9..c1ca707b 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,6 +4,7 @@ +