diff --git a/lib/Doctrine/ODM/MongoDB/Configuration.php b/lib/Doctrine/ODM/MongoDB/Configuration.php index 768d32b9b..07534abcf 100644 --- a/lib/Doctrine/ODM/MongoDB/Configuration.php +++ b/lib/Doctrine/ODM/MongoDB/Configuration.php @@ -631,7 +631,7 @@ public function setUseLazyGhostObject(bool $flag): void trigger_deprecation( 'doctrine/mongodb-odm', - '2.6', + '2.10', 'Using "friendsofphp/proxy-manager-lts" is deprecated. Use "symfony/var-exporter" LazyGhostObjects instead.', ); } diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/LazyGhostProxyFactory.php b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/LazyGhostProxyFactory.php index d22534c60..d66768056 100644 --- a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/LazyGhostProxyFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/LazyGhostProxyFactory.php @@ -267,20 +267,15 @@ private function loadProxyClass(ClassMetadata $class): string $fileName = $this->getProxyFileName($class->getName(), $this->proxyDir); - switch ($this->autoGenerate) { - case Configuration::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED: - if (file_exists($fileName) && filemtime($fileName) >= filemtime($class->getReflectionClass()->getFileName())) { - break; - } - // no break - case Configuration::AUTOGENERATE_FILE_NOT_EXISTS: - if (file_exists($fileName)) { - break; - } - // no break - case Configuration::AUTOGENERATE_ALWAYS: - $this->generateProxyClass($class, $fileName, $proxyClassName); - break; + if ( + match ($this->autoGenerate) { + Configuration::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED => ! file_exists($fileName) || filemtime($fileName) < filemtime($class->getReflectionClass()->getFileName()), + Configuration::AUTOGENERATE_FILE_NOT_EXISTS => ! file_exists($fileName), + Configuration::AUTOGENERATE_ALWAYS => true, + Configuration::AUTOGENERATE_NEVER => false, + } + ) { + $this->generateProxyClass($class, $fileName, $proxyClassName); } require $fileName;