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 c7775c3

Browse files
committed
Inspect columns in embeddables
1 parent 6c2421a commit c7775c3

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
@@ -64,9 +64,6 @@ public function processNode(Node $node, Scope $scope): array
6464
}
6565

6666
$className = $class->getName();
67-
if ($objectManager->getMetadataFactory()->isTransient($className)) {
68-
return [];
69-
}
7067

7168
try {
7269
$metadata = $objectManager->getClassMetadata($className);

‎tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ public function testCustomType(): void
153153
]);
154154
}
155155

156+
public function testEmbeddable(): void
157+
{
158+
$this->analyse([__DIR__ . '/data/Embeddable.php'], []);
159+
}
160+
161+
public function testBrokenEmbeddable(): void
162+
{
163+
$this->analyse([__DIR__ . '/data/BrokenEmbeddable.php'], [
164+
[
165+
'Property PHPStan\Rules\Doctrine\ORM\BrokenEmbeddable::$one type mapping mismatch: database can contain string|null but property expects string.',
166+
16,
167+
],
168+
]);
169+
}
170+
156171
public function testUnknownType(): void
157172
{
158173
$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 によって変換されたページ (->オリジナル) /