diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml index a865103..83318ed 100644 --- a/.github/workflows/diagnostics.yml +++ b/.github/workflows/diagnostics.yml @@ -15,17 +15,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - php: 7.4 - output: '-o github-action -o default' - phpcq_install: 'install' - - php: 8.0 - output: '-o default' - phpcq_install: 'update' + php: ['7.4', '8.0', '8.1', '8.2'] + phpcq_install: ['update'] + output: ['-o github-action -o default'] steps: - name: Pull source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@v2 @@ -33,7 +29,7 @@ jobs: php-version: ${{ matrix.php }} - name: Cache composer cache directory - uses: actions/cache@v1 + uses: actions/cache@v3 env: cache-name: composer-cache-dir with: @@ -41,7 +37,7 @@ jobs: key: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }} - name: Cache vendor directory - uses: actions/cache@v1 + uses: actions/cache@v3 env: cache-name: vendor with: @@ -51,7 +47,7 @@ jobs: ${{ runner.os }}-${{ matrix.php }}-build-${{ env.cache-name }}- - name: Cache phpcq directory - uses: actions/cache@v1 + uses: actions/cache@v3 env: cache-name: phpcq with: @@ -70,7 +66,7 @@ jobs: run: ./vendor/bin/phpcq run -v ${{ matrix.output }} - name: Upload build directory to artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: ${{ success() }} || ${{ failure() }} with: name: phpcq-builds-php-${{ matrix.php }} diff --git a/src/Contao/LangArrayTranslator.php b/src/Contao/LangArrayTranslator.php index 9b859fb..95cfb19 100644 --- a/src/Contao/LangArrayTranslator.php +++ b/src/Contao/LangArrayTranslator.php @@ -3,7 +3,7 @@ /** * This file is part of contao-community-alliance/translator. * - * (c) 2013-2021 Contao Community Alliance. + * (c) 2013-2023 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -14,7 +14,8 @@ * @author Christian Schiffler * @author Tristan Lins * @author Sven Baumann - * @copyright 2013-2021 Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2013-2023 Contao Community Alliance. * @license https://github.com/contao-community-alliance/translator/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -53,8 +54,13 @@ public function __construct(EventDispatcherInterface $eventDispatcher) } /** - * {@inheritDoc} + * Retrieve the value. * + * @param mixed $string The string to translate. + * @param string|null $domain The domain to use. + * @param string|null $locale The locale (otherwise the current default locale will get used). + * + * @return array|string * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) * @@ -62,6 +68,13 @@ public function __construct(EventDispatcherInterface $eventDispatcher) */ protected function getValue($string, $domain, $locale) { + if (false === \is_string($string)) { + // @codingStandardsIgnoreStart + @\trigger_error('Only string allowed to translate!', E_USER_DEPRECATED); + // @codingStandardsIgnoreEnd + return ''; + } + if (null === $domain) { $domain = 'default'; }