Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a4149f

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

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

‎src/Rules/Doctrine/ORM/EntityColumnRule.php

Lines changed: 0 additions & 3 deletions
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

Lines changed: 15 additions & 0 deletions
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'], [
Lines changed: 17 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /