Skip to content

Commit b1f8253

Browse files
authored
Merge pull request doctrine#11772 from doctrine/2.20.x
Merge 2.20.x up into 3.3.x
2 parents 7b9c0d9 + e3cabad commit b1f8253

8 files changed

+39
-20
lines changed

.github/workflows/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ on:
2424

2525
jobs:
2626
coding-standards:
27-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@6.0.0"
27+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.1.0"

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ on:
1717
jobs:
1818
documentation:
1919
name: "Documentation"
20-
uses: "doctrine/.github/.github/workflows/documentation.yml@6.0.0"
20+
uses: "doctrine/.github/.github/workflows/documentation.yml@7.1.0"

.github/workflows/release-on-milestone-closed.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
release:
10-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@6.0.0"
10+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.1.0"
1111
secrets:
1212
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1313
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

docs/en/reference/basic-mapping.rst

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Here is a complete list of ``Column``s attributes (all optional):
167167
- ``nullable`` (default: ``false``): Whether the column is nullable.
168168
- ``insertable`` (default: ``true``): Whether the column should be inserted.
169169
- ``updatable`` (default: ``true``): Whether the column should be updated.
170+
- ``generated`` (default: ``null``): Whether the generated strategy should be ``'NEVER'``, ``'INSERT'`` and ``ALWAYS``.
170171
- ``enumType`` (requires PHP 8.1 and ``doctrine/orm`` 2.11): The PHP enum class name to convert the database value into.
171172
- ``precision`` (default: 0): The precision for a decimal (exact numeric) column
172173
(applies only for decimal column),

docs/en/tutorials/override-field-association-mappings-in-subclasses.rst

+13-15
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,28 @@ i.e. attributes and associations metadata in particular. The example here shows
99
the overriding of a class that uses a trait but is similar when extending a base
1010
class as shown at the end of this tutorial.
1111

12-
Suppose we have a class ExampleEntityWithOverride. This class uses trait ExampleTrait:
12+
Suppose we have a class ``ExampleEntityWithOverride``. This class uses trait ``ExampleTrait``:
1313

1414
.. code-block:: php
1515
1616
<?php
1717
1818
#[Entity]
1919
#[AttributeOverrides([
20-
new AttributeOverride('foo', [
21-
'column' => new Column([
22-
'name' => 'foo_overridden',
23-
'type' => 'integer',
24-
'length' => 140,
25-
'nullable' => false,
26-
'unique' => false,
27-
]),
28-
]),
20+
new AttributeOverride('foo', new Column(
21+
name: 'foo_overridden',
22+
type: 'integer',
23+
length: 140,
24+
nullable: false,
25+
unique: false,
26+
)),
2927
])]
3028
#[AssociationOverrides([
3129
new AssociationOverride('bar', [
32-
'joinColumns' => new JoinColumn([
33-
'name' => 'example_entity_overridden_bar_id',
34-
'referencedColumnName' => 'id',
35-
]),
30+
new JoinColumn(
31+
name: 'example_entity_overridden_bar_id',
32+
referencedColumnName: 'id',
33+
),
3634
]),
3735
])]
3836
class ExampleEntityWithOverride
@@ -47,7 +45,7 @@ Suppose we have a class ExampleEntityWithOverride. This class uses trait Example
4745
private $id;
4846
}
4947
50-
The docblock is showing metadata override of the attribute and association type. It
48+
``#[AttributeOverrides]`` contains metadata override of the attribute and association type. It
5149
basically changes the names of the columns mapped for a property ``foo`` and for
5250
the association ``bar`` which relates to Bar class shown above. Here is the trait
5351
which has mapping metadata that is overridden by the attribute above:

phpcs.xml.dist

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0"?>
2-
<ruleset>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
name="PHP_CodeSniffer"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
35
<arg name="basepath" value="."/>
46
<arg name="extensions" value="php"/>
57
<arg name="parallel" value="80"/>

src/UnitOfWork.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ public function createEntity(string $className, array $data, array &$hints = [])
23942394
$oid = spl_object_id($entity);
23952395
$this->registerManaged($entity, $id, $data);
23962396

2397-
if (isset($hints[Query::HINT_READ_ONLY])) {
2397+
if (isset($hints[Query::HINT_READ_ONLY]) && $hints[Query::HINT_READ_ONLY] === true) {
23982398
$this->readOnlyObjects[$oid] = true;
23992399
}
24002400
}

tests/Tests/ORM/Functional/ReadOnlyTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ public function testReadOnlyQueryHint(): void
8888
self::assertTrue($this->_em->getUnitOfWork()->isReadOnly($user));
8989
}
9090

91+
public function testNotReadOnlyQueryHint(): void
92+
{
93+
$user = new ReadOnlyEntity('beberlei', 1234);
94+
95+
$this->_em->persist($user);
96+
97+
$this->_em->flush();
98+
$this->_em->clear();
99+
100+
$query = $this->_em->createQuery('SELECT u FROM ' . ReadOnlyEntity::class . ' u WHERE u.id = ?1');
101+
$query->setParameter(1, $user->id);
102+
$query->setHint(Query::HINT_READ_ONLY, false);
103+
104+
$user = $query->getSingleResult();
105+
106+
self::assertFalse($this->_em->getUnitOfWork()->isReadOnly($user));
107+
}
108+
91109
public function testNotReadOnlyIfObjectWasProxyBefore(): void
92110
{
93111
$user = new ReadOnlyEntity('beberlei', 1234);

0 commit comments

Comments
 (0)