Skip to content

Commit

Permalink
Added support for 2.8.2 (#14)
Browse files Browse the repository at this point in the history
* Added support for 2.8.2

* Fixed patch

* disable caching dependencies in ci
  • Loading branch information
sspat authored Jul 3, 2021
1 parent 191df8e commit b2f0e4c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ jobs:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
- name: "Cache dependencies"
uses: "actions/cache@v2"
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
- name: "Install lowest dependencies"
if: ${{ matrix.dependencies == 'lowest' }}
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ If you choose this path, you can install this package in the following steps:
```
Then depending on the version of doctrine/orm you want to use:

- run `composer require sspat/doctrine-nullable-embeddables:v2.8.2 doctrine/orm`
- run `composer require sspat/doctrine-nullable-embeddables:v2.8.1 doctrine/orm`
- run `composer require sspat/doctrine-nullable-embeddables:v2.8.0 doctrine/orm`
- run `composer require sspat/doctrine-nullable-embeddables:v2.7.5 doctrine/orm`
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "^7.4|^8.0",
"cweagans/composer-patches": "^1.6|^1.7",
"doctrine/orm": "2.8.1"
"doctrine/orm": "2.8.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand All @@ -31,7 +31,7 @@
"extra": {
"patches": {
"doctrine/orm": {
"Allow nullable embeddables": "https://raw.githubusercontent.com/sspat/doctrine-nullable-embeddables/v2.8.1/patch/nullable_embeddables.patch"
"Allow nullable embeddables": "https://raw.githubusercontent.com/sspat/doctrine-nullable-embeddables/v2.8.2/patch/nullable_embeddables.patch"
}
}
},
Expand Down
24 changes: 11 additions & 13 deletions patch/nullable_embeddables.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
diff --git a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php
index b224fff4e..13404d91a 100644
index 49a2ab2..8f3d6f7 100644
--- a/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php
+++ b/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php
@@ -72,13 +72,16 @@ class ReflectionEmbeddedProperty extends ReflectionProperty
@@ -63,13 +63,15 @@ class ReflectionEmbeddedProperty extends ReflectionProperty
*/
public function getValue($object = null)
{
- $embeddedObject = $this->parentProperty->getValue($object);
+ $embeddedObject = ! $this->parentProperty->getDeclaringClass()->isInstance($object) ||
+ $this->parentProperty->isInitialized($object) ?
+ $embeddedObject = ! $this->parentProperty->getDeclaringClass()->isInstance($object) || $this->parentProperty->isInitialized($object) ?
+ $this->parentProperty->getValue($object) :
+ null;
if (null === $embeddedObject) {

if ($embeddedObject === null) {
return null;
}

- return $this->childProperty->getValue($embeddedObject);
+ return $this->childProperty->isInitialized($embeddedObject) ? $this->childProperty->getValue($embeddedObject) : null;
}

/**
@@ -86,7 +89,21 @@ class ReflectionEmbeddedProperty extends ReflectionProperty
@@ -77,7 +79,20 @@ class ReflectionEmbeddedProperty extends ReflectionProperty
*/
public function setValue($object, $value = null)
{
Expand All @@ -37,10 +36,9 @@ index b224fff4e..13404d91a 100644
+ return;
+ }
+
+ $embeddedObject = ! $this->parentProperty->getDeclaringClass()->isInstance($object) ||
+ $this->parentProperty->isInitialized($object) ?
+ $embeddedObject = ! $this->parentProperty->getDeclaringClass()->isInstance($object) || $this->parentProperty->isInitialized($object) ?
+ $this->parentProperty->getValue($object) :
+ null;
if (null === $embeddedObject) {

if ($embeddedObject === null) {
$this->instantiator = $this->instantiator ?: new Instantiator();

0 comments on commit b2f0e4c

Please sign in to comment.