name; if ($defaultValueName !== 'false' && $defaultValueName !== 'true' && $defaultValueName !== 'null') { $constant = PhpStormStubsSingleton::getPhpStormStubs()->getConstant($defaultValueName); $value = $constant->value; } else { $value = $defaultValueName; } } elseif ($defaultValue instanceof String_ || $defaultValue instanceof LNumber || $defaultValue instanceof DNumber) { $value = strval($defaultValue->value); } elseif ($defaultValue instanceof BitwiseOr) { if ($defaultValue->left instanceof ConstFetch && $defaultValue->right instanceof ConstFetch) { $constants = array_filter( PhpStormStubsSingleton::getPhpStormStubs()->getConstants(), fn (PHPConst $const) => property_exists($defaultValue->left, 'name') && $const->name === (string)$defaultValue->left->name ); /** @var PHPConst $leftConstant */ $leftConstant = array_pop($constants); $constants = array_filter( PhpStormStubsSingleton::getPhpStormStubs()->getConstants(), fn (PHPConst $const) => property_exists($defaultValue->right, 'name') && $const->name === (string)$defaultValue->right->name ); /** @var PHPConst $rightConstant */ $rightConstant = array_pop($constants); $value = $leftConstant->value|$rightConstant->value; } } elseif ($defaultValue instanceof UnaryMinus && property_exists($defaultValue->expr, 'value')) { $value = '-' . $defaultValue->expr->value; } elseif ($defaultValue instanceof ClassConstFetch) { $class = (string)$defaultValue->class; if ($class === 'self' && $contextClass !== null) { $class = $contextClass->name; } $parentClass = PhpStormStubsSingleton::getPhpStormStubs()->getClass($class) ?? PhpStormStubsSingleton::getPhpStormStubs()->getInterface($class); if ($parentClass === null) { throw new Exception("Class $class not found in stubs"); } if ((string)$defaultValue->name === 'class') { $value = (string)$defaultValue->class; } else { $constant = $parentClass->getConstant((string)$defaultValue->name);; $value = $constant->value; } } elseif ($defaultValue === null) { $value = "null"; } elseif (is_array($defaultValue) || $defaultValue instanceof Array_) { $value = '[]'; } else { $value = strval($defaultValue); } return $value; } public static function getParameterRepresentation(PHPFunction $function): string { $result = ''; foreach ($function->parameters as $parameter) { $types = array_unique($parameter->typesFromSignature + Model\CommonUtils::flattenArray($parameter->typesFromAttribute, false)); if (!empty($types)) { $result .= implode('|', $types) . ' '; } if ($parameter->is_passed_by_ref) { $result .= '&'; } if ($parameter->is_vararg) { $result .= '...'; } $result .= '$' . $parameter->name . ', '; } return rtrim($result, ', '); } /** * @param PHPFunction[] $filtered * @return PHPFunction[] * @throws RuntimeException */ protected static function getDuplicatedFunctions(array $filtered): array { $duplicatedFunctions = array_filter($filtered, function (PHPFunction $value, int|string $key) { $duplicatesOfFunction = self::getAllDuplicatesOfFunction($value->name); $functionVersions[] = ParserUtils::getAvailableInVersions( PhpStormStubsSingleton::getPhpStormStubs()->getFunction($value->name, shouldSuitCurrentPhpVersion: false) ); array_push($functionVersions, ...array_values(array_map( fn (PHPFunction $function) => ParserUtils::getAvailableInVersions($function), $duplicatesOfFunction ))); $hasDuplicates = false; $current = array_pop($functionVersions); $next = array_pop($functionVersions); while ($next !== null) { if (!empty(array_intersect($current, $next))) { $hasDuplicates = true; } $current = array_merge($current, $next); $next = array_pop($functionVersions); } return $hasDuplicates; }, ARRAY_FILTER_USE_BOTH); return array_unique(array_map(fn (PHPFunction $function) => $function->name, $duplicatedFunctions)); } /** * @return PHPFunction[] */ protected static function getAllDuplicatesOfFunction(?string $name): array { return array_filter( PhpStormStubsSingleton::getPhpStormStubs()->getFunctions(), fn ($duplicateValue, $duplicateKey) => $duplicateValue->name === $name && str_contains($duplicateKey, 'duplicated'), ARRAY_FILTER_USE_BOTH ); } /** * @param string[] $reflectionTypes * @param string[] $typesFromSignature */ public static function isReflectionTypesMatchSignature(array $reflectionTypes, array $typesFromSignature): bool { return empty(array_merge( array_diff($reflectionTypes, $typesFromSignature), array_diff($typesFromSignature, $reflectionTypes) )); } /** * @param string[] $reflectionTypes * @param string[] $typesFromAttribute */ public static function isReflectionTypesExistInAttributes(array $reflectionTypes, array $typesFromAttribute): bool { return empty(array_merge( array_diff($reflectionTypes, array_filter($typesFromAttribute, fn ($type) => !empty($type))), array_diff(array_filter($typesFromAttribute, fn ($type) => !empty($type)), $reflectionTypes) )); } /** * @param string[][] $typesFromAttribute */ public static function getStringRepresentationOfTypeHintsFromAttributes(array $typesFromAttribute): string { $resultString = ''; foreach ($typesFromAttribute as $types) { $resultString .= '[' . implode('|', $types) . ']'; } return $resultString; } /** * @param string[] $typesToProcess * @param string[] $resultArray */ public static function convertNullableTypesToUnion(array $typesToProcess, array &$resultArray) { array_walk($typesToProcess, function (string $type) use (&$resultArray) { if (str_contains($type, '?')) { array_push($resultArray, 'null', ltrim($type, '?')); } else { $resultArray[] = $type; } }); } } __halt_compiler();----SIGNATURE:----BhQkMW3NFAoQhaX2ew9y31zuD9Dx9m7zpYEGiB28OukZqTy7zJPMsb8h3G9SlncFFEjLhFz2Yste5RmoWJQD7V34SvBv8UJ65tSueyqQ/2Ult/mMch330BRM/b+xx0vwgK3Q3tnO+hwlDnnfIHT+g/GU9ZMs4pKVlW1E3TgIvUUiYoQz8/qgp9L+xErLGQRCzowz0gSjUyJt22OiFUhw3pcuyqRhR30XAQOS6eWDhE1WkBSoMxXTqP7YQDOxg0MV1TmiknmdKOi+bOPA8v/zYNXqj1KozrtbQWHlMumFmlJ9ND9/7T2MW4Zo4uzyCZkz5B5PwRVE4u+KdVi4TD+bN1g2cv4nWhan6lp//+Rk2ls9dltPIdKQPoEfTUO0q+jb0fsfFGtoknauG5SiSt4AdwMjLDv6eCfrfQR/TkdMHXXuRwU2Tij/s8UyikLL+F5iqBsDZ9+r8Z3WmPGmS0liUJPKZ2aSpvHjChkF4Iy+3fPQ/4VvIbD6Q366yR5iC7/rBVJLFz2fvXtayvz2axLvybDJEGHr+o7088+LJoqt9an5tXxJQWWk/DK2lvOS6XMYVpEydwaLCFOv9y3gyK/nx/lltuw6ArUc+rhnkIZVY0Wkvcc2Udrk+G09a1UxuBkVn24bGiEtM+KqVVY4EY7Zi1xIWKxLGLuzt7PqAHCC99k=----ATTACHMENT:----NzQxNzYwMjQ5NjE3MDgzOSAzMDAyNDczMzQyNzc3MzQ5IDIzMzk4OTI5MjcxMjIwNTU=