diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9175c637..1786c80d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,5 +1,6 @@ name: Run tests + on: push: branches: [ "master" ] @@ -9,6 +10,7 @@ on: permissions: contents: read + jobs: build: @@ -32,26 +34,32 @@ jobs: MONGO_INITDB_ROOT_PASSWORD: secret steps: - - uses: actions/checkout@v3 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: mbstring, intl + + - uses: actions/checkout@v4 - - name: Validate composer.json and composer.lock - run: composer validate --strict + - name: Validate composer.json and composer.lock + run: composer validate --strict - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- - - name: Install dependencies - run: composer install --prefer-dist --no-progress + - name: Install dependencies + run: composer install --prefer-dist --no-progress - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md - - name: Run test suite - run: | - composer test + - name: Run test suite + run: | + composer test diff --git a/Entity/TransUnitRepository.php b/Entity/TransUnitRepository.php index 084aa820..051201d2 100644 --- a/Entity/TransUnitRepository.php +++ b/Entity/TransUnitRepository.php @@ -111,15 +111,19 @@ public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, a /** * Count the number of trans unit. * + * @param array $criteria * @return int */ - public function count(array $locales = null, array $filters = null) + public function count(array $criteria = []): int { $this->loadCustomHydrator(); $builder = $this->createQueryBuilder('tu') ->select('COUNT(DISTINCT tu.id) AS number'); + $locales = $criteria['locales'] ?? null; + $filters = $criteria['filters'] ?? null; + $this->addTransUnitFilters($builder, $filters); $this->addTranslationFilter($builder, $locales, $filters); diff --git a/Util/Doctrine/SingleColumnArrayHydrator.php b/Util/Doctrine/SingleColumnArrayHydrator.php index e989aaa6..3078faae 100644 --- a/Util/Doctrine/SingleColumnArrayHydrator.php +++ b/Util/Doctrine/SingleColumnArrayHydrator.php @@ -2,6 +2,8 @@ namespace Lexik\Bundle\TranslationBundle\Util\Doctrine; +use Doctrine\DBAL\Result; +use Doctrine\ORM\Query\ResultSetMapping; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; /** @@ -14,7 +16,7 @@ class SingleColumnArrayHydrator extends AbstractHydrator /** * {@inheritdoc} */ - protected function hydrateAllData() + protected function hydrateAllData(): mixed { $result = []; @@ -34,4 +36,13 @@ protected function hydrateAllData() return $result; } + + /** + * {@inheritdoc} + */ + public function hydrateAll(Result $stmt, ResultSetMapping $resultSetMapping, array $hints = []): mixed + { + $this->_stmt = $stmt; + return parent::hydrateAll($stmt, $resultSetMapping, $hints); + } }