@@ -142,14 +142,24 @@ public function __construct(...$args)
142
142
$ typeHintGot = \is_object ($ value ) ? \get_class ($ value ) : \gettype ($ value );
143
143
$ reflectionMethod = new \ReflectionMethod ($ this , $ method );
144
144
$ parameter = $ reflectionMethod ->getParameters ()[0 ] ?? null ;
145
- $ typeHintExpected = ($ parameter instanceof \ReflectionParameter ? ($ parameter ->getType () === 'object ' ? $ parameter ->getClass () : $ parameter ->getType ()) : 'Unknown type ' );
146
-
147
- throw new PhpfastcacheInvalidConfigurationException (\sprintf (
148
- 'Invalid type hint found for "%s", expected "%s" got "%s" ' ,
149
- \lcfirst (\substr ($ method , 3 )),
150
- $ typeHintExpected ,
151
- $ typeHintGot
152
- ));
145
+ $ paraReflectionType = $ parameter ->getType ();
146
+ if (method_exists ($ paraReflectionType , "getName " )) {
147
+ $ typeHintExpected = ($ parameter instanceof \ReflectionParameter ? ($ paraReflectionType ->getName () === 'object ' ? $ parameter ->getClass () : $ paraReflectionType ->getName ()) : 'Unknown type ' );
148
+ throw new PhpfastcacheInvalidConfigurationException (\sprintf (
149
+ 'Invalid type hint found for "%s", expected "%s" got "%s" ' ,
150
+ \lcfirst (\substr ($ method , 3 )),
151
+ $ typeHintExpected ,
152
+ $ typeHintGot
153
+ ));
154
+ } else {
155
+ $ typeHintExpected = ($ parameter instanceof \ReflectionParameter ? ($ paraReflectionType === 'object ' ? $ parameter ->getClass () : $ paraReflectionType ) : 'Unknown type ' );
156
+ throw new PhpfastcacheInvalidConfigurationException (\sprintf (
157
+ 'Invalid type hint found for "%s", expected "%s" got "%s" ' ,
158
+ \lcfirst (\substr ($ method , 3 )),
159
+ $ typeHintExpected ,
160
+ $ typeHintGot
161
+ ));
162
+ }
153
163
}
154
164
}
155
165
}
@@ -447,4 +457,4 @@ public function setCacheSlamsTimeout(int $cacheSlamsTimeout): self
447
457
$ this ->cacheSlamsTimeout = $ cacheSlamsTimeout ;
448
458
return $ this ;
449
459
}
450
- }
460
+ }
0 commit comments