From 56fd959a24ffcffe71e3089b30895a0478d35ed9 Mon Sep 17 00:00:00 2001 From: HC Torres Date: Sat, 17 Jun 2023 21:49:16 -0300 Subject: [PATCH] Check existence of childTypes method --- src/HasChildren.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/HasChildren.php b/src/HasChildren.php index a25475e..77c8ff7 100644 --- a/src/HasChildren.php +++ b/src/HasChildren.php @@ -267,6 +267,14 @@ public function classToAlias(string $className): string */ public function getChildTypes(): array { - return property_exists($this, 'childTypes') ? $this->childTypes : []; + if (method_exists($this, 'childTypes')) { + return $this->childTypes(); + } + + if (property_exists($this, 'childTypes')) { + return $this->childTypes; + } + + return []; } }