Skip to content
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
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
tests:
name: PHP ${{ matrix.php }} - ${{ matrix.dependencies }} deps
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Symfony 7.4, Doctrine ORM 2.20, PHPUnit 11
- php: '8.2'
dependencies: lowest
# Symfony 7.4
- php: '8.3'
dependencies: highest
# Symfony 8, with the optional PhpSpreadsheet exports
- php: '8.4'
dependencies: highest
spreadsheet: true
- php: '8.5'
dependencies: highest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo_sqlite, gd, zip
coverage: none

- name: Require PhpSpreadsheet
if: ${{ matrix.spreadsheet }}
run: composer require --dev --no-update phpoffice/phpspreadsheet

- uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}

- run: vendor/bin/phpunit

quality:
name: PHPStan & PHP CS Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none

- uses: ramsey/composer-install@v3

- run: vendor/bin/phpstan analyse --no-progress
- run: vendor/bin/php-cs-fixer fix --dry-run --diff
- run: composer audit
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ catalog.xml
.htpasswd
vendor/
composer.lock
/.phpunit.result.cache
/.phpunit.result.cache
/.phpunit.cache/
/.php-cs-fixer.cache
/var/
14 changes: 14 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude(['var', 'vendor'])
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'@PHP82Migration' => true,
])
->setFinder($finder)
;
1 change: 0 additions & 1 deletion .phpunit.result.cache

This file was deleted.

17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

38 changes: 7 additions & 31 deletions Bridge/Doctrine/Helper/QueryBuilderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,24 @@

namespace Spyrit\Bundle\DoctrineDatagridBundle\Bridge\Doctrine\Helper;

use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;

class QueryBuilderHelper
{
public static function addLeftJoin(string $field, string $alias, QueryBuilder $qb): QueryBuilder
{
$parts = $qb->getDQLParts()['join'];
$exists = false;
/** @var array<string, Join[]> $joinsByRootAlias */
$joinsByRootAlias = $qb->getDQLPart('join');

foreach ($parts as $joins) {
foreach ($joinsByRootAlias as $joins) {
foreach ($joins as $join) {
foreach ((array) $join as $key => $val) {
if ($val == $alias) {
$exists = true;
break 3;
}
if ($join->getAlias() === $alias) {
return $qb;
}
}
}

/*
* The following code is only available for Doctrine 2.5
*/
/*$parts = $qb->getDQLPart('join');
$exists = false;

foreach ($parts as $joins)
{
foreach ($joins as $join)
{
if ($join->getAlias() === $alias)
{
$exists = true;
break 2;
}
}
}*/

if (!$exists) {
$qb->leftJoin($field, $alias);
}

return $qb;
return $qb->leftJoin($field, $alias);
}
}
Loading
Loading