File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed
tests/DoctrineIntegration/ORM Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,7 @@ includes:
22 - vendor/phpstan/phpstan-strict-rules/rules.neon
33 - vendor/phpstan/phpstan-phpunit/extension.neon
44 - vendor/phpstan/phpstan-phpunit/rules.neon
5+
6+ parameters :
7+ excludes_analyse :
8+ - */tests/*/data/*
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \DoctrineIntegration \ORM ;
4+
5+ use PHPStan \Testing \LevelsTestCase ;
6+
7+ final class EntityManagerIntegrationTest extends LevelsTestCase
8+ {
9+
10+ /**
11+ * @return string[][]
12+ */
13+ public function dataTopics (): array
14+ {
15+ return [['entityManagerDynamicReturn ' ]];
16+ }
17+
18+ public function getDataPath (): string
19+ {
20+ return __DIR__ . '/data ' ;
21+ }
22+
23+ public function getPhpStanExecutablePath (): string
24+ {
25+ return __DIR__ . '/../../../vendor/bin/phpstan ' ;
26+ }
27+
28+ public function getPhpStanConfigPath (): ?string
29+ {
30+ return __DIR__ . '/phpstan.neon ' ;
31+ }
32+
33+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \DoctrineIntegration \ORM \EntityManagerDynamicReturn ;
4+
5+ use Doctrine \ORM \EntityManagerInterface ;
6+ use RuntimeException ;
7+
8+ class Example
9+ {
10+ /**
11+ * @var EntityManagerInterface
12+ */
13+ private $ entityManager ;
14+
15+ public function __construct (EntityManagerInterface $ entityManager )
16+ {
17+ $ this ->entityManager = $ entityManager ;
18+ }
19+
20+ public function findDynamicType (): void
21+ {
22+ $ test = $ this ->entityManager ->find (MyEntity::class, 1 );
23+
24+ if ($ test === null ) {
25+ throw new RuntimeException ('Sorry, but no... ' );
26+ }
27+
28+ $ test ->doSomething ();
29+ }
30+
31+ public function getReferenceDynamicType (): void
32+ {
33+ $ test = $ this ->entityManager ->getReference (MyEntity::class, 1 );
34+ $ test ->doSomething ();
35+ }
36+
37+ public function getPartialReferenceDynamicType (): void
38+ {
39+ $ test = $ this ->entityManager ->getPartialReference (MyEntity::class, 1 );
40+ $ test ->doSomething ();
41+ }
42+ }
43+
44+ /**
45+ * @ORM\Entity()
46+ */
47+ class MyEntity
48+ {
49+ public function doSomething (): void
50+ {
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ includes :
2+ - ../../../extension.neon
You can’t perform that action at this time.
0 commit comments