Skip to content
Merged
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
29 changes: 4 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,8 @@ on:
- cron: '0 0 1,16 * *'

jobs:
test:
name: PHP ${{ matrix.php }}, SF ${{ matrix.symfony }} - ${{ matrix.deps }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.1, 8.2, 8.3, 8.4 ]
deps: [ highest ]
symfony: [ 6.4.*, 7.2.*, 7.3.* ]
include:
- php: 8.1
deps: lowest
symfony: '*'
exclude:
- php: 8.1
symfony: 7.2.*
- php: 8.1
symfony: 7.3.*
steps:
- uses: zenstruck/.github/actions/php-test-symfony@main
with:
php: ${{ matrix.php }}
symfony: ${{ matrix.symfony }}
deps: ${{ matrix.deps }}
tests:
uses: zenstruck/.github/.github/workflows/php-test-symfony.yml@main

code-coverage:
uses: zenstruck/.github/.github/workflows/php-coverage-codecov.yml@main
Expand All @@ -46,7 +25,7 @@ jobs:
if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: zenstruck/.github@php-cs-fixer
- uses: zenstruck/.github/actions/php-cs-fixer@main
with:
php: 8.1
key: ${{ secrets.GPG_PRIVATE_KEY }}
Expand All @@ -57,7 +36,7 @@ jobs:
if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: zenstruck/.github@sync-with-template
- uses: zenstruck/.github/actions/sync-with-template@main
with:
key: ${{ secrets.GPG_PRIVATE_KEY }}
token: ${{ secrets.COMPOSER_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/vendor/
/build/
/var/
/config/reference.php
/.php-cs-fixer.cache
/.phpunit.result.cache
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@
"require-dev": {
"composer-runtime-api": "^2.0",
"doctrine/collections": "^2.1",
"doctrine/dbal": "^3.0|^4.0",
"doctrine/doctrine-bundle": "^2.7",
"doctrine/orm": "^2.15|^3.0",
"doctrine/dbal": ">=3.0",
"doctrine/doctrine-bundle": "^2.7|^3.0",
"doctrine/orm": "^2.20.7|^3.5.3",
"pagerfanta/pagerfanta": "^1.0|^2.0|^3.0|^4.0",
"phpstan/phpstan": "^2.1.17",
"phpunit/phpunit": "^9.6.21",
"symfony/expression-language": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/phpunit-bridge": "^6.3|^7.0",
"symfony/var-dumper": "^6.4|^7.0",
"zenstruck/foundry": "^1.38.3",
"symfony/expression-language": "^6.4|^7.0|^8.0",
"symfony/framework-bundle": "^6.4|^7.0|^8.0",
"symfony/phpunit-bridge": "^6.3|^7.0|^8.0",
"symfony/var-dumper": "^6.4|^7.0|^8.0",
"zenstruck/foundry": "^2.0",
"zenstruck/uri": "^2.3"
},
"suggest": {
"doctrine/orm": "To use ORM implementation and batch utilities (>=2.15).",
"doctrine/dbal": "To use DBAL implementation (>=3.0).",
"doctrine/orm": "To use ORM implementation and batch utilities (>=2.20.7).",
"doctrine/collections": "To use CollectionDecorator.",
"pagerfanta/pagerfanta": "To use CollectionAdapter."
},
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function fill(int $start, int $count, mixed $value): self

public function first(mixed $default = null): mixed
{
return $this->source[\array_key_first($this->source)] ?? $default;
return $this->source[\array_key_first($this->source) ?? ''] ?? $default;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/Doctrine/ORM/EntityResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class EntityResult implements Result
private $resultModifier;

/** @var Query::HYDRATE_*|null */
private ?int $hydrationMode = null; // @phpstan-ignore property.unusedType, property.unusedType, property.unusedType, property.unusedType
private ?int $hydrationMode = null;
private bool $fetchJoins = true;

private bool $readonly = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Collection/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(iterable|callable $source = [])
$source = $source(...); // @phpstan-ignore callable.nonCallable
}

$this->source = \is_array($source) ? new \ArrayIterator($source) : $source; // @phpstan-ignore assign.propertyType
$this->source = \is_array($source) ? new \ArrayIterator($source) : $source;
}

/**
Expand Down
14 changes: 10 additions & 4 deletions tests/Doctrine/HasDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ trait HasDatabase
*/
protected function setupEntityManager(): void
{
$configuration = new Configuration();
$configuration->setMiddlewares([new DebugMiddleware($this->debugDataHolder = new DebugDataHolder(), null)]);
$connectionConfig = new Configuration();
$connectionConfig->setMiddlewares([new DebugMiddleware($this->debugDataHolder = new DebugDataHolder(), null)]);

$ormConfig = ORMSetup::createAttributeMetadataConfiguration([], true);

if (\PHP_VERSION_ID > 80400) {
$ormConfig->enableNativeLazyObjects(true);
}

$this->em = new EntityManager(
DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $configuration),
ORMSetup::createAttributeMetadataConfiguration([], true),
DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $connectionConfig),
$ormConfig,
);

$schemaTool = new SchemaTool($this->em);
Expand Down
11 changes: 6 additions & 5 deletions tests/Doctrine/ORM/Result/AggregateEntityResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,19 @@ public function exception_when_paginating_if_result_does_not_have_aggregate_fiel
/**
* @test
*/
public function exception_when_iterating_if_result_has_aggregate_fields(): void
public function can_iterate_over_result_with_aggregate_fields(): void
{
$this->persistEntities(3);

$result = new EntityResult($this->em->createQueryBuilder()->select('e')->from(Entity::class, 'e')
->addSelect('UPPER(e.value) AS extra'),
);

$this->expectException(\LogicException::class);
$this->expectExceptionMessage(\sprintf('Results contain aggregate fields, call %s::withAggregates().', EntityResult::class));

\iterator_to_array($result);
$this->assertEquals([
[0 => new Entity('value 1', 1), 'extra' => 'VALUE 1'],
[0 => new Entity('value 2', 2), 'extra' => 'VALUE 2'],
[0 => new Entity('value 3', 3), 'extra' => 'VALUE 3'],
], \iterator_to_array($result));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function invalid_limit(): void

protected function createWithItems(int $count): Page
{
return $this->createPage($count ? \range(1, $count) : [], 1, (int) \INF);
return $this->createPage($count ? \range(1, $count) : [], 1, 9999999999);
}

private function createPage(array $results, int $page, int $limit = Page::DEFAULT_LIMIT): Page
Expand Down
6 changes: 0 additions & 6 deletions tests/Symfony/Fixture/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
'test' => true,
]);

$c->loadFromExtension('zenstruck_foundry', [
'auto_refresh_proxies' => true,
]);

$c->loadFromExtension('doctrine', [
'dbal' => ['url' => 'sqlite:///%kernel.project_dir%/var/data.db'],
'orm' => [
'auto_generate_proxy_classes' => true,
'auto_mapping' => true,
'mappings' => [
'Test' => [
'is_bundle' => false,
Expand Down