mirror of
https://github.com/doctrine/persistence.git
synced 2026-03-23 22:42:11 +01:00
Drop Psalm
This is an equivalent of1669e8danda17744efor 4.0.x It is easier and safer to re-run the same search and replace than to address conflicts.
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,4 +12,4 @@ 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"
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
"phpstan/phpstan-strict-rules": "^1.1",
|
||||
"doctrine/coding-standard": "^12",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"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,48 +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>
|
||||
<MethodSignatureMismatch>
|
||||
<code><![CDATA[$object]]></code>
|
||||
</MethodSignatureMismatch>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
</file>
|
||||
<file src="src/Persistence/Reflection/RuntimeReflectionProperty.php">
|
||||
<MethodSignatureMismatch>
|
||||
<code><![CDATA[$object]]></code>
|
||||
</MethodSignatureMismatch>
|
||||
</file>
|
||||
<file src="src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php">
|
||||
<MethodSignatureMismatch>
|
||||
<code><![CDATA[$object]]></code>
|
||||
</MethodSignatureMismatch>
|
||||
</file>
|
||||
<file src="tests/Persistence/Mapping/DriverChainTest.php">
|
||||
<TypeDoesNotContainType>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="tests/Persistence/Reflection/Reflection/EnumReflectionPropertyTest.php">
|
||||
<TypeDoesNotContainNull>
|
||||
<code><![CDATA[assertNull]]></code>
|
||||
<code><![CDATA[assertNull]]></code>
|
||||
</TypeDoesNotContainNull>
|
||||
</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>
|
||||
@@ -18,7 +18,7 @@ abstract class AbstractManagerRegistry implements ManagerRegistry
|
||||
/**
|
||||
* @param array<string, string> $connections
|
||||
* @param array<string, string> $managers
|
||||
* @psalm-param class-string $proxyInterfaceName
|
||||
* @phpstan-param class-string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $name,
|
||||
@@ -204,7 +204,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|null $persistentManagerName = null,
|
||||
|
||||
@@ -15,7 +15,7 @@ use Doctrine\Persistence\ObjectManager;
|
||||
*/
|
||||
class LifecycleEventArgs extends EventArgs
|
||||
{
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
/** @phpstan-param TObjectManager $objectManager */
|
||||
public function __construct(
|
||||
private readonly object $object,
|
||||
private readonly ObjectManager $objectManager,
|
||||
@@ -31,7 +31,7 @@ class LifecycleEventArgs extends EventArgs
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager(): ObjectManager
|
||||
{
|
||||
|
||||
@@ -17,8 +17,8 @@ use Doctrine\Persistence\ObjectManager;
|
||||
class LoadClassMetadataEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @psalm-param TClassMetadata $classMetadata
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
* @phpstan-param TClassMetadata $classMetadata
|
||||
* @phpstan-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly ClassMetadata $classMetadata,
|
||||
@@ -29,7 +29,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
/**
|
||||
* Retrieves the associated ClassMetadata.
|
||||
*
|
||||
* @psalm-return TClassMetadata
|
||||
* @phpstan-return TClassMetadata
|
||||
*/
|
||||
public function getClassMetadata(): ClassMetadata
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager(): ObjectManager
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ use Doctrine\Persistence\ObjectManager;
|
||||
*/
|
||||
class ManagerEventArgs extends EventArgs
|
||||
{
|
||||
/** @psalm-param TObjectManager $objectManager */
|
||||
/** @phpstan-param TObjectManager $objectManager */
|
||||
public function __construct(
|
||||
private readonly ObjectManager $objectManager,
|
||||
) {
|
||||
@@ -23,7 +23,7 @@ class ManagerEventArgs extends EventArgs
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager(): ObjectManager
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ class OnClearEventArgs extends EventArgs
|
||||
{
|
||||
/**
|
||||
* @param ObjectManager $objectManager The object manager.
|
||||
* @psalm-param TObjectManager $objectManager
|
||||
* @phpstan-param TObjectManager $objectManager
|
||||
*/
|
||||
public function __construct(private readonly ObjectManager $objectManager)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ class OnClearEventArgs extends EventArgs
|
||||
/**
|
||||
* Retrieves the associated ObjectManager.
|
||||
*
|
||||
* @psalm-return TObjectManager
|
||||
* @phpstan-return TObjectManager
|
||||
*/
|
||||
public function getObjectManager(): ObjectManager
|
||||
{
|
||||
|
||||
@@ -22,7 +22,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)
|
||||
{
|
||||
|
||||
@@ -62,9 +62,9 @@ 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
|
||||
*
|
||||
* @psalm-return ObjectRepository<T>
|
||||
* @phpstan-return ObjectRepository<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
|
||||
/**
|
||||
* @var array<string, ClassMetadata>
|
||||
* @psalm-var CMTemplate[]
|
||||
* @phpstan-var CMTemplate[]
|
||||
*/
|
||||
private array $loadedMetadata = [];
|
||||
|
||||
@@ -66,7 +66,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(): array
|
||||
{
|
||||
@@ -108,7 +108,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Wakes up reflection after ClassMetadata gets unserialized from cache.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*/
|
||||
abstract protected function wakeupReflection(
|
||||
ClassMetadata $class,
|
||||
@@ -118,7 +118,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
/**
|
||||
* Initializes Reflection after ClassMetadata was constructed.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*/
|
||||
abstract protected function initializeReflection(
|
||||
ClassMetadata $class,
|
||||
@@ -130,16 +130,16 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
*
|
||||
* This method should return false for mapped superclasses or embedded classes.
|
||||
*
|
||||
* @psalm-param CMTemplate $class
|
||||
* @phpstan-param CMTemplate $class
|
||||
*/
|
||||
abstract protected function isEntity(ClassMetadata $class): bool;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
@@ -179,7 +179,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());
|
||||
@@ -234,8 +234,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
|
||||
*/
|
||||
public function setMetadataFor(string $className, ClassMetadata $class): void
|
||||
{
|
||||
@@ -245,10 +245,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): array
|
||||
{
|
||||
@@ -277,10 +277,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): array
|
||||
{
|
||||
@@ -340,7 +340,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory
|
||||
*
|
||||
* Override this method to implement a fallback strategy for failed metadata loading
|
||||
*
|
||||
* @psalm-return CMTemplate|null
|
||||
* @phpstan-return CMTemplate|null
|
||||
*/
|
||||
protected function onNotFoundMetadata(string $className): ClassMetadata|null
|
||||
{
|
||||
@@ -352,8 +352,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
|
||||
*/
|
||||
abstract protected function doLoadMetadata(
|
||||
ClassMetadata $class,
|
||||
@@ -365,10 +365,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
|
||||
*/
|
||||
@@ -388,7 +388,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);
|
||||
}
|
||||
|
||||
@@ -416,9 +416,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
|
||||
*/
|
||||
@@ -437,9 +437,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
|
||||
*/
|
||||
@@ -448,11 +448,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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ interface ClassMetadata
|
||||
/**
|
||||
* Gets the fully-qualified class name of this persistent class.
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
@@ -26,7 +26,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(): array;
|
||||
|
||||
@@ -88,7 +88,7 @@ interface ClassMetadata
|
||||
/**
|
||||
* Returns the target class name of the given association.
|
||||
*
|
||||
* @psalm-return class-string|null
|
||||
* @phpstan-return class-string|null
|
||||
*/
|
||||
public function getAssociationTargetClass(string $assocName): string|null;
|
||||
|
||||
|
||||
@@ -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(): array;
|
||||
|
||||
@@ -25,7 +25,7 @@ interface ClassMetadataFactory
|
||||
*
|
||||
* @param class-string $className The name of the class.
|
||||
*
|
||||
* @psalm-return T
|
||||
* @phpstan-return T
|
||||
*/
|
||||
public function getMetadataFor(string $className): ClassMetadata;
|
||||
|
||||
@@ -42,7 +42,7 @@ interface ClassMetadataFactory
|
||||
* Sets the metadata descriptor for a specific class.
|
||||
*
|
||||
* @param class-string $className
|
||||
* @psalm-param T $class
|
||||
* @phpstan-param T $class
|
||||
*/
|
||||
public function setMetadataFor(string $className, ClassMetadata $class): void;
|
||||
|
||||
@@ -50,7 +50,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
|
||||
*/
|
||||
public function isTransient(string $className): bool;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ trait ColocatedMappingDriver
|
||||
* Cache for getAllClassNames().
|
||||
*
|
||||
* @var array<int, string>|null
|
||||
* @psalm-var list<class-string>|null
|
||||
* @phpstan-var list<class-string>|null
|
||||
*/
|
||||
protected array|null $classNames = null;
|
||||
|
||||
@@ -112,7 +112,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
|
||||
*/
|
||||
abstract public function isTransient(string $className): bool;
|
||||
|
||||
@@ -120,7 +120,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(): array
|
||||
{
|
||||
|
||||
@@ -131,7 +131,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;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class FileDriver implements MappingDriver
|
||||
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array<class-string, T>|null
|
||||
* @phpstan-var array<class-string, T>|null
|
||||
*/
|
||||
protected array|null $classCache = null;
|
||||
protected string $globalBasename = '';
|
||||
@@ -66,7 +66,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.
|
||||
*
|
||||
@@ -122,7 +122,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 */
|
||||
@@ -138,7 +138,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): array;
|
||||
|
||||
|
||||
@@ -21,7 +21,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): array;
|
||||
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -25,7 +25,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(): array;
|
||||
|
||||
@@ -33,7 +33,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
|
||||
*/
|
||||
public function isTransient(string $className): bool;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
*/
|
||||
class PHPDriver extends FileDriver
|
||||
{
|
||||
/** @psalm-var ClassMetadata<object> */
|
||||
/** @phpstan-var ClassMetadata<object> */
|
||||
protected ClassMetadata $metadata;
|
||||
|
||||
/** @param string|array<int, string>|FileLocator $locator */
|
||||
|
||||
@@ -34,7 +34,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 array|null $classNames = null;
|
||||
|
||||
|
||||
@@ -185,10 +185,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,19 +30,19 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns the shortname of a class.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*/
|
||||
public function getClassShortName(string $class): string;
|
||||
|
||||
/** @psalm-param class-string $class */
|
||||
/** @phpstan-param class-string $class */
|
||||
public function getClassNamespace(string $class): string;
|
||||
|
||||
/**
|
||||
* Returns a reflection class instance or null.
|
||||
*
|
||||
* @psalm-param class-string<T> $class
|
||||
* @phpstan-param class-string<T> $class
|
||||
*
|
||||
* @psalm-return ReflectionClass<T>
|
||||
* @phpstan-return ReflectionClass<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
@@ -51,14 +51,14 @@ interface ReflectionService
|
||||
/**
|
||||
* Returns an accessible property (setAccessible(true)) or null.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*/
|
||||
public function getAccessibleProperty(string $class, string $property): ReflectionProperty|null;
|
||||
|
||||
/**
|
||||
* Checks if the class have a public method with the given name.
|
||||
*
|
||||
* @psalm-param class-string $class
|
||||
* @phpstan-param class-string $class
|
||||
*/
|
||||
public function hasPublicMethod(string $class, string $method): bool;
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ class RuntimeReflectionService implements ReflectionService
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<T> $class
|
||||
* @phpstan-param class-string<T> $class
|
||||
*
|
||||
* @psalm-return ReflectionClass<T>
|
||||
* @phpstan-return ReflectionClass<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
|
||||
@@ -17,10 +17,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
|
||||
*/
|
||||
@@ -82,9 +82,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
|
||||
*/
|
||||
@@ -96,9 +96,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
|
||||
*/
|
||||
@@ -107,7 +107,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(): ClassMetadataFactory;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class ObjectManagerDecorator implements ObjectManager
|
||||
return $this->wrapped->getClassMetadata($className);
|
||||
}
|
||||
|
||||
/** @psalm-return ClassMetadataFactory<ClassMetadata<object>> */
|
||||
/** @phpstan-return ClassMetadataFactory<ClassMetadata<object>> */
|
||||
public function getMetadataFactory(): ClassMetadataFactory
|
||||
{
|
||||
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(mixed $id): object|null;
|
||||
|
||||
@@ -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(): array;
|
||||
|
||||
@@ -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): object|null;
|
||||
|
||||
/**
|
||||
* Returns the class name of the object managed by the repository.
|
||||
*
|
||||
* @psalm-return class-string<T>
|
||||
* @phpstan-return class-string<T>
|
||||
*/
|
||||
public function getClassName(): string;
|
||||
}
|
||||
|
||||
@@ -23,31 +23,16 @@ class EnumReflectionProperty extends ReflectionProperty
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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|null
|
||||
{
|
||||
return $this->originalReflectionProperty->getType();
|
||||
@@ -136,31 +121,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();
|
||||
|
||||
@@ -183,7 +183,7 @@ class TestManagerRegistry extends AbstractManagerRegistry
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @psalm-param class-string $proxyInterfaceName
|
||||
* @phpstan-param class-string $proxyInterfaceName
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
|
||||
@@ -57,10 +57,6 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
{
|
||||
$cmf = $this->getMockForAbstractClass(AbstractClassMetadataFactory::class);
|
||||
$this->expectException(MappingException::class);
|
||||
/**
|
||||
* @psalm-suppress ArgumentTypeCoercion
|
||||
* @psalm-suppress UndefinedClass
|
||||
*/
|
||||
// @phpstan-ignore-next-line
|
||||
$cmf->getMetadataFor('App:Test');
|
||||
}
|
||||
@@ -69,10 +65,6 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
{
|
||||
$cmf = $this->getMockForAbstractClass(AbstractClassMetadataFactory::class);
|
||||
$this->expectException(MappingException::class);
|
||||
/**
|
||||
* @psalm-suppress ArgumentTypeCoercion
|
||||
* @psalm-suppress UndefinedClass
|
||||
*/
|
||||
// @phpstan-ignore-next-line
|
||||
$cmf->isTransient('App:Test');
|
||||
}
|
||||
@@ -87,7 +79,6 @@ final class AbstractClassMetadataFactoryTest extends DoctrineTestCase
|
||||
self::createStub(ClassMetadata::class),
|
||||
);
|
||||
|
||||
/** @psalm-suppress ArgumentTypeCoercion */
|
||||
self::assertSame($cmf->getMetadataFor(SomeOtherEntity::class), $cmf->getMetadataFor('\\' . SomeOtherEntity::class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
/** @covers \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory */
|
||||
class ClassMetadataFactoryTest extends DoctrineTestCase
|
||||
{
|
||||
/** @psalm-var TestClassMetadataFactory<ClassMetadata<object>> */
|
||||
/** @phpstan-var TestClassMetadataFactory<ClassMetadata<object>> */
|
||||
private TestClassMetadataFactory $cmf;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$driver = $this->createMock(MappingDriver::class);
|
||||
|
||||
/** @psalm-var ClassMetadata<object> */
|
||||
/** @phpstan-var ClassMetadata<object> */
|
||||
$metadata = $this->createMock(ClassMetadata::class);
|
||||
$this->cmf = new TestClassMetadataFactory($driver, $metadata);
|
||||
}
|
||||
@@ -183,7 +183,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|null
|
||||
{
|
||||
$method = new ReflectionMethod($classMetadataFactory, 'getCache');
|
||||
|
||||
@@ -14,7 +14,7 @@ use ReflectionClass;
|
||||
*/
|
||||
final class TestClassMetadata implements ClassMetadata
|
||||
{
|
||||
/** @psalm-param class-string<T> $className */
|
||||
/** @phpstan-param class-string<T> $className */
|
||||
public function __construct(private readonly string $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();
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestClassMetadataFactory extends AbstractClassMetadataFactory
|
||||
/** @var callable|null */
|
||||
public $fallbackCallback;
|
||||
|
||||
/** @psalm-param CMTemplate $metadata */
|
||||
/** @phpstan-param CMTemplate $metadata */
|
||||
public function __construct(public MappingDriver $driver, public ClassMetadata $metadata)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -170,7 +170,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