Skip to content

Commit

Permalink
PHpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Aug 8, 2024
1 parent 23d4d97 commit 112d8c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @property bool|int $is_map_private
* @property ?int $location_id
* @property Map[]|Collection $maps
* @property ?Location $parent
* @property Location[]|Collection $descendants
* @property Event[]|Collection $events
* @property Character[]|Collection $characters
Expand Down
20 changes: 10 additions & 10 deletions app/Services/Entity/Connections/MapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,14 +666,13 @@ protected function addLocation(): self
*/
protected function addParent(): self
{
if (!method_exists($this->entity->child, 'getParentKeyName')) {
// If not part of the node model, check for the {self}_id attribute
if (!array_key_exists($this->entity->type() . '_id', $this->entity->child->getAttributes())) {
return $this;
}
if (!method_exists($this->entity->child, 'parent')) {
return $this;
}

$parent = $this->entity->child->parent;
/** @var Location $child */
$child = $this->entity->child;
$parent = $child->parent;
if (empty($parent)) {
$this->addChildren();
return $this;
Expand All @@ -700,12 +699,13 @@ protected function addParent(): self
*/
protected function addChildren(): self
{
/** @var MiscModel $children */
if (!method_exists($this->entity->child, 'children')) {
return $this;
}

foreach ($this->entity->child->children()->with(['entity', 'entity.image'])->has('entity')->get() as $related) {
/** @var Location $child */
$child = $this->entity->child;
foreach ($child->children()->with(['entity', 'entity.image'])->has('entity')->get() as $related) {
$this->addEntity($related->entity);
$this->relations[] = [
'target' => $this->entity->id,
Expand Down Expand Up @@ -788,7 +788,7 @@ protected function addMapMarkers(): self
*/
protected function addMaps(): self
{
/** @var Map $parent */
/** @var Location $parent */
$parent = $this->entity->child;
/** @var Map $related */
foreach ($parent->maps()->with(['entity', 'entity.image'])->has('entity')->get() as $related) {
Expand Down Expand Up @@ -831,7 +831,7 @@ protected function addQuests(): self
*/
protected function addRaces(): self
{
/** @var Race $race */
/** @var Character $race */
$race = $this->entity->child;

foreach ($race->races()->with(['entity', 'entity.image'])->has('entity')->get() as $subrace) {
Expand Down

0 comments on commit 112d8c0

Please sign in to comment.