Compability with PHP 8.1 (class_exists calling)

This commit is contained in:
Ilyas Salikhov 2024-01-30 18:31:12 +03:00
parent 66bcfd82e3
commit c764717de4
4 changed files with 10 additions and 10 deletions

View File

@ -627,7 +627,7 @@ class ApiDocExtractor
{ {
if ($actualType == DataTypes::MODEL) { if ($actualType == DataTypes::MODEL) {
if (class_exists($subType)) { if ($subType && class_exists($subType)) {
$parts = explode('\\', $subType); $parts = explode('\\', $subType);
return sprintf('object (%s)', end($parts)); return sprintf('object (%s)', end($parts));
@ -642,7 +642,7 @@ class ApiDocExtractor
return sprintf('array of %ss', $subType); return sprintf('array of %ss', $subType);
} }
if (class_exists($subType)) { if ($subType && class_exists($subType)) {
$parts = explode('\\', $subType); $parts = explode('\\', $subType);
return sprintf('array of objects (%s)', end($parts)); return sprintf('array of objects (%s)', end($parts));

View File

@ -182,7 +182,7 @@ class FormTypeParser implements ParserInterface
$subType = is_object($type) ? get_class($type) : $type; $subType = is_object($type) ? get_class($type) : $type;
if (class_exists($subType)) { if ($subType && class_exists($subType)) {
$parts = explode('\\', $subType); $parts = explode('\\', $subType);
$dataType = sprintf('object (%s)', end($parts)); $dataType = sprintf('object (%s)', end($parts));
} else { } else {
@ -294,7 +294,7 @@ class FormTypeParser implements ParserInterface
$actualType = DataTypes::COLLECTION; $actualType = DataTypes::COLLECTION;
$subType = is_object($embbededType) ? get_class($embbededType) : $embbededType; $subType = is_object($embbededType) ? get_class($embbededType) : $embbededType;
if (class_exists($subType)) { if ($subType && class_exists($subType)) {
$parts = explode('\\', $subType); $parts = explode('\\', $subType);
$bestType = sprintf('array of objects (%s)', end($parts)); $bestType = sprintf('array of objects (%s)', end($parts));
} else { } else {
@ -441,7 +441,7 @@ class FormTypeParser implements ParserInterface
private function implementsType($item) private function implementsType($item)
{ {
if (!class_exists($item)) { if (null === $item || !class_exists($item)) {
return false; return false;
} }

View File

@ -93,7 +93,7 @@ class JmsMetadataParser implements ParserInterface, PostParserInterface
return $result; return $result;
} }
if (class_exists($className)) { if ($className && class_exists($className)) {
$parts = explode('\\', $className); $parts = explode('\\', $className);
$dataType = sprintf('object (%s)', end($parts)); $dataType = sprintf('object (%s)', end($parts));
} else { } else {
@ -180,7 +180,7 @@ class JmsMetadataParser implements ParserInterface, PostParserInterface
} }
// we can use type property also for custom handlers, then we don't have here real class name // we can use type property also for custom handlers, then we don't have here real class name
if (!class_exists($dataType['class'])) { if (!$dataType['class'] || !class_exists($dataType['class'])) {
continue; continue;
} }
@ -252,7 +252,7 @@ class JmsMetadataParser implements ParserInterface, PostParserInterface
} }
// we can use type property also for custom handlers, then we don't have here real class name // we can use type property also for custom handlers, then we don't have here real class name
if (!class_exists($type)) { if (!$type || !class_exists($type)) {
return array( return array(
'normalized' => sprintf("custom handler result for (%s)", $type), 'normalized' => sprintf("custom handler result for (%s)", $type),
'class' => $type, 'class' => $type,

View File

@ -84,7 +84,7 @@ class ValidationParser implements ParserInterface, PostParserInterface
return $parsed; return $parsed;
} }
if (class_exists($className)) { if ($className && class_exists($className)) {
$parts = explode('\\', $className); $parts = explode('\\', $className);
$dataType = sprintf('object (%s)', end($parts)); $dataType = sprintf('object (%s)', end($parts));
} else { } else {
@ -313,7 +313,7 @@ class ValidationParser implements ParserInterface, PostParserInterface
if ($childConstraint instanceof Type) { if ($childConstraint instanceof Type) {
$nestedType = $childConstraint->type; $nestedType = $childConstraint->type;
$exp = explode("\\", $nestedType); $exp = explode("\\", $nestedType);
if (!class_exists($nestedType)) { if (!$nestedType || !class_exists($nestedType)) {
$nestedType = substr($className, 0, strrpos($className, '\\') + 1).$nestedType; $nestedType = substr($className, 0, strrpos($className, '\\') + 1).$nestedType;
if (!class_exists($nestedType)) { if (!class_exists($nestedType)) {