Skip to content

Commit b1e4a69

Browse files
Add @throws annotation on EntityManagerInterface::flush
1 parent 90e60ba commit b1e4a69

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

stubs/EntityManagerInterface.stub

+16-7
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ interface EntityManagerInterface extends ObjectManager
6060
*/
6161
public function copy($entity, $deep = false);
6262

63-
/**
64-
* @template T of object
65-
* @phpstan-param class-string<T> $className
66-
*
67-
* @phpstan-return ClassMetadata<T>
68-
*/
69-
public function getClassMetadata($className);
63+
/**
64+
* @return void
65+
*
66+
* @throws ORMException
67+
* @throws \Doctrine\DBAL\Exception\UniqueConstraintViolationException
68+
*/
69+
public function flush();
70+
71+
/**
72+
* @template T of object
73+
* @phpstan-param class-string<T> $className
74+
*
75+
* @phpstan-return ClassMetadata<T>
76+
*/
77+
public function getClassMetadata($className);
78+
7079
}

tests/Rules/Exceptions/data/unthrown-exception.php

+8
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ class FooFacade
88
/** @var \Doctrine\ORM\EntityManager */
99
private $entityManager;
1010

11+
/** @var \Doctrine\ORM\EntityManagerInterface */
12+
private $entityManagerInterface;
13+
1114
public function doFoo(): void
1215
{
1316
try {
1417
$this->entityManager->flush();
1518
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
1619
// pass
1720
}
21+
try {
22+
$this->entityManagerInterface->flush();
23+
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
24+
// pass
25+
}
1826
}
1927

2028
}

0 commit comments

Comments
 (0)