File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 44
55namespace PhpKafka \PhpAvroSchemaGenerator \Parser ;
66
7+ use ReflectionUnionType ;
8+ use ReflectionNamedType ;
79use PhpKafka \PhpAvroSchemaGenerator \PhpClass \PhpClassProperty ;
810use ReflectionClass ;
911use ReflectionProperty ;
@@ -200,9 +202,14 @@ public function getProperties(string $classPath): array
200202 public function getPropertyClass (ReflectionProperty $ property , bool $ ignorePrimitive = true )
201203 {
202204 $ type = null ;
205+ $ phpVersion = false === phpversion () ? '7.0.0 ' : phpversion ();
203206 // Get is explicit type decralation if possible
204- if (version_compare (phpversion (), '7.4.0 ' , '>= ' ) && null !== $ property ->getType ()) {
205- $ type = $ property ->getType ()->getName ();
207+ if (version_compare ($ phpVersion , '7.4.0 ' , '>= ' ) && null !== $ property ->getType ()) {
208+ $ reflectionType = $ property ->getType ();
209+
210+ if ($ reflectionType instanceof ReflectionNamedType) {
211+ $ type = $ reflectionType ->getName ();
212+ }
206213 }
207214
208215 if (is_null ($ type )) { // Try get the content of the @var annotation
You can’t perform that action at this time.
0 commit comments