Skip to content

Commit c5343f0

Browse files
committed
More tests
1 parent 86f3c26 commit c5343f0

7 files changed

+116
-0
lines changed

tests/DoctrineIntegration/ORM/data/customRepositoryUsage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,9 @@ public function get(int $id): MyEntity
7979

8080
return $entity;
8181
}
82+
83+
public function findOneByBlabla(): int
84+
{
85+
86+
}
8287
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityManagerDynamicReturn\\MyEntity::doSomethingElse().",
4+
"line": 30,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityManagerDynamicReturn\\MyEntity::doSomethingElse().",
9+
"line": 42,
10+
"ignorable": true
11+
},
12+
{
13+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityManagerDynamicReturn\\MyEntity::doSomethingElse().",
14+
"line": 54,
15+
"ignorable": true
16+
}
17+
]

tests/DoctrineIntegration/ORM/data/entityManagerDynamicReturn.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function findDynamicType(): void
2727
}
2828

2929
$test->doSomething();
30+
$test->doSomethingElse();
3031
}
3132

3233
public function getReferenceDynamicType(): void
@@ -38,6 +39,7 @@ public function getReferenceDynamicType(): void
3839
}
3940

4041
$test->doSomething();
42+
$test->doSomethingElse();
4143
}
4244

4345
public function getPartialReferenceDynamicType(): void
@@ -49,6 +51,7 @@ public function getPartialReferenceDynamicType(): void
4951
}
5052

5153
$test->doSomething();
54+
$test->doSomethingElse();
5255
}
5356
}
5457

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityManagerMergeReturn\\MyEntity::doSomethingElse().",
4+
"line": 24,
5+
"ignorable": true
6+
}
7+
]

tests/DoctrineIntegration/ORM/data/entityManagerMergeReturn.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function merge(): void
2121
{
2222
$test = $this->entityManager->merge(new MyEntity());
2323
$test->doSomething();
24+
$test->doSomethingElse();
2425
}
2526
}
2627

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityRepositoryDynamicReturn\\MyEntity::doSomethingElse().",
4+
"line": 88,
5+
"ignorable": true
6+
},
7+
{
8+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityRepositoryDynamicReturn\\MyEntity::doSomethingElse().",
9+
"line": 100,
10+
"ignorable": true
11+
},
12+
{
13+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityRepositoryDynamicReturn\\MyEntity::doSomethingElse().",
14+
"line": 109,
15+
"ignorable": true
16+
},
17+
{
18+
"message": "Call to an undefined method PHPStan\\DoctrineIntegration\\ORM\\EntityRepositoryDynamicReturn\\MyEntity::doSomethingElse().",
19+
"line": 119,
20+
"ignorable": true
21+
}
22+
]

tests/DoctrineIntegration/ORM/data/entityRepositoryDynamicReturn.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function findDynamicType(): void
2828
}
2929

3030
$test->doSomething();
31+
$test->doSomethingElse();
3132
}
3233

3334
public function findOneByDynamicType(): void
@@ -39,6 +40,7 @@ public function findOneByDynamicType(): void
3940
}
4041

4142
$test->doSomething();
43+
$test->doSomethingElse();
4244
}
4345

4446
public function findAllDynamicType(): void
@@ -47,6 +49,7 @@ public function findAllDynamicType(): void
4749

4850
foreach ($items as $test) {
4951
$test->doSomething();
52+
$test->doSomethingElse();
5053
}
5154
}
5255

@@ -56,6 +59,64 @@ public function findByDynamicType(): void
5659

5760
foreach ($items as $test) {
5861
$test->doSomething();
62+
$test->doSomethingElse();
63+
}
64+
}
65+
}
66+
67+
class Example2
68+
{
69+
/**
70+
* @var EntityRepository<MyEntity>
71+
*/
72+
private $repository;
73+
74+
public function __construct(EntityManagerInterface $entityManager)
75+
{
76+
$this->repository = $entityManager->getRepository(MyEntity::class);
77+
}
78+
79+
public function findDynamicType(): void
80+
{
81+
$test = $this->repository->find(1);
82+
83+
if ($test === null) {
84+
throw new RuntimeException('Sorry, but no...');
85+
}
86+
87+
$test->doSomething();
88+
$test->doSomethingElse();
89+
}
90+
91+
public function findOneByDynamicType(): void
92+
{
93+
$test = $this->repository->findOneBy(['blah' => 'testing']);
94+
95+
if ($test === null) {
96+
throw new RuntimeException('Sorry, but no...');
97+
}
98+
99+
$test->doSomething();
100+
$test->doSomethingElse();
101+
}
102+
103+
public function findAllDynamicType(): void
104+
{
105+
$items = $this->repository->findAll();
106+
107+
foreach ($items as $test) {
108+
$test->doSomething();
109+
$test->doSomethingElse();
110+
}
111+
}
112+
113+
public function findByDynamicType(): void
114+
{
115+
$items = $this->repository->findBy(['blah' => 'testing']);
116+
117+
foreach ($items as $test) {
118+
$test->doSomething();
119+
$test->doSomethingElse();
59120
}
60121
}
61122
}

0 commit comments

Comments
 (0)