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 4
4
5
5
namespace PhpKafka \PhpAvroSchemaGenerator \Parser ;
6
6
7
+ use ReflectionUnionType ;
8
+ use ReflectionNamedType ;
7
9
use PhpKafka \PhpAvroSchemaGenerator \PhpClass \PhpClassProperty ;
8
10
use ReflectionClass ;
9
11
use ReflectionProperty ;
@@ -200,9 +202,14 @@ public function getProperties(string $classPath): array
200
202
public function getPropertyClass (ReflectionProperty $ property , bool $ ignorePrimitive = true )
201
203
{
202
204
$ type = null ;
205
+ $ phpVersion = false === phpversion () ? '7.0.0 ' : phpversion ();
203
206
// 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
+ }
206
213
}
207
214
208
215
if (is_null ($ type )) { // Try get the content of the @var annotation
You can’t perform that action at this time.
0 commit comments