Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility issues with Doctrine. #460

Open
wants to merge 2 commits into
base: 6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Run tests


on:
push:
branches: [ "master" ]
Expand All @@ -9,6 +10,7 @@ on:
permissions:
contents: read


jobs:
build:

Expand All @@ -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
6 changes: 5 additions & 1 deletion Entity/TransUnitRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, a
/**
* Count the number of trans unit.
*
* @param array<string, mixed> $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);

Expand Down
13 changes: 12 additions & 1 deletion Util/Doctrine/SingleColumnArrayHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -14,7 +16,7 @@ class SingleColumnArrayHydrator extends AbstractHydrator
/**
* {@inheritdoc}
*/
protected function hydrateAllData()
protected function hydrateAllData(): mixed
{
$result = [];

Expand All @@ -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);
}
}