mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
type fixes
This commit is contained in:
@@ -48,9 +48,9 @@ use stdClass;
|
||||
*/
|
||||
class ActionProcessor
|
||||
{
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
private $classFinder;
|
||||
private ClassFinder $classFinder;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, ClassFinder $classFinder)
|
||||
{
|
||||
@@ -130,6 +130,9 @@ class ActionProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $result
|
||||
*/
|
||||
private function handleResult(Response $response, $result): void
|
||||
{
|
||||
$responseContents = $result;
|
||||
@@ -183,6 +186,10 @@ class ActionProcessor
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string
|
||||
* @throws NotFound
|
||||
*/
|
||||
private function getControllerClassName(string $name): string
|
||||
{
|
||||
$className = $this->classFinder->find('Controllers', $name);
|
||||
|
||||
@@ -171,6 +171,10 @@ class Auth
|
||||
return AuthResult::createNotResolved();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{string,string}
|
||||
* @throws BadRequest
|
||||
*/
|
||||
protected function decodeAuthorizationString(string $string): array
|
||||
{
|
||||
$stringDecoded = base64_decode($string);
|
||||
@@ -260,6 +264,9 @@ class Auth
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{?string,?string}
|
||||
*/
|
||||
protected function obtainUsernamePasswordFromRequest(Request $request): array
|
||||
{
|
||||
if ($request->hasHeader('Espo-Authorization')) {
|
||||
|
||||
@@ -40,13 +40,13 @@ use Espo\Core\{
|
||||
*/
|
||||
class AuthBuilder
|
||||
{
|
||||
private $authRequired = false;
|
||||
private bool $authRequired = false;
|
||||
|
||||
private $isEntryPoint = false;
|
||||
private bool $isEntryPoint = false;
|
||||
|
||||
private $authentication = null;
|
||||
private ?Authentication $authentication = null;
|
||||
|
||||
private $log;
|
||||
private Log $log;
|
||||
|
||||
public function __construct(Log $log)
|
||||
{
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace Espo\Core\Api;
|
||||
*/
|
||||
class AuthResult
|
||||
{
|
||||
private $isResolved = false;
|
||||
private bool $isResolved = false;
|
||||
|
||||
private $isResolvedUseNoAuth = false;
|
||||
private bool $isResolvedUseNoAuth = false;
|
||||
|
||||
public static function createResolved(): self
|
||||
{
|
||||
|
||||
@@ -45,6 +45,9 @@ use Throwable;
|
||||
*/
|
||||
class ErrorOutput
|
||||
{
|
||||
/**
|
||||
* @var array<int,string>
|
||||
*/
|
||||
private $errorDescriptions = [
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
@@ -55,6 +58,9 @@ class ErrorOutput
|
||||
503 => 'Service Unavailable',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private $allowedStatusCodeList = [
|
||||
200,
|
||||
201,
|
||||
@@ -67,13 +73,16 @@ class ErrorOutput
|
||||
503,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var class-string[]
|
||||
*/
|
||||
private $ignorePrintXStatusReasonExceptionClassNameList = [
|
||||
'PDOException',
|
||||
];
|
||||
|
||||
private $log;
|
||||
private Log $log;
|
||||
|
||||
private $config;
|
||||
private Config $config;
|
||||
|
||||
public function __construct(Log $log, Config $config)
|
||||
{
|
||||
|
||||
@@ -46,12 +46,14 @@ interface Request
|
||||
/**
|
||||
* Get a query parameter.
|
||||
*
|
||||
* @return string|array|null
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getQueryParam(string $name);
|
||||
|
||||
/**
|
||||
* Get all query parameters.
|
||||
*
|
||||
* @return array<string,string|string[]>
|
||||
*/
|
||||
public function getQueryParams(): array;
|
||||
|
||||
@@ -67,6 +69,8 @@ interface Request
|
||||
|
||||
/**
|
||||
* Get all route parameters.
|
||||
*
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public function getRouteParams(): array;
|
||||
|
||||
|
||||
@@ -48,13 +48,16 @@ class RequestNull implements ApiRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|array|null
|
||||
* @return null
|
||||
*/
|
||||
public function getQueryParam(string $name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getQueryParams(): array
|
||||
{
|
||||
return [];
|
||||
|
||||
@@ -43,14 +43,20 @@ use stdClass;
|
||||
*/
|
||||
class RequestWrapper implements ApiRequest
|
||||
{
|
||||
private $request;
|
||||
private Psr7Request $request;
|
||||
|
||||
private $basePath;
|
||||
private string $basePath;
|
||||
|
||||
private $parsedBody = null;
|
||||
private ?stdClass $parsedBody = null;
|
||||
|
||||
private $routeParams;
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
private array $routeParams;
|
||||
|
||||
/**
|
||||
* @param array<string,string> $routeParams
|
||||
*/
|
||||
public function __construct(Psr7Request $request, string $basePath = '', array $routeParams = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
@@ -92,6 +98,9 @@ class RequestWrapper implements ApiRequest
|
||||
return $this->routeParams[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public function getRouteParams(): array
|
||||
{
|
||||
return $this->routeParams;
|
||||
@@ -103,7 +112,7 @@ class RequestWrapper implements ApiRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|array|null
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getQueryParam(string $name)
|
||||
{
|
||||
@@ -116,6 +125,9 @@ class RequestWrapper implements ApiRequest
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string|string[]>
|
||||
*/
|
||||
public function getQueryParams(): array
|
||||
{
|
||||
return $this->request->getQueryParams();
|
||||
@@ -184,7 +196,7 @@ class RequestWrapper implements ApiRequest
|
||||
return Util::cloneObject($this->parsedBody);
|
||||
}
|
||||
|
||||
private function initParsedBody()
|
||||
private function initParsedBody(): void
|
||||
{
|
||||
$contents = $this->getBodyContents();
|
||||
|
||||
|
||||
@@ -31,14 +31,20 @@ namespace Espo\Core\Api;
|
||||
|
||||
class Route
|
||||
{
|
||||
private $method;
|
||||
private string $method;
|
||||
|
||||
private $route;
|
||||
private string $route;
|
||||
|
||||
private $params;
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
private array $params;
|
||||
|
||||
private $noAuth;
|
||||
private bool $noAuth;
|
||||
|
||||
/**
|
||||
* @param array<string,string> $params
|
||||
*/
|
||||
public function __construct(
|
||||
string $method,
|
||||
string $route,
|
||||
@@ -61,6 +67,9 @@ class Route
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public function getParams(): array
|
||||
{
|
||||
return $this->params;
|
||||
|
||||
@@ -33,6 +33,10 @@ use Espo\Core\Api\Route;
|
||||
|
||||
class RouteParamsFetcher
|
||||
{
|
||||
/**
|
||||
* @param array<string,mixed> $args
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function fetch(Route $item, array $args): array
|
||||
{
|
||||
$params = [];
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
|
||||
namespace Espo\Core\Api;
|
||||
|
||||
use StdClass;
|
||||
use stdClass;
|
||||
|
||||
class Util
|
||||
{
|
||||
public static function cloneObject(StdClass $source): StdClass
|
||||
public static function cloneObject(stdClass $source): stdClass
|
||||
{
|
||||
$cloned = (object) [];
|
||||
|
||||
@@ -44,6 +44,10 @@ class Util
|
||||
return $cloned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $item
|
||||
* @return mixed
|
||||
*/
|
||||
private static function cloneObjectItem($item)
|
||||
{
|
||||
if (is_array($item)) {
|
||||
@@ -56,7 +60,7 @@ class Util
|
||||
return $cloned;
|
||||
}
|
||||
|
||||
if ($item instanceof StdClass) {
|
||||
if ($item instanceof stdClass) {
|
||||
return self::cloneObject($item);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ class ClassFinder
|
||||
|
||||
/**
|
||||
* Find class name by a category and name.
|
||||
*
|
||||
* @return ?class-string
|
||||
*/
|
||||
public function find(string $category, string $name, bool $subDirs = false): ?string
|
||||
{
|
||||
@@ -62,7 +64,7 @@ class ClassFinder
|
||||
/**
|
||||
* Get a name => class name map.
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @return array<string,class-string>
|
||||
*/
|
||||
public function getMap(string $category, bool $subDirs = false): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user