Skip to content

Commit

Permalink
Merge branch '2.11.x' into 3.0.x
Browse files Browse the repository at this point in the history
* 2.11.x:
  Run static analysis with language level PHP 8.1 (doctrine#9314)
  Document LockMode enums (doctrine#9319)
  Document PHPUnit mocks with intersection types (doctrine#9318)
  Run PHP CodeSniffer on PHP 8.1 (doctrine#9317)
  Psalm 4.17.0 (doctrine#9315)
  Run static analysis on PHP 8.1 (doctrine#9310)
  • Loading branch information
derrabus committed Jan 2, 2022
2 parents f151daa + 1599975 commit 9b3d89d
Show file tree
Hide file tree
Showing 28 changed files with 93 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
coding-standards:
uses: "doctrine/.github/.github/workflows/[email protected]"
with:
php-version: "8.0"
php-version: "8.1"
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
dbal-version:
- "default"

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
dbal-version:
- "default"

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "3.6.2",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"vimeo/psalm": "4.16.1"
"vimeo/psalm": "4.17.0"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"
Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ public function flush($entity = null)
* @param int|null $lockVersion The version of the entity to find when using
* optimistic locking.
* @psalm-param class-string<T> $className
* @psalm-param LockMode::*|null $lockMode
*
* @return object|null The entity instance or NULL if the entity can not be found.
* @psalm-return ?T
Expand Down Expand Up @@ -946,6 +947,8 @@ public function hasFilters()
}

/**
* @psalm-param LockMode::* $lockMode
*
* @throws OptimisticLockException
* @throws TransactionRequiredException
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DateTimeInterface;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use Doctrine\ORM\Proxy\ProxyFactory;
Expand Down Expand Up @@ -204,6 +205,7 @@ public function close();
* @param object $entity
* @param int $lockMode
* @param int|DateTimeInterface|null $lockVersion
* @psalm-param LockMode::* $lockMode
*
* @return void
*
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Doctrine\DBAL\LockMode;
use Doctrine\Deprecations\Deprecation;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
Expand Down Expand Up @@ -164,6 +165,7 @@ public function clear()
* or NULL if no specific lock mode should be used
* during the search.
* @param int|null $lockVersion The lock version.
* @psalm-param LockMode::*|null $lockMode
*
* @return object|null The entity instance or NULL if the entity can not be found.
* @psalm-return ?T
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/LazyCriteriaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Persisters\Entity\EntityPersister;
use ReturnTypeWillChange;

/**
* A lazy collection that allows a fast count when using criteria object
Expand Down Expand Up @@ -38,6 +39,7 @@ public function __construct(EntityPersister $entityPersister, Criteria $criteria
*
* @return int
*/
#[ReturnTypeWillChange]
public function count()
{
if ($this->isInitialized()) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping\ClassMetadata;
use ReturnTypeWillChange;
use RuntimeException;

use function array_combine;
Expand Down Expand Up @@ -504,6 +505,7 @@ public function offsetSet($offset, $value): void
*
* @return object|null
*/
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
return $this->remove($offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ public function lock(array $criteria, $lockMode)
* Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister.
*
* @param int|null $lockMode One of the Doctrine\DBAL\LockMode::* constants.
* @psalm-param LockMode::*|null $lockMode
*
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/Persisters/Entity/EntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\ORM\Persisters\Entity;

use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\MappingException;
use Doctrine\ORM\PersistentCollection;
Expand Down Expand Up @@ -54,6 +55,7 @@ public function getInsertSQL();
* @param int|null $limit
* @param int|null $offset
* @param mixed[]|null $orderBy
* @psalm-param LockMode::*|null $lockMode
*
* @return string
*/
Expand Down Expand Up @@ -185,6 +187,7 @@ public function getOwningTable($fieldName);
* @psalm-param array<string, mixed> $criteria
* @psalm-param array<string, mixed>|null $assoc
* @psalm-param array<string, mixed> $hints
* @psalm-param LockMode::*|null $lockMode
* @psalm-param array<string, string>|null $orderBy
*
* @return object|null The loaded and managed entity instance or NULL if the entity can not be found.
Expand Down Expand Up @@ -239,6 +242,7 @@ public function loadOneToOneEntity(array $assoc, $sourceEntity, array $identifie
* @psalm-param array<string, mixed> $id The identifier of the entity as an
* associative array from column or
* field names to values.
* @psalm-param LockMode::*|null $lockMode
*
* @return void
*/
Expand Down Expand Up @@ -300,6 +304,7 @@ public function loadOneToManyCollection(array $assoc, $sourceEntity, PersistentC
*
* @param int $lockMode One of the Doctrine\DBAL\LockMode::* constants.
* @psalm-param array<string, mixed> $criteria
* @psalm-param LockMode::* $lockMode
*
* @return void
*/
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ public function setHydrationMode($hydrationMode): self
* @see \Doctrine\DBAL\LockMode
*
* @param int $lockMode
* @psalm-param LockMode::* $lockMode
*
* @throws TransactionRequiredException
*/
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ static function ($assoc) {
*
* @param object $entity
* @param int|DateTimeInterface|null $lockVersion
* @psalm-param LockMode::* $lockMode
*
* @throws ORMInvalidArgumentException
* @throws TransactionRequiredException
Expand Down
33 changes: 11 additions & 22 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,6 @@ parameters:
count: 2
path: lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php

-
message: "#^Call to an undefined method ReflectionProperty\\:\\:getType\\(\\)\\.$#"
count: 3
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php

-
message: "#^Call to an undefined method ReflectionProperty\\:\\:hasType\\(\\)\\.$#"
count: 1
path: lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php

-
message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\NamingStrategy\\:\\:joinColumnName\\(\\) invoked with 2 parameters, 1 required\\.$#"
count: 2
Expand Down Expand Up @@ -821,18 +811,17 @@ parameters:
path: lib/Doctrine/ORM/Query/Parser.php

-
message:
"""
#^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\|
AST\\\\CollectionMemberExpression\\|
AST\\\\ComparisonExpression\\|
AST\\\\EmptyCollectionComparisonExpression\\|
AST\\\\ExistsExpression\\|
AST\\\\InExpression\\|
AST\\\\InstanceOfExpression\\|
AST\\\\LikeExpression\\|
AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$#
"""
message: """
#^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\|
AST\\\\CollectionMemberExpression\\|
AST\\\\ComparisonExpression\\|
AST\\\\EmptyCollectionComparisonExpression\\|
AST\\\\ExistsExpression\\|
AST\\\\InExpression\\|
AST\\\\InstanceOfExpression\\|
AST\\\\LikeExpression\\|
AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$#
"""
count: 1
path: lib/Doctrine/ORM/Query/Parser.php

Expand Down
2 changes: 1 addition & 1 deletion phpstan-params.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ parameters:
earlyTerminatingMethodCalls:
Doctrine\ORM\Query\Parser:
- syntaxError
phpVersion: 70100
phpVersion: 80100
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.16.1@aa7e400908833b10c0333861f86cd48c510b60eb">
<files psalm-version="4.17.0@6f4707aa41c9174353a6434bba3fc8840f981d9c">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<DeprecatedMethod occurrences="3">
<code>getResultCacheDriver</code>
Expand Down
14 changes: 1 addition & 13 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
phpVersion="8.1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down Expand Up @@ -79,25 +80,12 @@
<file name="lib/Doctrine/ORM/QueryBuilder.php"/>
</errorLevel>
</RedundantCastGivenDocblockType>
<!-- Workaround for https://github.com/vimeo/psalm/issues/7026 -->
<ReservedWord>
<errorLevel type="suppress">
<directory name="lib"/>
<directory name="tests"/>
</errorLevel>
</ReservedWord>
<TypeDoesNotContainType>
<errorLevel type="suppress">
<file name="lib/Doctrine/ORM/Internal/SQLResultCasing.php"/>
<file name="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php"/>
</errorLevel>
</TypeDoesNotContainType>
<UndefinedAttributeClass>
<errorLevel type="suppress">
<!-- The class was added in PHP 8.1 -->
<referencedClass name="ReturnTypeWillChange"/>
</errorLevel>
</UndefinedAttributeClass>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="Doctrine\Common\Cache\ApcCache"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Cache/CacheLoggerChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CacheLoggerChainTest extends DoctrineTestCase
/** @var CacheLoggerChain */
private $logger;

/** @var MockObject|CacheLogger */
/** @var CacheLogger&MockObject */
private $mock;

protected function setUp(): void
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Doctrine\Tests\OrmTestCase;
use InvalidArgumentException;
use LogicException;
use PHPUnit\Framework\MockObject\MockObject;

use function assert;

Expand All @@ -39,7 +40,7 @@
*/
class DefaultCacheFactoryTest extends OrmTestCase
{
/** @var CacheFactory */
/** @var CacheFactory&MockObject */
private $factory;

/** @var EntityManager */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
use Doctrine\ORM\Persisters\Collection\CollectionPersister;
use Doctrine\Tests\Models\Cache\State;
use Doctrine\Tests\OrmTestCase;
use PHPUnit\Framework\MockObject\MockObject;

/**
* @group DDC-2183
*/
abstract class AbstractCollectionPersisterTest extends OrmTestCase
{
/** @var Region */
/** @var Region&MockObject */
protected $region;

/** @var CollectionPersister */
Expand Down Expand Up @@ -70,6 +71,9 @@ protected function setUp(): void
->getMock();
}

/**
* @return Region&MockObject
*/
protected function createRegion(): Region
{
return $this->getMockBuilder(Region::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\Tests\Models\Cache\Country;
use Doctrine\Tests\OrmTestCase;
use PHPUnit\Framework\MockObject\MockObject;

/**
* @group DDC-2183
*/
abstract class AbstractEntityPersisterTest extends OrmTestCase
{
/** @var Region */
/** @var Region&MockObject */
protected $region;

/** @var EntityPersister */
/** @var EntityPersister&MockObject */
protected $entityPersister;

/** @var EntityManager */
Expand All @@ -45,6 +46,9 @@ protected function setUp(): void
$this->entityPersister = $this->createMock(EntityPersister::class);
}

/**
* @return Region&MockObject
*/
protected function createRegion(): Region
{
return $this->createMock(Region::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EntityManagerDecoratorTest extends TestCase
'lock',
];

/** @var EntityManagerInterface|MockObject */
/** @var EntityManagerInterface&MockObject */
private $wrapped;

protected function setUp(): void
Expand Down
Loading

0 comments on commit 9b3d89d

Please sign in to comment.