-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generics for cmf #167
Merged
Merged
Generics for cmf #167
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,9 @@ | |
* to a relational database. | ||
* | ||
* This class was abstracted from the ORM ClassMetadataFactory. | ||
* | ||
* @template CMTemplate of ClassMetadata | ||
* @template-implements ClassMetadataFactory<CMTemplate> | ||
*/ | ||
abstract class AbstractClassMetadataFactory implements ClassMetadataFactory | ||
{ | ||
|
@@ -49,7 +52,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory | |
/** @var CacheItemPoolInterface|null */ | ||
private $cache; | ||
|
||
/** @var ClassMetadata[] */ | ||
/** | ||
* @var ClassMetadata[] | ||
* @psalm-var CMTemplate[] | ||
*/ | ||
private $loadedMetadata = []; | ||
|
||
/** @var bool */ | ||
|
@@ -116,17 +122,15 @@ final protected function getCache(): ?CacheItemPoolInterface | |
* Returns an array of all the loaded metadata currently in memory. | ||
* | ||
* @return ClassMetadata[] | ||
* @psalm-return CMTemplate[] | ||
*/ | ||
public function getLoadedMetadata() | ||
{ | ||
return $this->loadedMetadata; | ||
} | ||
|
||
/** | ||
* Forces the factory to load the metadata of all classes known to the underlying | ||
* mapping driver. | ||
* | ||
* @return ClassMetadata[] The ClassMetadata instances of all mapped classes. | ||
* {@inheritDoc} | ||
*/ | ||
public function getAllMetadata() | ||
{ | ||
|
@@ -176,13 +180,17 @@ abstract protected function getDriver(); | |
/** | ||
* Wakes up reflection after ClassMetadata gets unserialized from cache. | ||
* | ||
* @psalm-param CMTemplate $class | ||
* | ||
* @return void | ||
*/ | ||
abstract protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService); | ||
|
||
/** | ||
* Initializes Reflection after ClassMetadata was constructed. | ||
* | ||
* @psalm-param CMTemplate $class | ||
* | ||
* @return void | ||
*/ | ||
abstract protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService); | ||
|
@@ -192,16 +200,14 @@ abstract protected function initializeReflection(ClassMetadata $class, Reflectio | |
* | ||
* This method should return false for mapped superclasses or embedded classes. | ||
* | ||
* @psalm-param CMTemplate $class | ||
* | ||
* @return bool | ||
*/ | ||
abstract protected function isEntity(ClassMetadata $class); | ||
|
||
/** | ||
* Gets the class metadata descriptor for a class. | ||
* | ||
* @param string $className The name of the class. | ||
* | ||
* @return ClassMetadata | ||
* {@inheritDoc} | ||
* | ||
* @throws ReflectionException | ||
* @throws MappingException | ||
|
@@ -232,6 +238,7 @@ public function getMetadataFor($className) | |
if ($this->cache) { | ||
$cached = $this->cache->getItem($this->getCacheKey($realClassName))->get(); | ||
if ($cached instanceof ClassMetadata) { | ||
/** @psalm-var CMTemplate $cached */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like cheating, but without trying to wrap the cache interface, I'm not sure we can do better |
||
$this->loadedMetadata[$realClassName] = $cached; | ||
|
||
$this->wakeupReflection($cached, $this->getReflectionService()); | ||
|
@@ -275,11 +282,7 @@ public function getMetadataFor($className) | |
} | ||
|
||
/** | ||
* Checks whether the factory has the metadata for a class loaded already. | ||
* | ||
* @param string $className | ||
* | ||
* @return bool TRUE if the metadata of the class in question is already loaded, FALSE otherwise. | ||
* {@inheritDoc} | ||
*/ | ||
public function hasMetadataFor($className) | ||
{ | ||
|
@@ -291,8 +294,7 @@ public function hasMetadataFor($className) | |
* | ||
* NOTE: This is only useful in very special cases, like when generating proxy classes. | ||
* | ||
* @param string $className | ||
* @param ClassMetadata $class | ||
* {@inheritDoc} | ||
* | ||
* @return void | ||
*/ | ||
|
@@ -395,6 +397,7 @@ protected function loadMetadata($name) | |
* @param string $className | ||
* | ||
* @return ClassMetadata|null | ||
* @psalm-return CMTemplate|null | ||
*/ | ||
protected function onNotFoundMetadata($className) | ||
{ | ||
|
@@ -409,6 +412,8 @@ protected function onNotFoundMetadata($className) | |
* @param bool $rootEntityFound | ||
* @param string[] $nonSuperclassParents All parent class names | ||
* that are not marked as mapped superclasses. | ||
* @psalm-param CMTemplate $class | ||
* @psalm-param CMTemplate|null $parent | ||
* | ||
* @return void | ||
*/ | ||
|
@@ -420,6 +425,7 @@ abstract protected function doLoadMetadata($class, $parent, $rootEntityFound, ar | |
* @param string $className | ||
* | ||
* @return ClassMetadata | ||
* @psalm-return CMTemplate | ||
*/ | ||
abstract protected function newClassMetadataInstance($className); | ||
|
||
|
@@ -473,9 +479,11 @@ protected function getCacheKey(string $realClassName): string | |
/** | ||
* Gets the real class name of a class name that could be a proxy. | ||
* | ||
* @template T of object | ||
* @psalm-param class-string<Proxy<T>>|class-string<T> $class | ||
* | ||
* @psalm-return class-string<T> | ||
* | ||
* @template T of object | ||
*/ | ||
private function getRealClass(string $class): string | ||
{ | ||
|
@@ -490,9 +498,11 @@ private function createDefaultProxyClassNameResolver(): void | |
{ | ||
$this->proxyClassNameResolver = new class implements ProxyClassNameResolver { | ||
/** | ||
* @template T of object | ||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className | ||
* | ||
* @psalm-return class-string<T> | ||
* | ||
* @template T of object | ||
*/ | ||
public function resolveClassName(string $className): string | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd advise pinning the version of static tools, especially now that we started deploying baseline. It will make sure the version used to generate the baseline is the same for everyone, and make sure not to break builds the day before the release :)