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
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@

if ($refreshedUser instanceof Proxy && !$refreshedUser->__isInitialized()) {
$refreshedUser->__load();
} elseif (\PHP_VERSION_ID >= 80400 && ($r = new \ReflectionClass($refreshedUser))->isUninitializedLazyObject($refreshedUser)) {

Check failure on line 103 in src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php:103:92: UndefinedMethod: Method ReflectionClass::isUninitializedLazyObject does not exist (see https://psalm.dev/022)

Check failure on line 103 in src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php:103:92: UndefinedMethod: Method ReflectionClass::isUninitializedLazyObject does not exist (see https://psalm.dev/022)
$r->initializeLazyObject($refreshedUser);

Check failure on line 104 in src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php:104:17: UndefinedMethod: Method ReflectionClass::initializeLazyObject does not exist (see https://psalm.dev/022)

Check failure on line 104 in src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php:104:17: UndefinedMethod: Method ReflectionClass::initializeLazyObject does not exist (see https://psalm.dev/022)
}

return $refreshedUser;
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public static function createTestEntityManager(?Configuration $config = null): E
$config ??= self::createTestConfiguration();
$eventManager = new EventManager();

if (\PHP_VERSION_ID >= 80400 && method_exists($config, 'enableNativeLazyObjects')) {
$config->enableNativeLazyObjects(true);
}

return new EntityManager(DriverManager::getConnection($params, $config, $eventManager), $config, $eventManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Doctrine\Tests\Security\User;

use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Tools\SchemaTool;
Expand Down Expand Up @@ -219,8 +220,13 @@ public function testRefreshedUserProxyIsLoaded()
$provider = new EntityUserProvider($this->getManager($em), User::class);
$refreshedUser = $provider->refreshUser($user);

$this->assertInstanceOf(Proxy::class, $refreshedUser);
$this->assertTrue($refreshedUser->__isInitialized());
if (\PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects')) {
$this->assertFalse((new \ReflectionClass(User::class))->isUninitializedLazyObject($refreshedUser));
$this->assertSame('user1', $refreshedUser->name);
} else {
$this->assertInstanceOf(Proxy::class, $refreshedUser);
$this->assertTrue($refreshedUser->__isInitialized());
}
}

private function getManager($em, $name = null)
Expand Down
Loading