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 30cc417

Browse files
Test that UniqueConstraintViolationException from EntityManager::flush() is not marked as dead catch
1 parent 802cc56 commit 30cc417

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Exceptions;
4+
5+
use PHPStan\Rules\Rule;
6+
use PHPStan\Testing\RuleTestCase;
7+
8+
/**
9+
* @extends RuleTestCase<CatchWithUnthrownExceptionRule>
10+
*/
11+
class CatchWithUnthrownExceptionRuleTest extends RuleTestCase
12+
{
13+
14+
protected function getRule(): Rule
15+
{
16+
return self::getContainer()->getByType(CatchWithUnthrownExceptionRule::class);
17+
}
18+
19+
public function testRule(): void
20+
{
21+
$this->analyse([__DIR__ . '/data/unthrown-exception.php'], []);
22+
}
23+
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace UnthrownException;
4+
5+
class FooFacade
6+
{
7+
8+
/** @var \Doctrine\ORM\EntityManager */
9+
private $entityManager;
10+
11+
public function doFoo(): void
12+
{
13+
try {
14+
$this->entityManager->flush();
15+
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException $e) {
16+
// pass
17+
}
18+
}
19+
20+
}

0 commit comments

Comments
(0)

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