Skip to content
Merged
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
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ awareness about deprecated code.
- Use of our low-overhead runtime deprecation API, details:
https://github.com/doctrine/deprecations/

# Upgrade to 4.0

Deprecated classes have been removed:

- `Doctrine\Persistence\Reflection\RuntimePublicReflectionProperty`
- `Doctrine\Persistence\Reflection\TypedNoDefaultRuntimePublicReflectionProperty`

# Upgrade to 3.3

## Added method `ObjectManager::isUninitializedObject()`
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ parameters:
count: 1
path: src/Persistence/Reflection/EnumReflectionProperty.php

-
message: "#^Variable property access on \\$this\\(Doctrine\\\\Persistence\\\\Reflection\\\\TypedNoDefaultRuntimePublicReflectionProperty\\)\\.$#"
count: 1
path: src/Persistence/Reflection/TypedNoDefaultRuntimePublicReflectionProperty.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\{'Doctrine\\\\\\\\Tests…', 'Doctrine\\\\\\\\Tests\\\\\\\\ORM…', 'Doctrine\\\\\\\\Tests\\\\\\\\ORM…'\\} and array\\<int, class\\-string\\> will always evaluate to false\\.$#"
count: 1
Expand All @@ -60,11 +55,6 @@ parameters:
count: 1
path: tests/Persistence/Mapping/SymfonyFileLocatorTest.php

-
message: "#^Property Doctrine\\\\Tests\\\\Persistence\\\\RuntimePublicReflectionPropertyTestProxyMock\\:\\:\\$checkedProperty \\(string\\) in isset\\(\\) is not nullable\\.$#"
count: 1
path: tests/Persistence/RuntimePublicReflectionPropertyTest.php

-
message: "#^Method Doctrine\\\\Tests\\\\Persistence\\\\RuntimeReflectionPropertyTestProxyMock\\:\\:__setInitialized\\(\\) has parameter \\$initialized with no type specified\\.$#"
count: 1
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ parameters:
# https://github.com/phpstan/phpstan/issues/5009
-
message: '#Call to function assert\(\) with true will always evaluate to true\.#'
path: 'src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php'
path: 'src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php'

-
message: '#Instanceof between Closure and Closure will always evaluate to true\.#'
path: 'src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php'
path: 'src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php'

-
message: '#Class Foo not found#'
Expand Down
61 changes: 0 additions & 61 deletions src/Persistence/Reflection/RuntimePublicReflectionProperty.php

This file was deleted.

55 changes: 54 additions & 1 deletion src/Persistence/Reflection/TypedNoDefaultReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,63 @@

namespace Doctrine\Persistence\Reflection;

use Closure;
use ReturnTypeWillChange;

use function assert;

/**
* PHP Typed No Default Reflection Property - special override for typed properties without a default value.
*/
class TypedNoDefaultReflectionProperty extends RuntimeReflectionProperty
{
use TypedNoDefaultReflectionPropertyBase;
/**
* {@inheritDoc}
*
* Checks that a typed property is initialized before accessing its value.
* This is necessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* Should be used only for reflecting typed properties without a default value.
*
* @param object|null $object
*
* @return mixed
*/
#[ReturnTypeWillChange]
public function getValue($object = null)
{
return $object !== null && $this->isInitialized($object) ? parent::getValue($object) : null;
}

/**
* {@inheritDoc}
*
* Works around the problem with setting typed no default properties to
* NULL which is not supported, instead unset() to uninitialize.
*
* @link https://github.com/doctrine/orm/issues/7999
*
* @param object|null $object
*
* @return void
*/
#[ReturnTypeWillChange]
public function setValue($object, $value = null)
{
if ($value === null && $this->hasType() && ! $this->getType()->allowsNull()) {
$propertyName = $this->getName();

$unsetter = function () use ($propertyName): void {
unset($this->$propertyName);
};
$unsetter = $unsetter->bindTo($object, $this->getDeclaringClass()->getName());

assert($unsetter instanceof Closure);

$unsetter();

return;
}

parent::setValue($object, $value);
}
}

This file was deleted.

This file was deleted.

Loading