Skip to content
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

Fix some static analysis issues #8699

Merged
merged 2 commits into from
May 20, 2021
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"doctrine/inflector": "^1.4|^2.0",
"doctrine/instantiator": "^1.3",
"doctrine/lexer": "^1.0",
"doctrine/persistence": "^2.0",
"doctrine/persistence": "^2.2",
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/EntityCacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ class EntityCacheEntry implements CacheEntry
* READ-ONLY: Public only for performance reasons, it should be considered immutable.
*
* @var string The entity class name
* @psalm-var class-string
*/
public $class;

/**
* @param string $class The entity class.
* @param array<string,mixed> $data The entity data.
* @psalm-param class-string $class
*/
public function __construct($class, array $data)
{
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ public function rollback()
*
* Internal note: Performance-sensitive method.
*
* @param string $className
*
* @return ClassMetadata
* {@inheritDoc}
*/
public function getClassMetadata($className)
{
Expand Down
13 changes: 12 additions & 1 deletion lib/Doctrine/ORM/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* EntityManager interface
*
* @method Mapping\ClassMetadata getClassMetadata($className)
* @method Mapping\ClassMetadataFactory getMetadataFactory()
*/
interface EntityManagerInterface extends ObjectManager
Expand Down Expand Up @@ -306,4 +305,16 @@ public function isFiltersStateClean();
* @return bool True, if the EM has a filter collection.
*/
public function hasFilters();

/**
* {@inheritDoc}
*
* @psalm-param string|class-string<T> $className
*
* @return Mapping\ClassMetadata
* @psalm-return Mapping\ClassMetadata<T>
*
* @template T of object
*/
public function getClassMetadata($className);
}
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* {@inheritDoc}
*
* @todo remove or rename ClassMetadataInfo to ClassMetadata
* @template T of object
* @template-extends ClassMetadataInfo<T>
*/
class ClassMetadata extends ClassMetadataInfo
{
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ protected function initializeReflection(ClassMetadataInterface $class, Reflectio
*/
protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
{
/** @psalm-var class-string */
return $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
* 2) To drastically reduce the size of a serialized instance (private/protected members
* get the whole class name, namespace inclusive, prepended to every property in
* the serialized representation).
*
* @template T of object
* @template-implements ClassMetadata<T>
*/
class ClassMetadataInfo implements ClassMetadata
{
Expand Down Expand Up @@ -235,6 +238,7 @@ class ClassMetadataInfo implements ClassMetadata
* READ-ONLY: The name of the entity class.
*
* @var string
* @psalm-var class-string<T>
*/
public $name;

Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,19 @@ protected function loadMappingFile($file)

if (isset($xmlElement->entity)) {
foreach ($xmlElement->entity as $entityElement) {
/** @psalm-var class-string */
$entityName = (string) $entityElement['name'];
$result[$entityName] = $entityElement;
}
} elseif (isset($xmlElement->{'mapped-superclass'})) {
foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) {
/** @psalm-var class-string */
$className = (string) $mappedSuperClass['name'];
$result[$className] = $mappedSuperClass;
}
} elseif (isset($xmlElement->embeddable)) {
foreach ($xmlElement->embeddable as $embeddableElement) {
/** @psalm-var class-string */
$embeddableName = (string) $embeddableElement['name'];
$result[$embeddableName] = $embeddableElement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function getProperties($className)

/**
* @param string $className
* @psalm-param class-string $className
*
* @return ReflectionClass[]
* @psalm-return list<ReflectionClass>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private function displayEntity($entityName, EntityManagerInterface $entityManage
* Return all mapped entity class names
*
* @return string[]
* @psalm-return class-string[]
*/
private function getMappedEntities(EntityManagerInterface $entityManager): array
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class UnitOfWork implements PropertyChangedListener
/**
* Map of Entity Class-Names and corresponding IDs that should eager loaded when requested.
*
* @psalm-var array<string, array<string, mixed>>
* @psalm-var array<class-string, array<string, mixed>>
*/
private $eagerLoadingEntities = [];

Expand Down Expand Up @@ -2630,6 +2630,7 @@ private function newInstance($class)
*
* @param string $className The name of the entity class.
* @param mixed[] $data The data for the entity.
* @psalm-param class-string $className
* @psalm-param array<string, mixed> $hints Any hints to account for during reconstitution/lookup of the entity.
*
* @return object The managed entity instance.
Expand Down
Loading