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 35c5fe1

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

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

‎phpstan.neon‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ parameters:
2727
-
2828
message: '~^Variable property access on PhpParser\\Node\\Stmt\\Declare_\|PhpParser\\Node\\Stmt\\Namespace_\.$~'
2929
path: src/Type/Doctrine/QueryBuilder/OtherMethodQueryBuilderParser.php
30+
-
31+
message: '~^Creating new PHPStan\\Rules\\Exceptions\\CatchWithUnthrownExceptionRule is not covered by backward compatibility promise\. The class might change in a minor PHPStan version\.$~'
32+
path: tests/Rules/Exceptions/CatchWithUnthrownExceptionRuleTest.php
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 new CatchWithUnthrownExceptionRule();
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 によって変換されたページ (->オリジナル) /