Skip to content

Commit

Permalink
Merge branch '2.12.x' into 2.13.x
Browse files Browse the repository at this point in the history
* 2.12.x:
  Psalm 4.25.0, PHPStan 1.8.2 (#9941)
  Use a more precise phpdoc for ClassMetadataInfo::versionField than mixed (#9937)
  • Loading branch information
derrabus committed Jul 28, 2022
2 parents 38a9a1c + 8bfe200 commit cd95b2a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"doctrine/annotations": "^1.13",
"doctrine/coding-standard": "^9.0",
"phpbench/phpbench": "^0.16.10 || ^1.0",
"phpstan/phpstan": "~1.4.10 || 1.8.0",
"phpstan/phpstan": "~1.4.10 || 1.8.2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"psr/log": "^1 || ^2 || ^3",
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"vimeo/psalm": "4.24.0"
"vimeo/psalm": "4.25.0"
},
"conflict": {
"doctrine/annotations": "<1.13 || >= 2.0"
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\ORM\Utility\IdentifierFlattener;

use function array_merge;
use function assert;
use function is_array;
use function is_object;
use function reset;
Expand Down Expand Up @@ -57,6 +58,7 @@ public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $e
if ($metadata->requiresFetchAfterChange) {
if ($metadata->isVersioned) {
assert($metadata->versionField !== null);
$data[$metadata->versionField] = $metadata->getFieldValue($entity, $metadata->versionField);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ class ClassMetadataInfo implements ClassMetadata
/**
* READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
*
* @var mixed
* @var string|null
*/
public $versionField;

Expand Down Expand Up @@ -3553,7 +3553,7 @@ public function setVersioned($bool)
* Sets the name of the field that is to be used for versioning if this class is
* versioned for optimistic locking.
*
* @param string $versionField
* @param string|null $versionField
*
* @return void
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ final protected function updateTable(
}

if ($versioned) {
$versionField = $this->class->versionField;
$versionField = $this->class->versionField;
assert($versionField !== null);
$versionFieldType = $this->class->fieldMappings[$versionField]['type'];
$versionColumn = $this->quoteStrategy->getColumnName($versionField, $this->class, $this->platform);

Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use function array_pop;
use function array_sum;
use function array_values;
use function assert;
use function count;
use function current;
use function get_class;
Expand Down Expand Up @@ -1615,6 +1616,8 @@ public function getEntityState($entity, $assume = null)
case $class->isIdentifierNatural():
// Check for a version field, if available, to avoid a db lookup.
if ($class->isVersioned) {
assert($class->versionField !== null);

return $class->getFieldValue($entity, $class->versionField)
? self::STATE_DETACHED
: self::STATE_NEW;
Expand Down Expand Up @@ -2064,6 +2067,7 @@ private function ensureVersionMatch(
return;
}

assert($class->versionField !== null);
$reflField = $class->reflFields[$class->versionField];
$managedCopyVersion = $reflField->getValue($managedCopy);
$entityVersion = $reflField->getValue($entity);
Expand Down Expand Up @@ -2498,6 +2502,7 @@ public function lock($entity, int $lockMode, $lockVersion = null): void
$entity->__load();
}

assert($class->versionField !== null);
$entityVersion = $class->reflFields[$class->versionField]->getValue($entity);

// phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedNotEqualOperator
Expand Down
14 changes: 7 additions & 7 deletions 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.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
<files psalm-version="v4.25.0@d7cd84c4ebca74ba3419b9601f81d177bcbe2aac">
<file src="lib/Doctrine/ORM/AbstractQuery.php">
<DeprecatedClass occurrences="1">
<code>IterableResult</code>
Expand Down Expand Up @@ -281,13 +281,10 @@
</TooManyArguments>
</file>
<file src="lib/Doctrine/ORM/EntityManager.php">
<ArgumentTypeCoercion occurrences="6">
<ArgumentTypeCoercion occurrences="3">
<code>$className</code>
<code>$connection</code>
<code>$entityName</code>
<code>ltrim($className, '\\')</code>
<code>ltrim($entityName, '\\')</code>
<code>ltrim($entityName, '\\')</code>
</ArgumentTypeCoercion>
<DeprecatedMethod occurrences="2">
<code>getMetadataCacheImpl</code>
Expand Down Expand Up @@ -696,10 +693,9 @@
<code>$table</code>
<code>$tableGeneratorDefinition</code>
</PropertyNotSetInConstructor>
<PropertyTypeCoercion occurrences="13">
<PropertyTypeCoercion occurrences="12">
<code>$this-&gt;associationMappings</code>
<code>$this-&gt;associationMappings</code>
<code>$this-&gt;discriminatorMap</code>
<code>$this-&gt;entityListeners</code>
<code>$this-&gt;fieldMappings</code>
<code>$this-&gt;fullyQualifiedClassName($repositoryClassName)</code>
Expand Down Expand Up @@ -1028,6 +1024,10 @@
</MissingParamType>
</file>
<file src="lib/Doctrine/ORM/Mapping/MappingException.php">
<ArgumentTypeCoercion occurrences="2">
<code>$className</code>
<code>$entityName</code>
</ArgumentTypeCoercion>
<MissingParamType occurrences="4">
<code>$className</code>
<code>$className</code>
Expand Down

0 comments on commit cd95b2a

Please sign in to comment.