46 if (!isset(self::$scalarTypes[$superTypeName])) {
51 if (isset(self::$scalarTypes[$subTypeName])) {
56 if ($superTypeName === BuiltInTypes::STRING && \method_exists($subTypeName,
'__toString')) {
71 public static function isMatch($superTypeName, $superTypeNullable, $subTypeName, $subTypeNullable, $weak)
74 if ($superTypeName ===
null) {
79 if ($subTypeName ===
null) {
83 $superTypeName = (string)$superTypeName;
84 $subTypeName = (string)$subTypeName;
87 if ($subTypeNullable && !$superTypeNullable) {
89 return $superTypeName === BuiltInTypes::VOID && $subTypeName === BuiltInTypes::VOID;
93 if ($superTypeName === $subTypeName) {
98 if ($superTypeName === BuiltInTypes::ITERABLE) {
99 return $subTypeName === BuiltInTypes::ARRAY
100 || $subTypeName === \Traversable::class
101 || \is_subclass_of($subTypeName, \Traversable::class);
105 if ($superTypeName === BuiltInTypes::CALLABLE) {
106 return $subTypeName === \Closure::class
107 || \method_exists($subTypeName,
'__invoke')
108 || \is_subclass_of($subTypeName, \Closure::class);
112 if (isset(self::$builtInTypes[$superTypeName])) {
118 if (isset(self::$builtInTypes[$subTypeName])) {
122 return \is_subclass_of($subTypeName, $superTypeName);