-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35cfb92
commit e56223f
Showing
4 changed files
with
71 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace PHPStan\DoctrineIntegration\ORM\EntityManagerOrm2; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use RuntimeException; | ||
use function PHPStan\Testing\assertType; | ||
|
||
class Example | ||
{ | ||
/** | ||
* @var EntityManagerInterface | ||
*/ | ||
private $entityManager; | ||
|
||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
public function getPartialReferenceDynamicType(): void | ||
{ | ||
$test = $this->entityManager->getPartialReference(MyEntity::class, 1); | ||
|
||
if ($test === null) { | ||
throw new RuntimeException('Sorry, but no...'); | ||
} | ||
|
||
assertType(MyEntity::class, $test); | ||
|
||
$test->doSomething(); | ||
$test->doSomethingElse(); | ||
} | ||
} | ||
|
||
/** | ||
* @ORM\Entity() | ||
*/ | ||
class MyEntity | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\GeneratedValue() | ||
* @ORM\Column(type="integer") | ||
* | ||
* @var int | ||
*/ | ||
private $id; | ||
|
||
public function doSomething(): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters