Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.4.x' into 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Nov 23, 2024
2 parents a7406cc + 50d7a0f commit 0a4a11b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 56 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ parameters:
count: 1
path: src/Mapping/ClassMetadataFactory.php

-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 1
path: src/Mapping/Driver/AttributeDriver.php

-
message: "#^Method Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\:\\:fromMappingArray\\(\\) should return static\\(Doctrine\\\\ORM\\\\Mapping\\\\ToOneOwningSideMapping\\) but returns Doctrine\\\\ORM\\\\Mapping\\\\ManyToOneAssociationMapping\\|Doctrine\\\\ORM\\\\Mapping\\\\OneToOneOwningSideMapping\\.$#"
count: 1
Expand Down
41 changes: 0 additions & 41 deletions phpstan-dbal3.neon

This file was deleted.

5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ parameters:
message: '#Negated boolean expression is always false\.#'
paths:
- src/Mapping/Driver/AttributeDriver.php

# Compatibility with Persistence 3
-
message: '#Expression on left side of \?\? is not nullable.#'
path: src/Mapping/Driver/AttributeDriver.php
15 changes: 13 additions & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,23 @@
* columnDefinition?: string
* }]]></code>
</MoreSpecificReturnType>
<RedundantCondition>
<code><![CDATA[$metadata->getReflectionClass()]]></code>
</RedundantCondition>
<RedundantConditionGivenDocblockType>
<code><![CDATA[assert($cacheAttribute instanceof Mapping\Cache)]]></code>
<code><![CDATA[assert($method instanceof ReflectionMethod)]]></code>
<code><![CDATA[assert($method instanceof ReflectionMethod)]]></code>
<code><![CDATA[assert($property instanceof ReflectionProperty)]]></code>
</RedundantConditionGivenDocblockType>
<TypeDoesNotContainNull>
<code><![CDATA[new ReflectionClass($metadata->name)]]></code>
</TypeDoesNotContainNull>
</file>
<file src="src/Mapping/Driver/LoadMappingFileImplementation.php">
<LessSpecificImplementedReturnType>
<code><![CDATA[array]]></code>
</LessSpecificImplementedReturnType>
<MissingParamType>
<code><![CDATA[$file]]></code>
</MissingParamType>
Expand Down Expand Up @@ -495,8 +504,11 @@
</file>
<file src="src/Mapping/GetReflectionClassImplementation.php">
<ImplementedReturnTypeMismatch>
<code><![CDATA[ReflectionClass|null]]></code>
<code><![CDATA[ReflectionClass]]></code>
</ImplementedReturnTypeMismatch>
<InvalidNullableReturnType>
<code><![CDATA[ReflectionClass]]></code>
</InvalidNullableReturnType>
</file>
<file src="src/Mapping/ManyToManyInverseSideMapping.php">
<PropertyNotSetInConstructor>
Expand Down Expand Up @@ -963,7 +975,6 @@
</PossiblyNullArrayOffset>
<PossiblyNullReference>
<code><![CDATA[dispatch]]></code>
<code><![CDATA[isSubclassOf]]></code>
</PossiblyNullReference>
</file>
<file src="src/QueryBuilder.php">
Expand Down
5 changes: 1 addition & 4 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,10 +874,7 @@ public function initializeReflection(ReflectionService $reflService): void
{
$this->reflClass = $reflService->getClass($this->name);
$this->namespace = $reflService->getClassNamespace($this->name);

if ($this->reflClass) {
$this->name = $this->rootEntityName = $this->reflClass->name;
}
$this->name = $this->rootEntityName = $this->reflClass->name;

$this->table['name'] = $this->namingStrategy->classToTableName($this->name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public function __wakeup(): void
*/
public function first()
{
if (! $this->initialized && ! $this->isDirty && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) {
if (! $this->initialized && ! $this->isDirty && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) {
$persister = $this->getUnitOfWork()->getCollectionPersister($this->getMapping());

return array_values($persister->slice($this, 0, 1))[0] ?? false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class CompanySQLFilter extends SQLFilter
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias): string
{
if ($targetEntity->getName() === User::class) {
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company'));
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company'));
}

if ($targetEntity->getName() === Order::class) {
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company'));
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company'));
}

return '';
Expand Down
5 changes: 4 additions & 1 deletion tests/Tests/ORM/Mapping/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ArrayObject;
use Doctrine\DBAL\Types\Types;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ChainTypedFieldMapper;
use Doctrine\ORM\Mapping\ClassMetadata;
Expand Down Expand Up @@ -70,6 +71,8 @@

class ClassMetadataTest extends OrmTestCase
{
use VerifyDeprecations;

public function testClassMetadataInstanceSerialization(): void
{
$cm = new ClassMetadata(CmsUser::class);
Expand Down Expand Up @@ -884,7 +887,7 @@ public function testAssociationOverrideCanOverrideCascade(): void
$cm->setAssociationOverride('parentDirectory', ['cascade' => ['all']]);

$mapping = $cm->getAssociationMapping('parentDirectory');
self::assertSame(['remove', 'persist', 'refresh', 'detach'], $mapping['cascade']);
self::assertSame(['remove', 'persist', 'refresh', 'detach'], $mapping->cascade);
}

#[TestGroup('DDC-1955')]
Expand Down

0 comments on commit 0a4a11b

Please sign in to comment.