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 567d167
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 61 deletions.
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
9 changes: 7 additions & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@
</RedundantConditionGivenDocblockType>
</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 +498,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 +969,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
6 changes: 1 addition & 5 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ public function isTransient(string $className): bool
*/
public function loadMetadataForClass(string $className, PersistenceClassMetadata $metadata): void
{
$reflectionClass = $metadata->getReflectionClass()
// this happens when running attribute driver in combination with
// static reflection services. This is not the nicest fix
?? new ReflectionClass($metadata->name);

$reflectionClass = $metadata->getReflectionClass();
$classAttributes = $this->reader->getClassAttributes($reflectionClass);

// Evaluate Entity attribute
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 567d167

Please sign in to comment.