Skip to content

Commit

Permalink
Fix deprecation version and refactor autoregenerate condition
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Dec 31, 2024
1 parent 53ee9f4 commit dbd1f1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
}
Expand Down
23 changes: 9 additions & 14 deletions lib/Doctrine/ODM/MongoDB/Proxy/Factory/LazyGhostProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dbd1f1b

Please sign in to comment.