Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the lock mode in the "Aggregate Fields" cookbook (aggregate-fields.rst) article. #11311

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Upgrade to 4.0

## Remove array access

Using array access on instances of the following classes is no longer possible:

- `Doctrine\ORM\Mapping\DiscriminatorColumnMapping`
- `Doctrine\ORM\Mapping\EmbedClassMapping`
- `Doctrine\ORM\Mapping\FieldMapping`
- `Doctrine\ORM\Mapping\JoinColumnMapping`
- `Doctrine\ORM\Mapping\JoinTableMapping`

# Upgrade to 3.1

## Deprecate passing null to `ClassMetadata::fullyQualifiedClassName()`
Expand Down
2 changes: 1 addition & 1 deletion docs/en/cookbook/aggregate-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ the database using a FOR UPDATE.
use Bank\Entities\Account;
use Doctrine\DBAL\LockMode;

$account = $em->find(Account::class, $accId, LockMode::PESSIMISTIC_READ);
$account = $em->find(Account::class, $accId, LockMode::PESSIMISTIC_WRITE);

Keeping Updates and Deletes in Sync
-----------------------------------
Expand Down
70 changes: 0 additions & 70 deletions src/Mapping/ArrayAccessImplementation.php

This file was deleted.

4 changes: 1 addition & 3 deletions src/Mapping/AssociationMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;
use Exception;
use OutOfRangeException;

Expand All @@ -14,8 +13,7 @@
use function property_exists;
use function sprintf;

/** @template-implements ArrayAccess<string, mixed> */
abstract class AssociationMapping implements ArrayAccess
abstract class AssociationMapping
{
/**
* The names of persistence operations to cascade on the association.
Expand Down
6 changes: 1 addition & 5 deletions src/Mapping/DiscriminatorColumnMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;
use BackedEnum;
use Exception;

use function in_array;
use function property_exists;

/** @template-implements ArrayAccess<string, mixed> */
final class DiscriminatorColumnMapping implements ArrayAccess
final class DiscriminatorColumnMapping
{
use ArrayAccessImplementation;

/** The database length of the column. Optional. Default value taken from the type. */
public int|null $length = null;

Expand Down
7 changes: 1 addition & 6 deletions src/Mapping/EmbeddedClassMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;

use function property_exists;

/** @template-implements ArrayAccess<string, mixed> */
final class EmbeddedClassMapping implements ArrayAccess
final class EmbeddedClassMapping
{
use ArrayAccessImplementation;

public string|false|null $columnPrefix = null;
public string|null $declaredField = null;
public string|null $originalField = null;
Expand Down
6 changes: 1 addition & 5 deletions src/Mapping/FieldMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;
use BackedEnum;

use function in_array;
use function property_exists;

/** @template-implements ArrayAccess<string, mixed> */
final class FieldMapping implements ArrayAccess
final class FieldMapping
{
use ArrayAccessImplementation;

/** The database length of the column. Optional. Default value taken from the type. */
public int|null $length = null;
/**
Expand Down
7 changes: 1 addition & 6 deletions src/Mapping/JoinColumnMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;

use function property_exists;

/** @template-implements ArrayAccess<string, mixed> */
final class JoinColumnMapping implements ArrayAccess
final class JoinColumnMapping
{
use ArrayAccessImplementation;

public bool|null $unique = null;
public bool|null $quoted = null;
public string|null $fieldName = null;
Expand Down
7 changes: 1 addition & 6 deletions src/Mapping/JoinTableMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

namespace Doctrine\ORM\Mapping;

use ArrayAccess;

use function array_map;
use function in_array;

/** @template-implements ArrayAccess<string, mixed> */
final class JoinTableMapping implements ArrayAccess
final class JoinTableMapping
{
use ArrayAccessImplementation;

public bool|null $quoted = null;

/** @var list<JoinColumnMapping> */
Expand Down
40 changes: 0 additions & 40 deletions tests/Tests/ORM/Mapping/AssociationMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\ORM\Mapping\AssociationMapping;
use Doctrine\ORM\Mapping\ClassMetadata;
use OutOfRangeException;
use PHPUnit\Framework\TestCase;

use function assert;
Expand Down Expand Up @@ -50,45 +49,6 @@ public function testItSurvivesSerialization(): void
self::assertTrue($resurrectedMapping->orphanRemoval);
self::assertTrue($resurrectedMapping->unique);
}

public function testItThrowsWhenAccessingUnknownProperty(): void
{
$mapping = new MyAssociationMapping(
fieldName: 'foo',
sourceEntity: self::class,
targetEntity: self::class,
);

$this->expectException(OutOfRangeException::class);

$mapping['foo'];
}

public function testItThrowsWhenSettingUnknownProperty(): void
{
$mapping = new MyAssociationMapping(
fieldName: 'foo',
sourceEntity: self::class,
targetEntity: self::class,
);

$this->expectException(OutOfRangeException::class);

$mapping['foo'] = 'bar';
}

public function testItThrowsWhenUnsettingUnknownProperty(): void
{
$mapping = new MyAssociationMapping(
fieldName: 'foo',
sourceEntity: self::class,
targetEntity: self::class,
);

$this->expectException(OutOfRangeException::class);

unset($mapping['foo']);
}
}

class MyAssociationMapping extends AssociationMapping
Expand Down
Loading