Skip to content

Commit c9c3efe

Browse files
committed
fixing phpstan
1 parent f19f6e5 commit c9c3efe

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/Turbo/src/Bridge/Mercure/Broadcaster.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public function broadcast(object $entity, string $action, array $options): void
6565

6666
if ($entity instanceof LazyObjectInterface) {
6767
$entityClass = get_parent_class($entity);
68+
if (false === $entityClass) {
69+
throw new \LogicException('Parent class missing');
70+
}
6871
} else {
6972
$entityClass = ClassUtils::getClass($entity);
7073
}

src/Turbo/src/Broadcaster/TwigBroadcaster.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function broadcast(object $entity, string $action, array $options): void
4747
// handle proxies (both styles)
4848
if ($entity instanceof LazyObjectInterface) {
4949
$class = get_parent_class($entity);
50+
if (false === $class) {
51+
throw new \LogicException('Parent class missing');
52+
}
5053
} else {
5154
$class = ClassUtils::getClass($entity);
5255
}

src/Turbo/src/Doctrine/BroadcastListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ private function storeEntitiesToPublish(EntityManagerInterface $em, object $enti
131131
// handle proxies (both styles)
132132
if ($entity instanceof LazyObjectInterface) {
133133
$class = get_parent_class($entity);
134+
if (false === $class) {
135+
throw new \LogicException('Parent class missing');
136+
}
134137
} else {
135138
$class = ClassUtils::getClass($entity);
136139
}

src/Turbo/tests/app/Kernel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,13 @@ public function artistFromSong(Request $request, EntityManagerInterface $doctrin
284284
$doctrine->flush();
285285
} else {
286286
$song = $doctrine->find(Song::class, $id);
287+
if (!$song) {
288+
throw new NotFoundHttpException();
289+
}
287290
$artist = $song->artist;
291+
if (!$artist) {
292+
throw new NotFoundHttpException();
293+
}
288294
$artist->name = $artist->name.' after change';
289295

290296
$doctrine->flush();

0 commit comments

Comments
 (0)