mirror of
https://github.com/doctrine/persistence.git
synced 2026-03-23 22:42:11 +01:00
Drop Psalm
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -12,7 +12,4 @@
|
||||
/phpcs.xml.dist export-ignore
|
||||
/phpstan.neon export-ignore
|
||||
/phpstan-baseline.neon export-ignore
|
||||
/psalm.xml export-ignore
|
||||
/psalm-baseline.xml export-ignore
|
||||
/psalm.phpstub export-ignore
|
||||
/composer.lock export-ignore
|
||||
|
||||
2
.github/workflows/static-analysis.yml
vendored
2
.github/workflows/static-analysis.yml
vendored
@@ -12,6 +12,6 @@ on:
|
||||
jobs:
|
||||
static-analysis:
|
||||
name: "Static Analysis"
|
||||
uses: "doctrine/.github/.github/workflows/static-analysis.yml@5.2.0"
|
||||
uses: "doctrine/.github/.github/workflows/phpstan.yml@5.2.0"
|
||||
with:
|
||||
composer-root-version: "3.0"
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
"doctrine/coding-standard": "^12",
|
||||
"doctrine/common": "^3.0",
|
||||
"phpunit/phpunit": "^8.5 || ^9.5",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6.0 || ^7.0",
|
||||
"vimeo/psalm": "4.30.0 || 5.26.1"
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6.0 || ^7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": "<2.10"
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e">
|
||||
<file src="src/Persistence/Mapping/AbstractClassMetadataFactory.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$class]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
</file>
|
||||
<file src="src/Persistence/Mapping/Driver/SymfonyFileLocator.php">
|
||||
<PossiblyInvalidOperand>
|
||||
<code><![CDATA[str_replace($this->nsSeparator, '\\', $fileName)]]></code>
|
||||
</PossiblyInvalidOperand>
|
||||
</file>
|
||||
<file src="src/Persistence/Reflection/EnumReflectionProperty.php">
|
||||
<InvalidArgument>
|
||||
<code><![CDATA[$name]]></code>
|
||||
</InvalidArgument>
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</InvalidReturnStatement>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
</file>
|
||||
</files>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Workaround for psalm to return a class-string when used with a class string
|
||||
* Can be removed when https://github.com/vimeo/psalm/pull/8219 is released
|
||||
*
|
||||
* @psalm-pure
|
||||
*
|
||||
* @return ($string is class-string ? ($characters is '\\' ? class-string : string) : string)
|
||||
*
|
||||
* @psalm-flow ($string) -> return
|
||||
*/
|
||||
function ltrim(string $string, string $characters = " \t\n\r\0\x0B") : string {}
|
||||
72
psalm.xml
72
psalm.xml
@@ -1,72 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="3"
|
||||
phpVersion="8.1"
|
||||
findUnusedBaselineEntry="true"
|
||||
findUnusedCode="false"
|
||||
findUnusedPsalmSuppress="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
errorBaseline="psalm-baseline.xml"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src/Persistence" />
|
||||
<directory name="tests" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
<!-- this one is a mapping file in written in PHP -->
|
||||
<file name="tests/Persistence/Mapping/_files/Doctrine.Tests.Persistence.Mapping.PHPTestEntity.php" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
<issueHandlers>
|
||||
<TypeDoesNotContainType>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Expected class list that is not a list<class-string> -->
|
||||
<file name="tests/Persistence/Mapping/DefaultFileLocatorTest.php"/>
|
||||
<file name="tests/Persistence/Mapping/SymfonyFileLocatorTest.php"/>
|
||||
</errorLevel>
|
||||
</TypeDoesNotContainType>
|
||||
<NullArgument>
|
||||
<errorLevel type="suppress">
|
||||
<file name="src/Persistence/Reflection/RuntimeReflectionProperty.php"/>
|
||||
<file name="tests/Persistence/Mapping/SymfonyFileLocatorTest.php"/>
|
||||
</errorLevel>
|
||||
</NullArgument>
|
||||
<ArgumentTypeCoercion>
|
||||
<errorLevel type="suppress">
|
||||
<!-- On purpose to use a non existing class for tests -->
|
||||
<file name="tests/Persistence/Mapping/RuntimeReflectionServiceTest.php"/>
|
||||
</errorLevel>
|
||||
</ArgumentTypeCoercion>
|
||||
<MoreSpecificReturnType>
|
||||
<errorLevel type="suppress">
|
||||
<!-- FileDriver::loadMappingFile() in tests could have a more specific return, but is not needed -->
|
||||
<file name="tests/Persistence/Mapping/FileDriverTest.php"/>
|
||||
</errorLevel>
|
||||
</MoreSpecificReturnType>
|
||||
<RedundantCast>
|
||||
<errorLevel type="suppress">
|
||||
<!-- We're filtering invalid input- -->
|
||||
<file name="src/Persistence/Mapping/Driver/SymfonyFileLocator.php"/>
|
||||
</errorLevel>
|
||||
</RedundantCast>
|
||||
<UndefinedClass>
|
||||
<errorLevel type="suppress">
|
||||
<!-- We are testing what happens when calling the API with a non existent class -->
|
||||
<file name="tests/Persistence/Mapping/ClassMetadataFactoryTest.php"/>
|
||||
<file name="tests/Persistence/Mapping/RuntimeReflectionServiceTest.php"/>
|
||||
</errorLevel>
|
||||
</UndefinedClass>
|
||||
<ArgumentTypeCoercion>
|
||||
<errorLevel type="suppress">
|
||||
<!-- Related to the above, since we are coercing a string to class-string -->
|
||||
<file name="tests/Persistence/Mapping/ClassMetadataFactoryTest.php"/>
|
||||
<file name="tests/Persistence/Mapping/RuntimeReflectionServiceTest.php"/>
|
||||
</errorLevel>
|
||||
</ArgumentTypeCoercion>
|
||||
</issueHandlers>
|
||||
<stubs>
|
||||
<file name="psalm.phpstub" />
|
||||
</stubs>
|
||||
</psalm>
|
||||
@@ -32,14 +32,14 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var class-string
|
||||
* @phpstan-var class-string
|
||||
*/
|
||||
private $proxyInterfaceName;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $connections
|
||||
* @param array<string, string> $managers
|
||||
* @psalm-param class-string $proxyInterfaceName
|
||||
* @phpstan-param class-string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
@@ -255,7 +255,7 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
||||
return $this->getManager($name);
|
||||
}
|
||||
|
||||
/** @psalm-param class-string $persistentObject */
|
||||
/** @phpstan-param class-string $persistentObject */
|
||||
private function selectManager(
|
||||
string $persistentObject,
|
||||
?string $persistentManagerName = null
|
||||
|
||||
@@ -17,14 +17,14 @@ class LifecycleEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
* @phpstan-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/** @var object */
|
||||
private $object;
|
||||
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
/** @phpstan-param TObjectManager $objectManager */
|
||||
public function __construct(object $object, ObjectManager $objectManager)
|
||||
{
|
||||
$this->object = $object;
|
||||
@@ -45,7 +45,7 @@ class LifecycleEventArgs extends EventArgs
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
|
||||
@@ -18,19 +18,19 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
* @psalm-var TClassMetadata
|
||||
* @phpstan-var TClassMetadata
|
||||
*/
|
||||
private $classMetadata;
|
||||
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
* @phpstan-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @psalm-param TClassMetadata $classMetadata
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
* @phpstan-param TClassMetadata $classMetadata
|
||||
* @phpstan-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
* Retrieves the associated ClassMetadata.
|
||||
*
|
||||
* @return ClassMetadata
|
||||
* @psalm-return TClassMetadata
|
||||
* @phpstan-return TClassMetadata
|
||||
*/
|
||||
public function getClassMetadata()
|
||||
{
|
||||
|
||||
@@ -16,11 +16,11 @@ class ManagerEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
* @phpstan-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
/** @phpstan-param TObjectManager $objectManager */
|
||||
public function __construct(ObjectManager $objectManager)
|
||||
{
|
||||
$this->objectManager = $objectManager;
|
||||
@@ -30,7 +30,7 @@ class ManagerEventArgs extends EventArgs
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
|
||||
@@ -16,13 +16,13 @@ class OnClearEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
* @psalm-var TObjectManager
|
||||
* @phpstan-var TObjectManager
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $objectManager The object manager.
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
* @phpstan-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(ObjectManager $objectManager)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ class OnClearEventArgs extends EventArgs
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @return ObjectManager
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager()
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
|
||||
/**
|
||||
* @param array<string, array<int, mixed>> $changeSet
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
* @phpstan-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(object $entity, ObjectManager $objectManager, array &$changeSet)
|
||||
{
|
||||
|
||||
@@ -66,10 +66,10 @@ interface ManagerRegistry extends ConnectionRegistry
|
||||
*
|
||||
* @param string $persistentObject The name of the persistent object.
|
||||
* @param string|null $persistentManagerName The object manager name (null for the default one).
|
||||
* @psalm-param class-string<T> $persistentObject
|
||||
* @phpstan-param class-string<T> $persistentObject
|
||||
*
|
||||
* @return ObjectRepository
|
||||
* @psalm-return ObjectRepository<T>
|
||||
* @phpstan-return ObjectRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
|
||||
/**
|
||||
* @var array<string, ClassMetadata>
|
||||
* @psalm-var CMTemplate[]
|
||||
* @phpstan-var CMTemplate[]
|
||||
*/
|
||||
private $loadedMetadata = [];
|
||||
|
||||
@@ -74,7 +74,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
* Returns an array of all the loaded metadata currently in memory.
|
||||
*
|
||||
* @return ClassMetadata[]
|
||||
* @psalm-return CMTemplate[]
|
||||
* @phpstan-return CMTemplate[]
|
||||
*/
|
||||
public function getLoadedMetadata()
|
||||
{
|
||||
@@ -122,7 +122,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Wakes up reflection after ClassMetadata gets unserialized from cache.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -134,7 +134,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Initializes Reflection after ClassMetadata was constructed.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -148,7 +148,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
*
|
||||
* This method should return false for mapped superclasses or embedded classes.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -157,9 +157,9 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Removes the prepended backslash of a class string to conform with how php outputs class names
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @phpstan-param class-string $className
|
||||
*
|
||||
* @psalm-return class-string
|
||||
* @phpstan-return class-string
|
||||
*/
|
||||
private function normalizeClassName(string $className): string
|
||||
{
|
||||
@@ -199,7 +199,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
if ($this->cache !== null) {
|
||||
$cached = $this->cache->getItem($this->getCacheKey($realClassName))->get();
|
||||
if ($cached instanceof ClassMetadata) {
|
||||
/** @psalm-var CMTemplate $cached */
|
||||
/** @phpstan-var CMTemplate $cached */
|
||||
$this->loadedMetadata[$realClassName] = $cached;
|
||||
|
||||
$this->wakeupReflection($cached, $this->getReflectionService());
|
||||
@@ -257,8 +257,8 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
*
|
||||
* NOTE: This is only useful in very special cases, like when generating proxy classes.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param class-string $className
|
||||
* @phpstan-param CMTemplate $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -270,10 +270,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Gets an array of parent classes for the given entity class.
|
||||
*
|
||||
* @psalm-param class-string $name
|
||||
* @phpstan-param class-string $name
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<class-string>
|
||||
* @phpstan-return list<class-string>
|
||||
*/
|
||||
protected function getParentClasses(string $name)
|
||||
{
|
||||
@@ -302,10 +302,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
* should be used for reflection.
|
||||
*
|
||||
* @param string $name The name of the class for which the metadata should get loaded.
|
||||
* @psalm-param class-string $name
|
||||
* @phpstan-param class-string $name
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
protected function loadMetadata(string $name)
|
||||
{
|
||||
@@ -366,7 +366,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
* Override this method to implement a fallback strategy for failed metadata loading
|
||||
*
|
||||
* @return ClassMetadata|null
|
||||
* @psalm-return CMTemplate|null
|
||||
* @phpstan-return CMTemplate|null
|
||||
*/
|
||||
protected function onNotFoundMetadata(string $className)
|
||||
{
|
||||
@@ -378,8 +378,8 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
*
|
||||
* @param bool $rootEntityFound True when there is another entity (non-mapped superclass) class above the current class in the PHP class hierarchy.
|
||||
* @param list<class-string> $nonSuperclassParents All parent class names that are not marked as mapped superclasses, with the direct parent class being the first and the root entity class the last element.
|
||||
* @psalm-param CMTemplate $class
|
||||
* @psalm-param CMTemplate|null $parent
|
||||
* @phpstan-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate|null $parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -393,10 +393,10 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Creates a new ClassMetadata instance for the given class name.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @phpstan-param class-string<T> $className
|
||||
*
|
||||
* @return ClassMetadata<T>
|
||||
* @psalm-return CMTemplate
|
||||
* @phpstan-return CMTemplate
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -419,7 +419,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
throw MappingException::nonExistingClass($className);
|
||||
}
|
||||
|
||||
/** @psalm-var class-string $className */
|
||||
/** @phpstan-var class-string $className */
|
||||
return $this->getDriver()->isTransient($className);
|
||||
}
|
||||
|
||||
@@ -455,9 +455,9 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Gets the real class name of a class name that could be a proxy.
|
||||
*
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $class
|
||||
* @phpstan-param class-string<Proxy<T>>|class-string<T> $class
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -476,9 +476,9 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
{
|
||||
$this->proxyClassNameResolver = new class implements ProxyClassNameResolver {
|
||||
/**
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
|
||||
* @phpstan-param class-string<Proxy<T>>|class-string<T> $className
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -487,11 +487,11 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
$pos = strrpos($className, '\\' . Proxy::MARKER . '\\');
|
||||
|
||||
if ($pos === false) {
|
||||
/** @psalm-var class-string<T> */
|
||||
/** @phpstan-var class-string<T> */
|
||||
return $className;
|
||||
}
|
||||
|
||||
/** @psalm-var class-string<T> */
|
||||
/** @phpstan-var class-string<T> */
|
||||
return substr($className, $pos + Proxy::MARKER_LENGTH + 2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ interface ClassMetadata
|
||||
* Gets the fully-qualified class name of this persistent class.
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ClassMetadata
|
||||
* The returned structure is an array of the identifier field names.
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<string>
|
||||
* @phpstan-return list<string>
|
||||
*/
|
||||
public function getIdentifier();
|
||||
|
||||
@@ -112,7 +112,7 @@ interface ClassMetadata
|
||||
* Returns the target class name of the given association.
|
||||
*
|
||||
* @return string|null
|
||||
* @psalm-return class-string|null
|
||||
* @phpstan-return class-string|null
|
||||
*/
|
||||
public function getAssociationTargetClass(string $assocName);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ interface ClassMetadataFactory
|
||||
* mapping driver.
|
||||
*
|
||||
* @return ClassMetadata[] The ClassMetadata instances of all mapped classes.
|
||||
* @psalm-return list<T>
|
||||
* @phpstan-return list<T>
|
||||
*/
|
||||
public function getAllMetadata();
|
||||
|
||||
@@ -26,7 +26,7 @@ interface ClassMetadataFactory
|
||||
* @param class-string $className The name of the class.
|
||||
*
|
||||
* @return ClassMetadata
|
||||
* @psalm-return T
|
||||
* @phpstan-return T
|
||||
*/
|
||||
public function getMetadataFor(string $className);
|
||||
|
||||
@@ -43,7 +43,7 @@ interface ClassMetadataFactory
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
* @param class-string $className
|
||||
* @psalm-param T $class
|
||||
* @phpstan-param T $class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ interface ClassMetadataFactory
|
||||
* Returns whether the class with the specified name should have its metadata loaded.
|
||||
* This is only the case if it is either mapped directly or as a MappedSuperclass.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @phpstan-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -54,7 +54,7 @@ trait ColocatedMappingDriver
|
||||
* Cache for getAllClassNames().
|
||||
*
|
||||
* @var array<int, string>|null
|
||||
* @psalm-var list<class-string>|null
|
||||
* @phpstan-var list<class-string>|null
|
||||
*/
|
||||
protected $classNames;
|
||||
|
||||
@@ -128,7 +128,7 @@ trait ColocatedMappingDriver
|
||||
* Returns whether the class with the specified name is transient. Only non-transient
|
||||
* classes, that is entities and mapped superclasses, should have their metadata loaded.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @phpstan-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -138,7 +138,7 @@ trait ColocatedMappingDriver
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return string[] The names of all mapped classes known to this driver.
|
||||
* @psalm-return list<class-string>
|
||||
* @phpstan-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames()
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ class DefaultFileLocator implements FileLocator
|
||||
// NOTE: All files found here means classes are not transient!
|
||||
|
||||
assert(is_string($fileName));
|
||||
/** @psalm-var class-string */
|
||||
/** @phpstan-var class-string */
|
||||
$class = str_replace('.', '\\', $fileName);
|
||||
$classes[] = $class;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class FileDriver implements MappingDriver
|
||||
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array<class-string, T>|null
|
||||
* @phpstan-var array<class-string, T>|null
|
||||
*/
|
||||
protected $classCache;
|
||||
|
||||
@@ -78,7 +78,7 @@ abstract class FileDriver implements MappingDriver
|
||||
* Gets the element of schema meta data for the class from the mapping file.
|
||||
* This will lazily load the mapping file if it is not loaded yet.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @phpstan-param class-string $className
|
||||
*
|
||||
* @return T The element of schema meta data.
|
||||
*
|
||||
@@ -137,7 +137,7 @@ abstract class FileDriver implements MappingDriver
|
||||
return $this->locator->getAllClassNames($this->globalBasename);
|
||||
}
|
||||
|
||||
/** @psalm-var array<class-string, ClassMetadata<object>> $classCache */
|
||||
/** @phpstan-var array<class-string, ClassMetadata<object>> $classCache */
|
||||
$classCache = $this->classCache;
|
||||
|
||||
/** @var list<class-string> $keys */
|
||||
@@ -156,7 +156,7 @@ abstract class FileDriver implements MappingDriver
|
||||
* @param string $file The mapping file to load.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @psalm-return array<class-string, T>
|
||||
* @phpstan-return array<class-string, T>
|
||||
*/
|
||||
abstract protected function loadMappingFile(string $file);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ interface FileLocator
|
||||
* @param string $globalBasename Passed to allow excluding the basename.
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @psalm-return list<class-string>
|
||||
* @phpstan-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames(string $globalBasename);
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ interface MappingDriver
|
||||
/**
|
||||
* Loads the metadata for the specified class into the provided container.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @psalm-param ClassMetadata<T> $metadata
|
||||
* @phpstan-param class-string<T> $className
|
||||
* @phpstan-param ClassMetadata<T> $metadata
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -27,7 +27,7 @@ interface MappingDriver
|
||||
* Gets the names of all mapped classes known to this driver.
|
||||
*
|
||||
* @return array<int, string> The names of all mapped classes known to this driver.
|
||||
* @psalm-return list<class-string>
|
||||
* @phpstan-return list<class-string>
|
||||
*/
|
||||
public function getAllClassNames();
|
||||
|
||||
@@ -35,7 +35,7 @@ interface MappingDriver
|
||||
* Returns whether the class with the specified name should have its metadata loaded.
|
||||
* This is only the case if it is either mapped as an Entity or a MappedSuperclass.
|
||||
*
|
||||
* @psalm-param class-string $className
|
||||
* @phpstan-param class-string $className
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ class PHPDriver extends FileDriver
|
||||
{
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
* @psalm-var ClassMetadata<object>
|
||||
* @phpstan-var ClassMetadata<object>
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class StaticPHPDriver implements MappingDriver
|
||||
* Map of all class names.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @psalm-var list<class-string>
|
||||
* @phpstan-var list<class-string>
|
||||
*/
|
||||
private $classNames;
|
||||
|
||||
|
||||
@@ -202,10 +202,10 @@ class SymfonyFileLocator implements FileLocator
|
||||
'\\'
|
||||
);
|
||||
|
||||
/** @psalm-var class-string */
|
||||
/** @phpstan-var class-string */
|
||||
$class = $this->prefixes[$path] . str_replace(DIRECTORY_SEPARATOR, '\\', $nsSuffix) . '\\' . str_replace($this->nsSeparator, '\\', $fileName);
|
||||
} else {
|
||||
/** @psalm-var class-string */
|
||||
/** @phpstan-var class-string */
|
||||
$class = str_replace($this->nsSeparator, '\\', $fileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ use Doctrine\Persistence\Proxy;
|
||||
interface ProxyClassNameResolver
|
||||
{
|
||||
/**
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
|
||||
* @phpstan-param class-string<Proxy<T>>|class-string<T> $className
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
|
||||
@@ -18,10 +18,10 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns an array of the parent classes (not interfaces) for the given class.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return class-string[]
|
||||
* @phpstan-return class-string[]
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
@@ -30,14 +30,14 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns the shortname of a class.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassShortName(string $class);
|
||||
|
||||
/**
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -46,10 +46,10 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns a reflection class instance or null.
|
||||
*
|
||||
* @psalm-param class-string<T> $class
|
||||
* @phpstan-param class-string<T> $class
|
||||
*
|
||||
* @return ReflectionClass|null
|
||||
* @psalm-return ReflectionClass<T>|null
|
||||
* @phpstan-return ReflectionClass<T>|null
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*
|
||||
* @return ReflectionProperty|null
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ interface ReflectionService
|
||||
/**
|
||||
* Checks if the class have a public method with the given name.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -67,10 +67,10 @@ class RuntimeReflectionService implements ReflectionService
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<T> $class
|
||||
* @phpstan-param class-string<T> $class
|
||||
*
|
||||
* @return ReflectionClass
|
||||
* @psalm-return ReflectionClass<T>
|
||||
* @phpstan-return ReflectionClass<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
|
||||
@@ -21,10 +21,10 @@ interface ObjectManager
|
||||
*
|
||||
* @param string $className The class name of the object to find.
|
||||
* @param mixed $id The identity of the object to find.
|
||||
* @psalm-param class-string<T> $className
|
||||
* @phpstan-param class-string<T> $className
|
||||
*
|
||||
* @return object|null The found object.
|
||||
* @psalm-return T|null
|
||||
* @phpstan-return T|null
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -98,9 +98,9 @@ interface ObjectManager
|
||||
/**
|
||||
* Gets the repository for a class.
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @phpstan-param class-string<T> $className
|
||||
*
|
||||
* @psalm-return ObjectRepository<T>
|
||||
* @phpstan-return ObjectRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -112,9 +112,9 @@ interface ObjectManager
|
||||
* The class name must be the fully-qualified class name without a leading backslash
|
||||
* (as it is returned by get_class($obj)).
|
||||
*
|
||||
* @psalm-param class-string<T> $className
|
||||
* @phpstan-param class-string<T> $className
|
||||
*
|
||||
* @psalm-return ClassMetadata<T>
|
||||
* @phpstan-return ClassMetadata<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ interface ObjectManager
|
||||
/**
|
||||
* Gets the metadata factory used to gather the metadata of classes.
|
||||
*
|
||||
* @psalm-return ClassMetadataFactory<ClassMetadata<object>>
|
||||
* @phpstan-return ClassMetadataFactory<ClassMetadata<object>>
|
||||
*/
|
||||
public function getMetadataFactory();
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ abstract class ObjectManagerDecorator implements ObjectManager
|
||||
return $this->wrapped->getClassMetadata($className);
|
||||
}
|
||||
|
||||
/** @psalm-return ClassMetadataFactory<ClassMetadata<object>> */
|
||||
/** @phpstan-return ClassMetadataFactory<ClassMetadata<object>> */
|
||||
public function getMetadataFactory()
|
||||
{
|
||||
return $this->wrapped->getMetadataFactory();
|
||||
|
||||
@@ -19,7 +19,7 @@ interface ObjectRepository
|
||||
* @param mixed $id The identifier.
|
||||
*
|
||||
* @return object|null The object.
|
||||
* @psalm-return T|null
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function find($id);
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ObjectRepository
|
||||
* Finds all objects in the repository.
|
||||
*
|
||||
* @return array<int, object> The objects.
|
||||
* @psalm-return T[]
|
||||
* @phpstan-return T[]
|
||||
*/
|
||||
public function findAll();
|
||||
|
||||
@@ -40,10 +40,10 @@ interface ObjectRepository
|
||||
*
|
||||
* @param array<string, mixed> $criteria
|
||||
* @param array<string, string>|null $orderBy
|
||||
* @psalm-param array<string, 'asc'|'desc'|'ASC'|'DESC'>|null $orderBy
|
||||
* @phpstan-param array<string, 'asc'|'desc'|'ASC'|'DESC'>|null $orderBy
|
||||
*
|
||||
* @return array<int, object> The objects.
|
||||
* @psalm-return T[]
|
||||
* @phpstan-return T[]
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
@@ -60,14 +60,14 @@ interface ObjectRepository
|
||||
* @param array<string, mixed> $criteria The criteria.
|
||||
*
|
||||
* @return object|null The object.
|
||||
* @psalm-return T|null
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function findOneBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Returns the class name of the object managed by the repository.
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*/
|
||||
public function getClassName();
|
||||
}
|
||||
|
||||
@@ -32,31 +32,16 @@ class EnumReflectionProperty extends ReflectionProperty
|
||||
$this->enumType = $enumType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function getDeclaringClass(): ReflectionClass
|
||||
{
|
||||
return $this->originalReflectionProperty->getDeclaringClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->originalReflectionProperty->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function getType(): ?ReflectionType
|
||||
{
|
||||
return $this->originalReflectionProperty->getType();
|
||||
@@ -149,31 +134,16 @@ class EnumReflectionProperty extends ReflectionProperty
|
||||
return $this->enumType::from($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function getModifiers(): int
|
||||
{
|
||||
return $this->originalReflectionProperty->getModifiers();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function getDocComment(): string|false
|
||||
{
|
||||
return $this->originalReflectionProperty->getDocComment();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-external-mutation-free
|
||||
*/
|
||||
public function isPrivate(): bool
|
||||
{
|
||||
return $this->originalReflectionProperty->isPrivate();
|
||||
|
||||
@@ -65,7 +65,7 @@ class PreUpdateEventArgsTest extends DoctrineTestCase
|
||||
$event->setNewValue('does_not_exist', 'new value');
|
||||
}
|
||||
|
||||
/** @psalm-return PreUpdateEventArgs<ObjectManager> */
|
||||
/** @phpstan-return PreUpdateEventArgs<ObjectManager> */
|
||||
private function createTestPreUpdateEventArgs(): PreUpdateEventArgs
|
||||
{
|
||||
$entity = new TestObject();
|
||||
|
||||
@@ -185,7 +185,7 @@ class TestManagerRegistry extends AbstractManagerRegistry
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-param class-string $proxyInterfaceName
|
||||
* @phpstan-param class-string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
|
||||
@@ -60,8 +60,8 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
$cmf = $this->getMockForAbstractClass(AbstractClassMetadataFactory::class);
|
||||
$this->expectException(MappingException::class);
|
||||
/**
|
||||
* @psalm-suppress ArgumentTypeCoercion
|
||||
* @psalm-suppress UndefinedClass
|
||||
* @phpstan-suppress ArgumentTypeCoercion
|
||||
* @phpstan-suppress UndefinedClass
|
||||
*/
|
||||
// @phpstan-ignore-next-line
|
||||
$cmf->getMetadataFor('App:Test');
|
||||
@@ -72,8 +72,8 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
$cmf = $this->getMockForAbstractClass(AbstractClassMetadataFactory::class);
|
||||
$this->expectException(MappingException::class);
|
||||
/**
|
||||
* @psalm-suppress ArgumentTypeCoercion
|
||||
* @psalm-suppress UndefinedClass
|
||||
* @phpstan-suppress ArgumentTypeCoercion
|
||||
* @phpstan-suppress UndefinedClass
|
||||
*/
|
||||
// @phpstan-ignore-next-line
|
||||
$cmf->isTransient('App:Test');
|
||||
@@ -89,7 +89,7 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
self::createStub(ClassMetadata::class)
|
||||
);
|
||||
|
||||
/** @psalm-suppress ArgumentTypeCoercion */
|
||||
/** @phpstan-suppress ArgumentTypeCoercion */
|
||||
self::assertSame($cmf->getMetadataFor(SomeOtherEntity::class), $cmf->getMetadataFor('\\' . SomeOtherEntity::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class ClassMetadataFactoryTest extends DoctrineTestCase
|
||||
{
|
||||
/**
|
||||
* @var TestClassMetadataFactory
|
||||
* @psalm-var TestClassMetadataFactory<ClassMetadata<object>>
|
||||
* @phpstan-var TestClassMetadataFactory<ClassMetadata<object>>
|
||||
*/
|
||||
private $cmf;
|
||||
|
||||
@@ -29,7 +29,7 @@ class ClassMetadataFactoryTest extends DoctrineTestCase
|
||||
{
|
||||
$driver = $this->createMock(MappingDriver::class);
|
||||
|
||||
/** @psalm-var ClassMetadata<object> */
|
||||
/** @phpstan-var ClassMetadata<object> */
|
||||
$metadata = $this->createMock(ClassMetadata::class);
|
||||
$this->cmf = new TestClassMetadataFactory($driver, $metadata);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ class ClassMetadataFactoryTest extends DoctrineTestCase
|
||||
self::assertSame($metadata, $this->cmf->getMetadataFor(Foo::class));
|
||||
}
|
||||
|
||||
/** @psalm-param AbstractClassMetadataFactory<ClassMetadata<object>> $classMetadataFactory */
|
||||
/** @phpstan-param AbstractClassMetadataFactory<ClassMetadata<object>> $classMetadataFactory */
|
||||
private static function getCache(AbstractClassMetadataFactory $classMetadataFactory): ?CacheItemPoolInterface
|
||||
{
|
||||
$method = new ReflectionMethod($classMetadataFactory, 'getCache');
|
||||
|
||||
@@ -16,11 +16,11 @@ final class TestClassMetadata implements ClassMetadata
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var class-string<T>
|
||||
* @phpstan-var class-string<T>
|
||||
*/
|
||||
private $className;
|
||||
|
||||
/** @psalm-param class-string<T> $className */
|
||||
/** @phpstan-param class-string<T> $className */
|
||||
public function __construct(string $className)
|
||||
{
|
||||
$this->className = $className;
|
||||
|
||||
@@ -30,7 +30,7 @@ class StaticPHPDriverTest extends DoctrineTestCase
|
||||
|
||||
class TestEntity
|
||||
{
|
||||
/** @psalm-param ClassMetadata<object> $metadata */
|
||||
/** @phpstan-param ClassMetadata<object> $metadata */
|
||||
public static function loadMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->getFieldNames();
|
||||
|
||||
@@ -20,14 +20,14 @@ class TestClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
|
||||
/**
|
||||
* @var ClassMetadata
|
||||
* @psalm-var CMTemplate
|
||||
* @phpstan-var CMTemplate
|
||||
*/
|
||||
public $metadata;
|
||||
|
||||
/** @var callable|null */
|
||||
public $fallbackCallback;
|
||||
|
||||
/** @psalm-param CMTemplate $metadata */
|
||||
/** @phpstan-param CMTemplate $metadata */
|
||||
public function __construct(MappingDriver $driver, ClassMetadata $metadata)
|
||||
{
|
||||
$this->driver = $driver;
|
||||
|
||||
@@ -160,7 +160,7 @@ class ObjectManagerDecoratorTest extends TestCase
|
||||
/** @extends ObjectManagerDecorator<ObjectManager&MockObject> */
|
||||
class NullObjectManagerDecorator extends ObjectManagerDecorator
|
||||
{
|
||||
/** @psalm-param ObjectManager&MockObject $wrapped */
|
||||
/** @phpstan-param ObjectManager&MockObject $wrapped */
|
||||
public function __construct(ObjectManager $wrapped)
|
||||
{
|
||||
$this->wrapped = $wrapped;
|
||||
|
||||
Reference in New Issue
Block a user