|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Test\ORM\Functional\Ticket; |
|
4
|
|
|
|
|
5
|
|
|
use DateTimeImmutable; |
|
6
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase; |
|
7
|
|
|
|
|
8
|
|
|
final class GH8014Test extends OrmFunctionalTestCase |
|
9
|
|
|
{ |
|
10
|
|
|
protected function setUp() |
|
11
|
|
|
{ |
|
12
|
|
|
parent::setUp(); |
|
13
|
|
|
|
|
14
|
|
|
if (PHP_VERSION_ID >= 70400) { |
|
15
|
|
|
$this->_schemaTool->createSchema( |
|
16
|
|
|
[ |
|
17
|
|
|
$this->_em->getClassMetadata(GH8014Foo::class), |
|
|
|
|
|
|
18
|
|
|
] |
|
19
|
|
|
); |
|
20
|
|
|
} |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function testNonNullablePropertyOfEmbeddableCanBeHydratedWithNullValueInDatabase() |
|
24
|
|
|
{ |
|
25
|
|
|
if (PHP_VERSION_ID < 70400) { |
|
26
|
|
|
self::markTestSkipped('This test only applies to PHP versions higher than 7.4'); |
|
27
|
|
|
|
|
28
|
|
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
$foo = $this->createEntityWithoutTheNullablePropertySet(); |
|
32
|
|
|
$foo = $this->_em->find( |
|
33
|
|
|
GH8014Foo::class, |
|
34
|
|
|
$foo->id |
|
35
|
|
|
); // Used to throw "Typed property Doctrine\Test\ORM\Functional\Ticket\GH8014Bar::$startDate must be an instance of DateTimeImmutable, null used" |
|
36
|
|
|
|
|
37
|
|
|
$this->expectException(\Error::class); |
|
38
|
|
|
$this->expectExceptionMessage('Typed property Doctrine\Test\ORM\Functional\Ticket\GH8014Bar::$startDate must not be accessed before initialization'); |
|
39
|
|
|
$foo->bar->startDate; |
|
40
|
|
|
|
|
41
|
|
|
$foo = $this->createEntityWithTheNullablePropertySet(); |
|
42
|
|
|
$foo = $this->_em->find(GH8014Foo::class, $foo->id); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertNotNull($foo->bar->startDate); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
private function createEntityWithoutTheNullablePropertySet(): GH8014Foo |
|
48
|
|
|
{ |
|
49
|
|
|
$foo = new GH8014Foo(); |
|
50
|
|
|
$this->_em->persist($foo); |
|
51
|
|
|
$this->_em->flush(); |
|
52
|
|
|
$this->_em->clear(); |
|
53
|
|
|
|
|
54
|
|
|
return $foo; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function createEntityWithTheNullablePropertySet(): GH8014Foo |
|
58
|
|
|
{ |
|
59
|
|
|
$foo = new GH8014Foo(); |
|
60
|
|
|
$foo->bar = new GH8014Bar(); |
|
|
|
|
|
|
61
|
|
|
$foo->bar->startDate = new DateTimeImmutable(); |
|
62
|
|
|
$this->_em->persist($foo); |
|
63
|
|
|
$this->_em->flush(); |
|
64
|
|
|
$this->_em->clear(); |
|
65
|
|
|
|
|
66
|
|
|
return $foo; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if (PHP_VERSION_ID >= 70400) { |
|
71
|
|
|
eval(<<<EOPHP |
|
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @Entity() |
|
74
|
|
|
*/ |
|
75
|
|
|
class GH8014Foo |
|
76
|
|
|
{ |
|
77
|
|
|
/** |
|
78
|
|
|
* @var integer |
|
79
|
|
|
* |
|
80
|
|
|
* @Id() |
|
81
|
|
|
* @Column(name="id", type="integer") |
|
82
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
|
83
|
|
|
*/ |
|
84
|
|
|
public \$id; |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @Embedded(class="Doctrine\Test\ORM\Functional\Ticket\GH8014Bar") |
|
88
|
|
|
*/ |
|
89
|
|
|
public ?GH8014Bar \$bar = null; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @Embeddable() |
|
94
|
|
|
*/ |
|
95
|
|
|
class GH8014Bar |
|
96
|
|
|
{ |
|
97
|
|
|
/** |
|
98
|
|
|
* @Column(type="datetime_immutable", nullable=true) |
|
99
|
|
|
*/ |
|
100
|
|
|
public DateTimeImmutable \$startDate; |
|
101
|
|
|
} |
|
102
|
|
|
EOPHP |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths