|
292 | 292 | /** @var AttributeGroup $attrGroup */ |
293 | 293 | foreach ($classMethod->attrGroups as $attrGroup) { |
294 | 294 | foreach ($attrGroup->attrs as $attr) { |
295 | | - if ($attr->name->getLast() !== 'Route' && $attr->name->getLast() !== 'ApiRoute' && $attr->name->getLast() !== 'FrontpageRoute') { |
| 295 | + if (!in_array($attr->name->getLast(), ['Route', 'ApiRoute', 'FrontpageRoute'], true)) { |
296 | 296 | continue; |
297 | 297 | } |
298 | 298 |
|
|
397 | 397 | // This is very ugly, but since we do not parse the entire source code we can not say with certainty which controller type is used. |
398 | 398 | // To still allow apps to use custom controllers that extend OCSController, we only check the suffix and have the warning if the controller type can not be detected. |
399 | 399 | $isOCS = str_ends_with($parentControllerClass, 'OCSController'); |
400 | | - if ($parentControllerClass !== 'Controller' && $parentControllerClass !== 'ApiController' && $parentControllerClass !== 'OCSController' && !$isOCS) { |
| 400 | + if (!in_array($parentControllerClass, ['Controller', 'ApiController', 'OCSController'], true) && !$isOCS) { |
401 | 401 | Logger::warning($routeName, 'You are extending a custom controller class. Make sure that it ends with "OCSController" if it extends "OCSController" itself.'); |
402 | 402 | } elseif ($isOCS !== ($pathPrefix === '/ocs/v2.php')) { |
403 | 403 | Logger::warning($routeName, 'Do not mix OCS/non-OCS routes and non-OCS/OCS controllers!'); |
|
422 | 422 | Logger::panic($routeName, "Controller '" . $controllerName . "' is marked as ignore but also has other scopes"); |
423 | 423 | } |
424 | 424 |
|
425 | | - $tagName = implode('_', array_map(fn (string $s) => strtolower($s), Helpers::splitOnUppercaseFollowedByNonUppercase(str_replace('\\', '', $controllerName)))); |
| 425 | + $tagName = implode('_', array_map(strtolower(...), Helpers::splitOnUppercaseFollowedByNonUppercase(str_replace('\\', '', $controllerName)))); |
426 | 426 | $doc = $controllerClass->getDocComment()?->getText(); |
427 | | - if ($doc != null && count(array_filter($tags, fn (array $tag): bool => $tag['name'] === $tagName)) == 0) { |
| 427 | + if ($doc != null && count(array_filter($tags, fn (array $tag): bool => $tag['name'] === $tagName)) === 0) { |
428 | 428 | $classDescription = []; |
429 | 429 |
|
430 | 430 | $docNodes = $phpDocParser->parse(new TokenIterator($lexer->tokenize($doc)))->children; |
|
520 | 520 | } |
521 | 521 |
|
522 | 522 | $classMethodInfo = ControllerMethod::parse($routeName, $definitions, $methodFunction, $isPublic, $isAdmin, $isDeprecated, $isPasswordConfirmation, $isCORS, $isOCS); |
523 | | - if (count($classMethodInfo->responses) == 0) { |
| 523 | + if (count($classMethodInfo->responses) === 0) { |
524 | 524 | Logger::error($routeName, 'Returns no responses'); |
525 | 525 | continue; |
526 | 526 | } |
|
612 | 612 | foreach ($urlParameters as $urlParameter) { |
613 | 613 | $matchingParameters = array_filter($route->controllerMethod->parameters, fn (ControllerMethodParameter $param): bool => $param->name == $urlParameter); |
614 | 614 | $requirement = $route->requirements[$urlParameter] ?? null; |
615 | | - if (count($matchingParameters) == 1) { |
| 615 | + if (count($matchingParameters) === 1) { |
616 | 616 | $parameter = $matchingParameters[array_keys($matchingParameters)[0]]; |
617 | 617 |
|
618 | 618 | $schema = $parameter->type->toArray(true); |
|
640 | 640 | continue; |
641 | 641 | } |
642 | 642 | preg_match("/^\^\(([v0-9-.|]*)\)\\$$/m", (string)$requirement, $matches); |
643 | | - if (count($matches) == 2) { |
| 643 | + if (count($matches) === 2) { |
644 | 644 | $enum = explode('|', $matches[1]); |
645 | 645 | } else { |
646 | 646 | Logger::error($route->name, 'Invalid requirement for apiVersion'); |
|
714 | 714 |
|
715 | 715 | $hasEmpty = array_filter($contentTypeResponses, fn (ControllerMethodResponse $response): bool => $response->type == null) !== []; |
716 | 716 | $uniqueResponses = array_values(array_intersect_key($contentTypeResponses, array_unique(array_map(fn (ControllerMethodResponse $response): array|\stdClass => $response->type->toArray(), array_filter($contentTypeResponses, fn (ControllerMethodResponse $response): bool => $response->type != null)), SORT_REGULAR))); |
717 | | - if (count($uniqueResponses) == 1) { |
| 717 | + if (count($uniqueResponses) === 1) { |
718 | 718 | if ($hasEmpty) { |
719 | 719 | $mergedContentTypeResponses[$contentType] = []; |
720 | 720 | } else { |
|
946 | 946 | ]; |
947 | 947 | } |
948 | 948 |
|
949 | | -if (count($schemas) == 0 && count($routes) == 0) { |
| 949 | +if (count($schemas) === 0 && count($routes) === 0) { |
950 | 950 | Logger::error('app', 'No spec generated'); |
951 | 951 | } |
952 | 952 |
|
|
972 | 972 |
|
973 | 973 | $usedSchemas = ['Capabilities', 'PublicCapabilities']; |
974 | 974 |
|
975 | | -foreach (glob(dirname($out) . '/openapi*.json') as $path) { |
| 975 | +foreach (glob(dirname((string)$out) . '/openapi*.json') as $path) { |
976 | 976 | unlink($path); |
977 | 977 | } |
978 | 978 |
|
|
1060 | 1060 | $openapiScope['paths'] = new stdClass(); |
1061 | 1061 | } |
1062 | 1062 |
|
1063 | | - $startExtension = strrpos($out, '.'); |
| 1063 | + $startExtension = strrpos((string)$out, '.'); |
1064 | 1064 | if ($startExtension !== false) { |
1065 | 1065 | // Path + filename (without extension) |
1066 | | - $path = substr($out, 0, $startExtension); |
| 1066 | + $path = substr((string)$out, 0, $startExtension); |
1067 | 1067 | // Extension |
1068 | | - $extension = substr($out, $startExtension); |
| 1068 | + $extension = substr((string)$out, $startExtension); |
1069 | 1069 | $scopeOut = $path . $scopeSuffix . $extension; |
1070 | 1070 | } else { |
1071 | 1071 | $scopeOut = $out . $scopeSuffix; |
|
0 commit comments