Skip to content

Commit

Permalink
Merge pull request #10401 from greg0ire/3.0.x
Browse files Browse the repository at this point in the history
Merge 2.15.x up into 3.0.x
  • Loading branch information
greg0ire authored Jan 14, 2023
2 parents c8b0931 + d4c53a8 commit 3cd65b1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 62 deletions.
19 changes: 19 additions & 0 deletions docs/en/reference/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ classes, and non-entity classes may extend entity classes.
never calls entity constructors, thus you are free to use them as
you wish and even have it require arguments of any type.

Mapped Superclasses
~~~~~~~~~~~~~~~~~~~

A mapped superclass is an abstract or concrete class that provides
persistent entity state and mapping information for its subclasses,
but which is not itself an entity.

Mapped superclasses are explained in greater detail in the chapter
on :doc:`inheritance mapping <reference/inheritance-mapping>`.

Transient Classes
~~~~~~~~~~~~~~~~~

The term "transient class" appears in some places in the mapping
drivers as well as the code dealing with metadata handling.

A transient class is a class that is neither an entity nor a mapped
superclass. From the ORM's point of view, these classes can be
completely ignored, and no class metadata is loaded for them at all.

Entity states
~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/inheritance-mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ like this (this is for SQLite):

.. code-block:: sql
CREATE TABLE EntitySubClass (mapped1 INTEGER NOT NULL, mapped2 TEXT NOT NULL, id INTEGER NOT NULL, name TEXT NOT NULL, related1_id INTEGER DEFAULT NULL, PRIMARY KEY(id))
CREATE TABLE Employee (mapped1 INTEGER NOT NULL, mapped2 TEXT NOT NULL, id INTEGER NOT NULL, name TEXT NOT NULL, toothbrush_id INTEGER DEFAULT NULL, PRIMARY KEY(id))
As you can see from this DDL snippet, there is only a single table
for the entity subclass. All the mappings from the mapped
Expand Down
14 changes: 7 additions & 7 deletions lib/Doctrine/ORM/OptimisticLockException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
class OptimisticLockException extends Exception implements ORMException
{
/**
* @param string $msg
* @param object|null $entity
* @param string $msg
* @param object|string|null $entity
*/
public function __construct($msg, private $entity, Throwable|null $previous = null)
{
Expand All @@ -27,15 +27,15 @@ public function __construct($msg, private $entity, Throwable|null $previous = nu
/**
* Gets the entity that caused the exception.
*
* @return object|null
* @return object|string|null
*/
public function getEntity()
{
return $this->entity;
}

/**
* @param object $entity
* @param object|class-string $entity
*
* @return OptimisticLockException
*/
Expand All @@ -45,9 +45,9 @@ public static function lockFailed($entity)
}

/**
* @param object $entity
* @param int|DateTimeInterface $expectedLockVersion
* @param int|DateTimeInterface $actualLockVersion
* @param object $entity
* @param int|string|DateTimeInterface $expectedLockVersion
* @param int|string|DateTimeInterface $actualLockVersion
*
* @return OptimisticLockException
*/
Expand Down
4 changes: 0 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ parameters:
count: 2
path: lib/Doctrine/ORM/Query/SqlWalker.php

-
message: "#^Parameter \\#1 \\$entity of static method Doctrine\\\\ORM\\\\OptimisticLockException\\:\\:lockFailed\\(\\) expects object, class\\-string\\<object\\> given\\.$#"
count: 1
path: lib/Doctrine/ORM/Query/SqlWalker.php

-
message: "#^Parameter \\#3 \\$condExpr of method Doctrine\\\\ORM\\\\Query\\\\SqlWalker\\:\\:walkJoinAssociationDeclaration\\(\\) expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalPrimary\\|null, Doctrine\\\\ORM\\\\Query\\\\AST\\\\ConditionalExpression\\|null given\\.$#"
Expand Down
84 changes: 37 additions & 47 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -323,48 +323,6 @@
<code>$class</code>
</PossiblyNullArgument>
</file>
<file src="lib/Doctrine/ORM/Mapping/ClassMetadata.php">
<PropertyNotSetInConstructor occurrences="2">
<code>ClassMetadata</code>
<code>ClassMetadata</code>
</PropertyNotSetInConstructor>
</file>
<file src="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php">
<ArgumentTypeCoercion occurrences="2">
<code>$nonSuperclassParents</code>
<code>new $definition['class']()</code>
</ArgumentTypeCoercion>
<InvalidArrayOffset occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</InvalidArrayOffset>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$subClass-&gt;table</code>
</InvalidPropertyAssignmentValue>
<PossiblyInvalidArrayAssignment occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</PossiblyInvalidArrayAssignment>
<PossiblyInvalidIterator occurrences="1">
<code>$parentClass-&gt;table[$indexType]</code>
</PossiblyInvalidIterator>
<PossiblyNullArgument occurrences="2">
<code>$this-&gt;em</code>
<code>$this-&gt;em</code>
</PossiblyNullArgument>
<PossiblyNullReference occurrences="8">
<code>getAllClassNames</code>
<code>getConfiguration</code>
<code>getConfiguration</code>
<code>getConfiguration</code>
<code>getConnection</code>
<code>hasListeners</code>
<code>hasListeners</code>
<code>loadMetadataForClass</code>
</PossiblyNullReference>
<RedundantCondition occurrences="2">
<code>$parent-&gt;generatorType</code>
<code>$parent-&gt;idGenerator</code>
</RedundantCondition>
</file>
<file src="lib/Doctrine/ORM/Mapping/ClassMetadata.php">
<DeprecatedProperty occurrences="4">
<code>$this-&gt;columnNames</code>
Expand Down Expand Up @@ -480,6 +438,42 @@
<code>$this-&gt;table</code>
</TypeDoesNotContainType>
</file>
<file src="lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php">
<ArgumentTypeCoercion occurrences="2">
<code>$nonSuperclassParents</code>
<code>new $definition['class']()</code>
</ArgumentTypeCoercion>
<InvalidArrayOffset occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</InvalidArrayOffset>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$subClass-&gt;table</code>
</InvalidPropertyAssignmentValue>
<PossiblyInvalidArrayAssignment occurrences="1">
<code>$subClass-&gt;table[$indexType][$indexName]</code>
</PossiblyInvalidArrayAssignment>
<PossiblyInvalidIterator occurrences="1">
<code>$parentClass-&gt;table[$indexType]</code>
</PossiblyInvalidIterator>
<PossiblyNullArgument occurrences="2">
<code>$this-&gt;em</code>
<code>$this-&gt;em</code>
</PossiblyNullArgument>
<PossiblyNullReference occurrences="8">
<code>getAllClassNames</code>
<code>getConfiguration</code>
<code>getConfiguration</code>
<code>getConfiguration</code>
<code>getConnection</code>
<code>hasListeners</code>
<code>hasListeners</code>
<code>loadMetadataForClass</code>
</PossiblyNullReference>
<RedundantCondition occurrences="2">
<code>$parent-&gt;generatorType</code>
<code>$parent-&gt;idGenerator</code>
</RedundantCondition>
</file>
<file src="lib/Doctrine/ORM/Mapping/DefaultEntityListenerResolver.php">
<InvalidStringClass occurrences="1">
<code>new $className()</code>
Expand Down Expand Up @@ -1346,10 +1340,9 @@
<code>$this-&gt;conn-&gt;quote((string) $newValue)</code>
<code>is_string($expression)</code>
</DocblockTypeContradiction>
<InvalidArgument occurrences="3">
<InvalidArgument occurrences="2">
<code>$assoc</code>
<code>$join-&gt;conditionalExpression</code>
<code>$selectedClass['class']-&gt;name</code>
</InvalidArgument>
<PossiblyInvalidArgument occurrences="1">
<code>$expr</code>
Expand Down Expand Up @@ -1555,9 +1548,6 @@
<code>$selectStatement-&gt;whereClause-&gt;conditionalExpression instanceof ConditionalFactor</code>
<code>$selectStatement-&gt;whereClause-&gt;conditionalExpression instanceof ConditionalPrimary</code>
</DocblockTypeContradiction>
<MissingClosureReturnType occurrences="1">
<code>static function ($id) use ($connection, $type) {</code>
</MissingClosureReturnType>
<PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$selectStatement-&gt;whereClause-&gt;conditionalExpression</code>
</PossiblyInvalidPropertyAssignmentValue>
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH6682Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public function testIssue(): void
'initialValue' => '',
];

$classMetadataInfo = new ClassMetadata('test_entity');
$classMetadataInfo->setSequenceGeneratorDefinition($parsedDefinition);
$classMetadata = new ClassMetadata('test_entity');
$classMetadata->setSequenceGeneratorDefinition($parsedDefinition);

self::assertSame(
['sequenceName' => 'test_sequence', 'allocationSize' => '1', 'initialValue' => '1'],
$classMetadataInfo->sequenceGeneratorDefinition,
$classMetadata->sequenceGeneratorDefinition,
);
}
}

0 comments on commit 3cd65b1

Please sign in to comment.