Skip to content

Commit 5a81825

Browse files
authored
Merge pull request #606 from greg0ire/fix-build
Address newly detected PHPStan issues
2 parents 5a6ac71 + 6514890 commit 5a81825

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/EventListener/SchemaFilterListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(string $configurationTableName)
2727
/** @var bool */
2828
private $enabled = false;
2929

30-
/** @param AbstractAsset|string $asset */
30+
/** @param AbstractAsset<*>|string $asset */
3131
public function __invoke($asset): bool
3232
{
3333
if (! $this->enabled) {

tests/Collector/EventListener/SchemaFilterListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testItFiltersNothingWhenNotRunningSpecificCommands(): void
4949
public function testItFiltersOutMigrationMetadataTableWhenRunningSpecificCommands(string $command): void
5050
{
5151
$listener = new SchemaFilterListener('doctrine_migration_versions');
52-
$ormCommand = new $command($this->createStub(EntityManagerProvider::class));
52+
$ormCommand = new $command(self::createStub(EntityManagerProvider::class));
5353

5454
$listener->onConsoleCommand(new ConsoleCommandEvent(
5555
$ormCommand,

tests/DependencyInjection/DoctrineMigrationsExtensionTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
use function sys_get_temp_dir;
4242
use function trait_exists;
4343

44+
use const PHP_VERSION_ID;
45+
4446
class DoctrineMigrationsExtensionTest extends TestCase
4547
{
4648
use ExpectDeprecationTrait;
@@ -287,10 +289,12 @@ public function testCustomConnection(): void
287289

288290
public function testPrefersEntityManagerOverConnection(): void
289291
{
290-
$config = [
292+
$config = [
291293
'migrations_paths' => ['DoctrineMigrationsTest' => 'a'],
292294
];
293-
$ormConfig = trait_exists(LazyGhostTrait::class) ? ['enable_lazy_ghost_objects' => true] : [];
295+
296+
$ormConfig = PHP_VERSION_ID < 80400 && trait_exists(LazyGhostTrait::class) ? ['enable_lazy_ghost_objects' => true] : [];
297+
294298
if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/doctrine-bundle', '^2.7.1 ')) {
295299
$ormConfig['controller_resolver'] = ['auto_mapping' => false];
296300
}
@@ -363,7 +367,12 @@ public function testCustomEntityManager(): void
363367
$ormConfig['controller_resolver'] = ['auto_mapping' => false];
364368
}
365369

366-
if (trait_exists(LazyGhostTrait::class)) {
370+
if (PHP_VERSION_ID >= 80400) {
371+
foreach ($ormConfig['entity_managers'] as $name => $emConfig) {
372+
$ormConfig['entity_managers'][$name]['enable_native_lazy_objects'] = true;
373+
}
374+
} elseif (interface_exists(LazyGhostTrait::class)) {
375+
// For PHP 8.0 and 8.1 we need to check for the interface as the trait is only used when the interface exists
367376
$ormConfig['enable_lazy_ghost_objects'] = true;
368377
}
369378

@@ -506,6 +515,7 @@ private function getContainerBuilder(): ContainerBuilder
506515
'namespace' => $bundle->getNamespace(),
507516
],
508517
],
518+
'kernel.build_dir' => sys_get_temp_dir(),
509519
'kernel.cache_dir' => sys_get_temp_dir(),
510520
'kernel.environment' => 'test',
511521
'kernel.project_dir' => __DIR__ . '/../',

0 commit comments

Comments
 (0)