Skip to content

Commit

Permalink
Merge branch '2.14.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.14.x:
  Bump Ubuntu version and shared workflows (doctrine#10020)
  Make paginator covariant (doctrine#10002)
  Fail gracefully if EM could not be constructed in tests (doctrine#10008)
  • Loading branch information
derrabus committed Aug 30, 2022
2 parents cdd79bc + 7a9037e commit 58990c9
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 17 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ on:

jobs:
coding-standards:
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1"
with:
php-version: "8.1"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@2.0.0"
10 changes: 5 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
phpunit-smoke-check:
name: "PHPUnit with SQLite"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"

strategy:
matrix:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:

phpunit-postgres:
name: "PHPUnit with PostgreSQL"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
needs: "phpunit-smoke-check"

strategy:
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:

phpunit-mariadb:
name: "PHPUnit with MariaDB"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
needs: "phpunit-smoke-check"

strategy:
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:

phpunit-mysql:
name: "PHPUnit with MySQL"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
needs: "phpunit-smoke-check"

strategy:
Expand Down Expand Up @@ -296,7 +296,7 @@ jobs:

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
needs:
- "phpunit-smoke-check"
- "phpunit-postgres"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpbench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
jobs:
phpbench:
name: "PHPBench"
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"

strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
release:
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.0.0"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
static-analysis-phpstan:
name: Static Analysis with PHPStan
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:

static-analysis-psalm:
name: Static Analysis with Psalm
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
Expand Down
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Tools/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
use Iterator;
use IteratorAggregate;
use Traversable;

use function array_key_exists;
use function array_map;
Expand All @@ -25,7 +25,7 @@
/**
* The paginator can handle various complex scenarios with DQL.
*
* @template T
* @template-covariant T
*/
class Paginator implements Countable, IteratorAggregate
{
Expand Down Expand Up @@ -101,9 +101,9 @@ public function count(): int
/**
* {@inheritdoc}
*
* @psalm-return Iterator<array-key, T>
* @psalm-return Traversable<array-key, T>
*/
public function getIterator(): Iterator
public function getIterator(): Traversable
{
$offset = $this->query->getFirstResult();
$length = $this->query->getMaxResults();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace Doctrine\StaticAnalysis\Tools\Pagination;

use Doctrine\ORM\Tools\Pagination\Paginator;

/**
* @template-covariant T of object
*/
abstract class PaginatorFactory
{
/** @var class-string<T> */
private $class;

/**
* @param class-string<T> $class
*/
final public function __construct(string $class)
{
$this->class = $class;
}

/**
* @return class-string<T>
*/
public function getClass(): string
{
return $this->class;
}

/**
* @psalm-return Paginator<T>
*/
abstract public function createPaginator(): Paginator;
}

interface Animal
{
}

class Cat implements Animal
{
}

/**
* @param Paginator<Animal> $paginator
*/
function getFirstAnimal(Paginator $paginator): ?Animal
{
foreach ($paginator as $result) {
return $result;
}

return null;
}

/**
* @param PaginatorFactory<Cat> $catPaginatorFactory
*/
function test(PaginatorFactory $catPaginatorFactory): ?Animal
{
return getFirstAnimal($catPaginatorFactory->createPaginator());
}
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/OrmFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ protected function setUpDBALTypes(): void

final protected function isQueryLogAvailable(): bool
{
return $this->_em->getConnection() instanceof Connection;
return $this->_em?->getConnection() instanceof Connection;
}

final protected function getQueryLog(): QueryLog
Expand Down

0 comments on commit 58990c9

Please sign in to comment.