Skip to content

Commit b99ae3d

Browse files
committed
Inspect columns in embeddables
1 parent 77d3d8e commit b99ae3d

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/Rules/Doctrine/ORM/EntityColumnRule.php

-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ public function processNode(Node $node, Scope $scope): array
6868
}
6969

7070
$className = $class->getName();
71-
if ($objectManager->getMetadataFactory()->isTransient($className)) {
72-
return [];
73-
}
7471

7572
try {
7673
$metadata = $objectManager->getClassMetadata($className);

tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ public function testEmbeddedWithWrongTypeHint(): void
168168
]);
169169
}
170170

171+
public function testEmbeddable(): void
172+
{
173+
$this->analyse([__DIR__ . '/data/Embeddable.php'], []);
174+
}
175+
176+
public function testBrokenEmbeddable(): void
177+
{
178+
$this->analyse([__DIR__ . '/data/BrokenEmbeddable.php'], [
179+
[
180+
'Property PHPStan\Rules\Doctrine\ORM\BrokenEmbeddable::$one type mapping mismatch: database can contain string|null but property expects string.',
181+
16,
182+
],
183+
]);
184+
}
185+
171186
public function testUnknownType(): void
172187
{
173188
$this->analyse([__DIR__ . '/data/EntityWithUnknownType.php'], [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Doctrine\ORM;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Embeddable()
9+
*/
10+
class BrokenEmbeddable
11+
{
12+
/**
13+
* @ORM\Column(type="string", nullable=true)
14+
* @var string
15+
*/
16+
private $one;
17+
}

0 commit comments

Comments
 (0)