diff --git a/application/Espo/Core/Api/Auth.php b/application/Espo/Core/Api/Auth.php
index e2d7fdc9de..0f1da51f2d 100644
--- a/application/Espo/Core/Api/Auth.php
+++ b/application/Espo/Core/Api/Auth.php
@@ -71,7 +71,7 @@ class Auth
$this->isEntryPoint = $isEntryPoint;
}
- public function process(Request $request, Response $response) : AuthResult
+ public function process(Request $request, Response $response): AuthResult
{
$username = null;
$password = null;
@@ -116,8 +116,12 @@ class Auth
}
protected function processAuthNotRequired(
- string $username, ?string $password, Request $request, Response $response, ?string $authenticationMethod
- ) : ?AuthResult {
+ string $username,
+ ?string $password,
+ Request $request,
+ Response $response,
+ ?string $authenticationMethod
+ ): ?AuthResult {
try {
$result = $this->authentication->login($username, $password, $request, $authenticationMethod);
@@ -136,8 +140,12 @@ class Auth
}
protected function processWithAuthData(
- ?string $username, ?string $password, Request $request, Response $response, ?string $authenticationMethod
- ) : AuthResult {
+ ?string $username,
+ ?string $password,
+ Request $request,
+ Response $response,
+ ?string $authenticationMethod
+ ): AuthResult {
$showDialog = $this->isEntryPoint;
@@ -165,7 +173,7 @@ class Auth
return AuthResult::createNotResolved();
}
- protected function decodeAuthorizationString(string $string) : array
+ protected function decodeAuthorizationString(string $string): array
{
$stringDecoded = base64_decode($string);
@@ -176,7 +184,7 @@ class Auth
return explode(':', $stringDecoded, 2);
}
- protected function handleSecondStepRequired(Response $response, Result $result)
+ protected function handleSecondStepRequired(Response $response, Result $result): void
{
$response->setStatus(401);
$response->setHeader('X-Status-Reason', 'second-step-required');
@@ -191,7 +199,7 @@ class Auth
$response->writeBody(json_encode($bodyData));
}
- protected function handleException(Response $response, Exception $e)
+ protected function handleException(Response $response, Exception $e): void
{
if (
$e instanceof BadRequest ||
@@ -216,7 +224,7 @@ class Auth
$this->log->error("Auth: " . $e->getMessage());
}
- protected function handleUnauthorized(Response $response, bool $showDialog)
+ protected function handleUnauthorized(Response $response, bool $showDialog): void
{
if ($showDialog) {
$response->setHeader('WWW-Authenticate', 'Basic realm=""');
@@ -225,7 +233,7 @@ class Auth
$response->setStatus(401);
}
- protected function isXMLHttpRequest(Request $request)
+ protected function isXMLHttpRequest(Request $request): bool
{
if (strtolower($request->getHeader('X-Requested-With') ?? '') == 'xmlhttprequest') {
return true;
@@ -234,7 +242,7 @@ class Auth
return false;
}
- protected function obtainAuthenticationMethodFromRequest(Request $request) : ?string
+ protected function obtainAuthenticationMethodFromRequest(Request $request): ?string
{
if ($request->hasHeader('Espo-Authorization')) {
return null;
@@ -254,7 +262,7 @@ class Auth
return null;
}
- protected function obtainUsernamePasswordFromRequest(Request $request) : array
+ protected function obtainUsernamePasswordFromRequest(Request $request): array
{
if ($request->hasHeader('Espo-Authorization')) {
list($username, $password) = $this->decodeAuthorizationString(
diff --git a/application/Espo/Core/Api/AuthBuilder.php b/application/Espo/Core/Api/AuthBuilder.php
index e8c18823f4..ab85979ad9 100644
--- a/application/Espo/Core/Api/AuthBuilder.php
+++ b/application/Espo/Core/Api/AuthBuilder.php
@@ -53,28 +53,28 @@ class AuthBuilder
$this->log = $log;
}
- public function setAuthentication(Authentication $authentication) : self
+ public function setAuthentication(Authentication $authentication): self
{
$this->authentication = $authentication;
return $this;
}
- public function setAuthRequired(bool $authRequired) : self
+ public function setAuthRequired(bool $authRequired): self
{
$this->authRequired = $authRequired;
return $this;
}
- public function forEntryPoint() : self
+ public function forEntryPoint(): self
{
$this->isEntryPoint = true;
return $this;
}
- public function build() : Auth
+ public function build(): Auth
{
if (!$this->authentication) {
throw new Error("Authentication is not set.");
diff --git a/application/Espo/Core/Api/AuthBuilderFactory.php b/application/Espo/Core/Api/AuthBuilderFactory.php
index 21d433e336..5f9c11c9f0 100644
--- a/application/Espo/Core/Api/AuthBuilderFactory.php
+++ b/application/Espo/Core/Api/AuthBuilderFactory.php
@@ -42,7 +42,7 @@ class AuthBuilderFactory
$this->log = $log;
}
- public function create() : AuthBuilder
+ public function create(): AuthBuilder
{
return new AuthBuilder($this->log);
}
diff --git a/application/Espo/Core/Api/AuthResult.php b/application/Espo/Core/Api/AuthResult.php
index a62e7e18c7..ee80445697 100644
--- a/application/Espo/Core/Api/AuthResult.php
+++ b/application/Espo/Core/Api/AuthResult.php
@@ -38,7 +38,7 @@ class AuthResult
private $isResolvedUseNoAuth = false;
- public static function createResolved() : self
+ public static function createResolved(): self
{
$obj = new self();
@@ -47,7 +47,7 @@ class AuthResult
return $obj;
}
- public static function createResolvedUseNoAuth() : self
+ public static function createResolvedUseNoAuth(): self
{
$obj = new self();
@@ -57,7 +57,7 @@ class AuthResult
return $obj;
}
- public static function createNotResolved() : self
+ public static function createNotResolved(): self
{
return new self();
}
@@ -65,7 +65,7 @@ class AuthResult
/**
* Logged in successfully.
*/
- public function isResolved() : bool
+ public function isResolved(): bool
{
return $this->isResolved;
}
@@ -73,7 +73,7 @@ class AuthResult
/**
* No need to log in.
*/
- public function isResolvedUseNoAuth() : bool
+ public function isResolvedUseNoAuth(): bool
{
return $this->isResolvedUseNoAuth;
}
diff --git a/application/Espo/Core/Api/ErrorOutput.php b/application/Espo/Core/Api/ErrorOutput.php
index 8f4b193730..9039222bdc 100644
--- a/application/Espo/Core/Api/ErrorOutput.php
+++ b/application/Espo/Core/Api/ErrorOutput.php
@@ -155,7 +155,7 @@ class ErrorOutput
}
}
- protected function doesExceptionHaveBody(Throwable $exception) : bool
+ protected function doesExceptionHaveBody(Throwable $exception): bool
{
if (
! $exception instanceof Error
@@ -174,7 +174,7 @@ class ErrorOutput
return $exceptionBody !== null;
}
- protected function getCodeDescription(int $statusCode) : ?string
+ protected function getCodeDescription(int $statusCode): ?string
{
if (isset($this->errorDescriptions[$statusCode])) {
return $this->errorDescriptions[$statusCode];
@@ -183,12 +183,12 @@ class ErrorOutput
return null;
}
- protected function clearPasswords(string $string) : string
+ protected function clearPasswords(string $string): string
{
return preg_replace('/"(.*?password.*?)":".*?"/i', '"$1":"*****"', $string);
}
- protected static function generateErrorBody(string $header, string $text) : string
+ protected static function generateErrorBody(string $header, string $text): string
{
$body = "
" . $header . "
";
$body .= $text;
@@ -196,7 +196,7 @@ class ErrorOutput
return $body;
}
- protected function stripInvalidCharactersFromHeaderValue(string $value) : string
+ protected function stripInvalidCharactersFromHeaderValue(string $value): string
{
$pattern = "/[^ \t\x21-\x7E\x80-\xFF]/";
diff --git a/application/Espo/Core/Api/Request.php b/application/Espo/Core/Api/Request.php
index c798dfb000..6c867cd4e6 100644
--- a/application/Espo/Core/Api/Request.php
+++ b/application/Espo/Core/Api/Request.php
@@ -41,7 +41,7 @@ interface Request
/**
* Whether a query parameter is set.
*/
- public function hasQueryParam(string $name) : bool;
+ public function hasQueryParam(string $name): bool;
/**
* Get a query parameter.
@@ -53,62 +53,62 @@ interface Request
/**
* Get all query parameters.
*/
- public function getQueryParams() : array;
+ public function getQueryParams(): array;
/**
* Whether a route parameter is set.
*/
- public function hasRouteParam(string $name) : bool;
+ public function hasRouteParam(string $name): bool;
/**
* Get a route parameter.
*/
- public function getRouteParam(string $name) : ?string;
+ public function getRouteParam(string $name): ?string;
/**
* Get all route parameters.
*/
- public function getRouteParams() : array;
+ public function getRouteParams(): array;
/**
* Get a header value.
*/
- public function getHeader(string $name) : ?string;
+ public function getHeader(string $name): ?string;
/**
* Whether a header is set.
*/
- public function hasHeader(string $name) : bool;
+ public function hasHeader(string $name): bool;
/**
* Get a request method.
*/
- public function getMethod() : string;
+ public function getMethod(): string;
/**
* Get Uri.
*/
- public function getUri() : UriInterface;
+ public function getUri(): UriInterface;
/**
* Get a relative path of a request (w/o base path).
*/
- public function getResourcePath() : string;
+ public function getResourcePath(): string;
/**
* Get body contents.
*/
- public function getBodyContents() : ?string;
+ public function getBodyContents(): ?string;
/**
* Get a parsed body. If JSON array is passed, then will be converted to `{"list": ARRAY}`.
*/
- public function getParsedBody() : StdClass;
+ public function getParsedBody(): StdClass;
/**
* Get a cookie param value.
*/
- public function getCookieParam(string $name) : ?string;
+ public function getCookieParam(string $name): ?string;
/**
* Get a server param value.
diff --git a/application/Espo/Core/Api/RequestNull.php b/application/Espo/Core/Api/RequestNull.php
index 3a024387bb..ac68dc7f58 100644
--- a/application/Espo/Core/Api/RequestNull.php
+++ b/application/Espo/Core/Api/RequestNull.php
@@ -42,7 +42,7 @@ use StdClass;
*/
class RequestNull implements ApiRequest
{
- public function hasQueryParam(string $name) : bool
+ public function hasQueryParam(string $name): bool
{
return false;
}
@@ -55,62 +55,62 @@ class RequestNull implements ApiRequest
return null;
}
- public function getQueryParams() : array
+ public function getQueryParams(): array
{
return [];
}
- public function hasRouteParam(string $name) : bool
+ public function hasRouteParam(string $name): bool
{
return false;
}
- public function getRouteParam(string $name) : ?string
+ public function getRouteParam(string $name): ?string
{
return null;
}
- public function getRouteParams() : array
+ public function getRouteParams(): array
{
return [];
}
- public function getHeader(string $name) : ?string
+ public function getHeader(string $name): ?string
{
return null;
}
- public function hasHeader(string $name) : bool
+ public function hasHeader(string $name): bool
{
return false;
}
- public function getMethod() : string
+ public function getMethod(): string
{
return '';
}
- public function getUri() : UriInterface
+ public function getUri(): UriInterface
{
return (new UriFactory())->createUri();
}
- public function getResourcePath() : string
+ public function getResourcePath(): string
{
return '';
}
- public function getBodyContents() : ?string
+ public function getBodyContents(): ?string
{
return null;
}
- public function getParsedBody() : StdClass
+ public function getParsedBody(): StdClass
{
return (object) [];
}
- public function getCookieParam(string $name) : ?string
+ public function getCookieParam(string $name): ?string
{
return null;
}
diff --git a/application/Espo/Core/Api/RequestWrapper.php b/application/Espo/Core/Api/RequestWrapper.php
index 5483a7cc6c..7788314099 100644
--- a/application/Espo/Core/Api/RequestWrapper.php
+++ b/application/Espo/Core/Api/RequestWrapper.php
@@ -82,22 +82,22 @@ class RequestWrapper implements ApiRequest
return $this->getQueryParam($name);
}
- public function hasRouteParam(string $name) : bool
+ public function hasRouteParam(string $name): bool
{
return array_key_exists($name, $this->routeParams);
}
- public function getRouteParam(string $name) : ?string
+ public function getRouteParam(string $name): ?string
{
return $this->routeParams[$name] ?? null;
}
- public function getRouteParams() : array
+ public function getRouteParams(): array
{
return $this->routeParams;
}
- public function hasQueryParam(string $name) : bool
+ public function hasQueryParam(string $name): bool
{
return array_key_exists($name, $this->request->getQueryParams());
}
@@ -116,12 +116,12 @@ class RequestWrapper implements ApiRequest
return $value;
}
- public function getQueryParams() : array
+ public function getQueryParams(): array
{
return $this->request->getQueryParams();
}
- public function getHeader(string $name) : ?string
+ public function getHeader(string $name): ?string
{
if (!$this->request->hasHeader($name)) {
return null;
@@ -130,17 +130,17 @@ class RequestWrapper implements ApiRequest
return $this->request->getHeaderLine($name);
}
- public function hasHeader(string $name) : bool
+ public function hasHeader(string $name): bool
{
return $this->request->hasHeader($name);
}
- public function getMethod() : string
+ public function getMethod(): string
{
return $this->request->getMethod();
}
- public function getContentType() : ?string
+ public function getContentType(): ?string
{
if (!$this->hasHeader('Content-Type')) {
return null;
@@ -151,7 +151,7 @@ class RequestWrapper implements ApiRequest
return strtolower($contentType);
}
- public function getBodyContents() : ?string
+ public function getBodyContents(): ?string
{
$contents = $this->request->getBody()->getContents();
@@ -160,7 +160,7 @@ class RequestWrapper implements ApiRequest
return $contents;
}
- public function getParsedBody() : StdClass
+ public function getParsedBody(): StdClass
{
if ($this->parsedBody === null) {
$this->initParsedBody();
@@ -188,7 +188,7 @@ class RequestWrapper implements ApiRequest
$this->parsedBody = (object) [];
}
- public function getCookieParam(string $name) : ?string
+ public function getCookieParam(string $name): ?string
{
$params = $this->request->getCookieParams();
@@ -205,44 +205,44 @@ class RequestWrapper implements ApiRequest
return $params[$name] ?? null;
}
- public function getUri() : UriInterface
+ public function getUri(): UriInterface
{
return $this->request->getUri();
}
- public function getResourcePath() : string
+ public function getResourcePath(): string
{
$path = $this->request->getUri()->getPath();
return substr($path, strlen($this->basePath));
}
- public function isGet() : bool
+ public function isGet(): bool
{
return $this->getMethod() === 'GET';
}
- public function isPut() : bool
+ public function isPut(): bool
{
return $this->getMethod() === 'PUT';
}
- public function isUpdate() : bool
+ public function isUpdate(): bool
{
return $this->getMethod() === 'UPDATE';
}
- public function isPost() : bool
+ public function isPost(): bool
{
return $this->getMethod() === 'POST';
}
- public function isPatch() : bool
+ public function isPatch(): bool
{
return $this->getMethod() === 'PATCH';
}
- public function isDelete() : bool
+ public function isDelete(): bool
{
return $this->getMethod() === 'DELETE';
}
diff --git a/application/Espo/Core/Api/Response.php b/application/Espo/Core/Api/Response.php
index 6979c50e9e..d81df875f8 100644
--- a/application/Espo/Core/Api/Response.php
+++ b/application/Espo/Core/Api/Response.php
@@ -42,35 +42,35 @@ interface Response
/**
* Set a status code.
*/
- public function setStatus(int $code, ?string $reason = null) : self;
+ public function setStatus(int $code, ?string $reason = null): self;
/**
* Set a specific header.
*/
- public function setHeader(string $name, string $value) : self;
+ public function setHeader(string $name, string $value): self;
/**
* Get a header value.
*/
- public function getHeader(string $name) : ?string;
+ public function getHeader(string $name): ?string;
/**
* Whether a header is set.
*/
- public function hasHeader(string $name) : bool;
+ public function hasHeader(string $name): bool;
/**
* Write a body.
*/
- public function writeBody(string $string) : self;
+ public function writeBody(string $string): self;
/**
* Set a body.
*/
- public function setBody(StreamInterface $body) : self;
+ public function setBody(StreamInterface $body): self;
/**
* Get a result PSR-7 response.
*/
- public function getResponse() : Psr7Response;
+ public function getResponse(): Psr7Response;
}
\ No newline at end of file
diff --git a/application/Espo/Core/Api/ResponseWrapper.php b/application/Espo/Core/Api/ResponseWrapper.php
index eb0d807c70..3c6c730a7e 100644
--- a/application/Espo/Core/Api/ResponseWrapper.php
+++ b/application/Espo/Core/Api/ResponseWrapper.php
@@ -54,21 +54,21 @@ class ResponseWrapper implements ApiResponse
$this->response = $this->response->withoutHeader('Authorization');
}
- public function setStatus(int $code, ?string $reason = null) : Response
+ public function setStatus(int $code, ?string $reason = null): Response
{
$this->response = $this->response->withStatus($code, $reason ?? '');
return $this;
}
- public function setHeader(string $name, string $value) : Response
+ public function setHeader(string $name, string $value): Response
{
$this->response = $this->response->withHeader($name, $value);
return $this;
}
- public function getHeader(string $name) : ?string
+ public function getHeader(string $name): ?string
{
if (!$this->response->hasHeader($name)) {
return null;
@@ -77,24 +77,24 @@ class ResponseWrapper implements ApiResponse
return $this->response->getHeaderLine($name);
}
- public function hasHeader(string $name) : bool
+ public function hasHeader(string $name): bool
{
return $this->response->hasHeader($name);
}
- public function getResponse() : Psr7Response
+ public function getResponse(): Psr7Response
{
return $this->response;
}
- public function writeBody(string $string) : Response
+ public function writeBody(string $string): Response
{
$this->response->getBody()->write($string);
return $this;
}
- public function setBody(StreamInterface $body) : Response
+ public function setBody(StreamInterface $body): Response
{
$this->response = $this->response->withBody($body);
diff --git a/application/Espo/Core/Api/RouteProcessor.php b/application/Espo/Core/Api/RouteProcessor.php
index 3da5a3a54b..8d3bc1cd2d 100644
--- a/application/Espo/Core/Api/RouteProcessor.php
+++ b/application/Espo/Core/Api/RouteProcessor.php
@@ -43,8 +43,9 @@ use StdClass;
*/
class RouteProcessor
{
- protected $config;
- protected $controllerManager;
+ private $config;
+
+ private $controllerManager;
public function __construct(Config $config, ControllerManager $controllerManager)
{
@@ -52,7 +53,7 @@ class RouteProcessor
$this->controllerManager = $controllerManager;
}
- public function process(string $route, Request $request, Response $response)
+ public function process(string $route, Request $request, Response $response): void
{
$response->setHeader('Content-Type', 'application/json');
diff --git a/application/Espo/Core/Api/Util.php b/application/Espo/Core/Api/Util.php
index 5884b6b64a..f5c8c3defd 100644
--- a/application/Espo/Core/Api/Util.php
+++ b/application/Espo/Core/Api/Util.php
@@ -33,7 +33,7 @@ use StdClass;
class Util
{
- public static function cloneObject(StdClass $source) : StdClass
+ public static function cloneObject(StdClass $source): StdClass
{
$cloned = (object) [];
diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php
index bd58429393..fee2b16e83 100644
--- a/application/Espo/Core/Application.php
+++ b/application/Espo/Core/Application.php
@@ -61,7 +61,7 @@ class Application
$this->initPreloads();
}
- protected function initContainer() : void
+ protected function initContainer(): void
{
$this->container = (new ContainerBuilder())->build();
}
@@ -72,7 +72,7 @@ class Application
* @param $className A runner class name.
* @param $params Runner parameters. Will be passed to a runner's constructor.
*/
- public function run(string $className, ?RunnerParams $params = null) : void
+ public function run(string $className, ?RunnerParams $params = null): void
{
if (!$className || !class_exists($className)) {
$this->getLog()->error("Application runner '{$className}' does not exist.");
@@ -106,7 +106,7 @@ class Application
/**
* Whether an application is installed.
*/
- public function isInstalled() : bool
+ public function isInstalled(): bool
{
$config = $this->getConfig();
@@ -120,42 +120,42 @@ class Application
/**
* Get a service container.
*/
- public function getContainer() : Container
+ public function getContainer(): Container
{
return $this->container;
}
- protected function getInjectableFactory() : InjectableFactory
+ protected function getInjectableFactory(): InjectableFactory
{
return $this->container->get('injectableFactory');
}
- protected function getApplicationUser() : ApplicationUser
+ protected function getApplicationUser(): ApplicationUser
{
return $this->container->get('applicationUser');
}
- protected function getLog() : Log
+ protected function getLog(): Log
{
return $this->container->get('log');
}
- protected function getClientManager() : ClientManager
+ protected function getClientManager(): ClientManager
{
return $this->container->get('clientManager');
}
- protected function getMetadata() : Metadata
+ protected function getMetadata(): Metadata
{
return $this->container->get('metadata');
}
- protected function getConfig() : Config
+ protected function getConfig(): Config
{
return $this->container->get('config');
}
- protected function initAutoloads() : void
+ protected function initAutoloads(): void
{
$autoload = $this->getInjectableFactory()->create(Autoload::class);
@@ -165,7 +165,7 @@ class Application
/**
* Initialize services that has the 'preload' parameter.
*/
- protected function initPreloads() : void
+ protected function initPreloads(): void
{
foreach ($this->getMetadata()->get(['app', 'containerServices']) ?? [] as $name => $defs) {
if ($defs['preload'] ?? false) {
@@ -177,7 +177,7 @@ class Application
/**
* Set a base path of an index file related to the application directory. Used for a portal.
*/
- public function setClientBasePath(string $basePath) : void
+ public function setClientBasePath(string $basePath): void
{
$this->getClientManager()->setBasePath($basePath);
}
@@ -185,7 +185,7 @@ class Application
/**
* Setup the system user. The system user is used when no user is logged in.
*/
- public function setupSystemUser() : void
+ public function setupSystemUser(): void
{
$this->getApplicationUser()->setupSystemUser();
}
diff --git a/application/Espo/Core/Application/Runner.php b/application/Espo/Core/Application/Runner.php
index f3a1a4f1fc..052dc4cb46 100644
--- a/application/Espo/Core/Application/Runner.php
+++ b/application/Espo/Core/Application/Runner.php
@@ -34,5 +34,5 @@ namespace Espo\Core\Application;
*/
interface Runner
{
- public function run() : void;
+ public function run(): void;
}
diff --git a/application/Espo/Core/Application/RunnerParams.php b/application/Espo/Core/Application/RunnerParams.php
index 00fe1c339f..1fec126c7a 100644
--- a/application/Espo/Core/Application/RunnerParams.php
+++ b/application/Espo/Core/Application/RunnerParams.php
@@ -53,7 +53,7 @@ class RunnerParams
/**
* Whether a parameter is set.
*/
- public function has(string $name) : bool
+ public function has(string $name): bool
{
return array_key_exists($name, $this->data);
}
@@ -63,7 +63,7 @@ class RunnerParams
*
* @param mixed $value
*/
- public function with(string $name, $value) : self
+ public function with(string $name, $value): self
{
$obj = clone $this;
@@ -75,7 +75,7 @@ class RunnerParams
/**
* Create from an array.
*/
- public static function fromArray(array $data) : self
+ public static function fromArray(array $data): self
{
$obj = new self();
@@ -87,7 +87,7 @@ class RunnerParams
/**
* Create an empty instance.
*/
- public static function fromNothing() : self
+ public static function fromNothing(): self
{
return new self();
}
diff --git a/application/Espo/Core/ApplicationRunners/Api.php b/application/Espo/Core/ApplicationRunners/Api.php
index 722683220c..dd76af5937 100644
--- a/application/Espo/Core/ApplicationRunners/Api.php
+++ b/application/Espo/Core/ApplicationRunners/Api.php
@@ -88,7 +88,7 @@ class Api implements Runner
$this->log = $log;
}
- public function run() : void
+ public function run(): void
{
$slim = SlimAppFactory::create();
@@ -107,7 +107,7 @@ class Api implements Runner
$slim->run();
}
- private function addRoute(SlimApp $slim, array $item) : void
+ private function addRoute(SlimApp $slim, array $item): void
{
$method = strtolower($item['method']);
$route = $item['route'];
@@ -129,7 +129,7 @@ class Api implements Runner
);
}
- private function getRouteParams(array $item, array $args) : array
+ private function getRouteParams(array $item, array $args): array
{
$params = [];
@@ -169,8 +169,10 @@ class Api implements Runner
}
private function processRequest(
- array $item, RequestWrapper $requestWrapped, ResponseWrapper $responseWrapped
- ) : void {
+ array $item,
+ RequestWrapper $requestWrapped,
+ ResponseWrapper $responseWrapped
+ ): void {
try {
$authRequired = !($item['noAuth'] ?? false);
@@ -205,7 +207,10 @@ class Api implements Runner
}
private function handleException(
- Throwable $exception, RequestWrapper $requestWrapped, ResponseWrapper $responseWrapped, string $route
+ Throwable $exception,
+ RequestWrapper $requestWrapped,
+ ResponseWrapper $responseWrapped,
+ string $route
) : void {
$errorOutput = new ApiErrorOutput($requestWrapped, $route);
diff --git a/application/Espo/Core/ApplicationRunners/ClearCache.php b/application/Espo/Core/ApplicationRunners/ClearCache.php
index 0d60aa7d7f..5604c47b1e 100644
--- a/application/Espo/Core/ApplicationRunners/ClearCache.php
+++ b/application/Espo/Core/ApplicationRunners/ClearCache.php
@@ -48,7 +48,7 @@ class ClearCache implements Runner
$this->dataManager = $dataManager;
}
- public function run() : void
+ public function run(): void
{
$this->dataManager->clearCache();
}
diff --git a/application/Espo/Core/ApplicationRunners/Client.php b/application/Espo/Core/ApplicationRunners/Client.php
index 5eb2d4bc8e..7af3e8cbd3 100644
--- a/application/Espo/Core/ApplicationRunners/Client.php
+++ b/application/Espo/Core/ApplicationRunners/Client.php
@@ -46,7 +46,7 @@ class Client implements Runner
$this->clientManager = $clientManager;
}
- public function run() : void
+ public function run(): void
{
$this->clientManager->display();
}
diff --git a/application/Espo/Core/ApplicationRunners/Command.php b/application/Espo/Core/ApplicationRunners/Command.php
index 09721e9ed1..c65dd825ba 100644
--- a/application/Espo/Core/ApplicationRunners/Command.php
+++ b/application/Espo/Core/ApplicationRunners/Command.php
@@ -51,7 +51,7 @@ class Command implements Runner
$this->commandManager = $commandManager;
}
- public function run() : void
+ public function run(): void
{
try {
$this->commandManager->run($_SERVER['argv']);
diff --git a/application/Espo/Core/ApplicationRunners/Cron.php b/application/Espo/Core/ApplicationRunners/Cron.php
index d1a62058bf..201a140dd9 100644
--- a/application/Espo/Core/ApplicationRunners/Cron.php
+++ b/application/Espo/Core/ApplicationRunners/Cron.php
@@ -53,7 +53,7 @@ class Cron implements Runner
$this->config = $config;
}
- public function run() : void
+ public function run(): void
{
if ($this->config->get('cronDisabled')) {
$GLOBALS['log']->warning("Cron is not run because it's disabled with 'cronDisabled' param.");
diff --git a/application/Espo/Core/ApplicationRunners/Daemon.php b/application/Espo/Core/ApplicationRunners/Daemon.php
index d31a417e53..22947878d3 100644
--- a/application/Espo/Core/ApplicationRunners/Daemon.php
+++ b/application/Espo/Core/ApplicationRunners/Daemon.php
@@ -53,7 +53,7 @@ class Daemon implements Runner
$this->config = $config;
}
- public function run() : void
+ public function run(): void
{
$maxProcessNumber = $this->config->get('daemonMaxProcessNumber');
$interval = $this->config->get('daemonInterval');
diff --git a/application/Espo/Core/ApplicationRunners/EntryPoint.php b/application/Espo/Core/ApplicationRunners/EntryPoint.php
index 6d2f00c161..aaad3e35d7 100644
--- a/application/Espo/Core/ApplicationRunners/EntryPoint.php
+++ b/application/Espo/Core/ApplicationRunners/EntryPoint.php
@@ -97,7 +97,7 @@ class EntryPoint implements Runner
$this->params = $params ?? RunnerParams::fromNothing();
}
- public function run() : void
+ public function run(): void
{
$requestWrapped = new RequestWrapper(
ServerRequestCreatorFactory::create()->createServerRequestFromGlobals(),
@@ -142,7 +142,7 @@ class EntryPoint implements Runner
ResponseWrapper $responseWrapped,
bool $authRequired,
bool $authNotStrict
- ) : void {
+ ): void {
try {
$authentication = $authNotStrict ?
@@ -181,7 +181,7 @@ class EntryPoint implements Runner
}
}
- private function detectPortalId(RequestWrapper $requestWrapped) : ?string
+ private function detectPortalId(RequestWrapper $requestWrapped): ?string
{
if ($requestWrapped->hasQueryParam('portalId')) {
return $requestWrapped->getQueryParam('portalId');
@@ -202,7 +202,7 @@ class EntryPoint implements Runner
return null;
}
- private function runThroughPortal(string $portalId, string $entryPoint) : void
+ private function runThroughPortal(string $portalId, string $entryPoint): void
{
$app = new PortalApplication($portalId);
diff --git a/application/Espo/Core/ApplicationRunners/Job.php b/application/Espo/Core/ApplicationRunners/Job.php
index e6d7d973a7..fca471da64 100644
--- a/application/Espo/Core/ApplicationRunners/Job.php
+++ b/application/Espo/Core/ApplicationRunners/Job.php
@@ -54,7 +54,7 @@ class Job implements Runner
$this->params = $params;
}
- public function run() : void
+ public function run(): void
{
$id = $this->params->get('id');
diff --git a/application/Espo/Core/ApplicationRunners/PortalClient.php b/application/Espo/Core/ApplicationRunners/PortalClient.php
index fa4f7505a0..c49ae48113 100644
--- a/application/Espo/Core/ApplicationRunners/PortalClient.php
+++ b/application/Espo/Core/ApplicationRunners/PortalClient.php
@@ -70,7 +70,7 @@ class PortalClient implements Runner
$this->params = $params ?? RunnerParams::fromNothing();
}
- public function run() : void
+ public function run(): void
{
$id = $this->params->get('id') ??
Url::detectPortalId() ??
@@ -108,7 +108,7 @@ class PortalClient implements Runner
$application->run(PortalPortalClient::class);
}
- private function processError(RequestWrapper $request, ResponseWrapper $response, Exception $exception) : void
+ private function processError(RequestWrapper $request, ResponseWrapper $response, Exception $exception): void
{
(new ApiErrorOutput($request))->process($response, $exception, true);
diff --git a/application/Espo/Core/ApplicationRunners/Preload.php b/application/Espo/Core/ApplicationRunners/Preload.php
index a070c36f48..ccb1af111c 100644
--- a/application/Espo/Core/ApplicationRunners/Preload.php
+++ b/application/Espo/Core/ApplicationRunners/Preload.php
@@ -45,7 +45,7 @@ class Preload implements Runner
{
use Cli;
- public function run() : void
+ public function run(): void
{
$preload = new PreloadUtil();
diff --git a/application/Espo/Core/ApplicationRunners/Rebuild.php b/application/Espo/Core/ApplicationRunners/Rebuild.php
index 95e9627273..61c6664073 100644
--- a/application/Espo/Core/ApplicationRunners/Rebuild.php
+++ b/application/Espo/Core/ApplicationRunners/Rebuild.php
@@ -48,7 +48,7 @@ class Rebuild implements Runner
$this->dataManager = $dataManager;
}
- public function run() : void
+ public function run(): void
{
$this->dataManager->rebuild();
}
diff --git a/application/Espo/Core/ApplicationRunners/WebSocket.php b/application/Espo/Core/ApplicationRunners/WebSocket.php
index 8536175a8d..983665c517 100644
--- a/application/Espo/Core/ApplicationRunners/WebSocket.php
+++ b/application/Espo/Core/ApplicationRunners/WebSocket.php
@@ -48,7 +48,7 @@ class WebSocket implements Runner
$this->serverStarter = $serverStarter;
}
- public function run() : void
+ public function run(): void
{
$this->serverStarter->start();
}
diff --git a/application/Espo/Core/ApplicationState.php b/application/Espo/Core/ApplicationState.php
index fec500393b..cadbae0b41 100644
--- a/application/Espo/Core/ApplicationState.php
+++ b/application/Espo/Core/ApplicationState.php
@@ -49,7 +49,7 @@ class ApplicationState
/**
* Whether an application is initialized as a portal.
*/
- public function isPortal() : bool
+ public function isPortal(): bool
{
return $this->container->has('portal');
}
@@ -57,7 +57,7 @@ class ApplicationState
/**
* Get a portal ID (if an application is portal).
*/
- public function getPortalId() : string
+ public function getPortalId(): string
{
if (!$this->isPortal()) {
throw new Error("Can't get portal ID for non-portal application.");
@@ -69,7 +69,7 @@ class ApplicationState
/**
* Get a portal entity (if an application is portal).
*/
- public function getPortal() : PortalEntity
+ public function getPortal(): PortalEntity
{
if (!$this->isPortal()) {
throw new Error("Can't get portal for non-portal application.");
@@ -81,7 +81,7 @@ class ApplicationState
/**
* Whether any user is initialized. If not logged, it will also return TRUE, meaning the system used is used.
*/
- public function hasUser() : bool
+ public function hasUser(): bool
{
return $this->container->has('user');
}
@@ -89,7 +89,7 @@ class ApplicationState
/**
* Get a current logged user. If no auth is applied, then the system user will be returned.
*/
- public function getUser() : UserEntity
+ public function getUser(): UserEntity
{
if (!$this->hasUser()) {
throw new Error("User is not yet available.");
@@ -101,7 +101,7 @@ class ApplicationState
/**
* Get an ID of a current logged user. If no auth is applied, then the system user will be returned.
*/
- public function getUserId() : string
+ public function getUserId(): string
{
return $this->getUser()->id;
}
@@ -109,7 +109,7 @@ class ApplicationState
/**
* Whether a user is logged.
*/
- public function isLogged() : bool
+ public function isLogged(): bool
{
if (!$this->container->has('user')) {
return false;
@@ -125,7 +125,7 @@ class ApplicationState
/**
* Whether logged as an admin.
*/
- public function isAdmin() : bool
+ public function isAdmin(): bool
{
if (!$this->isLogged()) {
return false;
@@ -138,7 +138,7 @@ class ApplicationState
/**
* Whether logged as an API user.
*/
- public function isApi() : bool
+ public function isApi(): bool
{
if (!$this->isLogged()) {
return false;
diff --git a/application/Espo/Core/ApplicationUser.php b/application/Espo/Core/ApplicationUser.php
index fbca11aa28..b25e156106 100644
--- a/application/Espo/Core/ApplicationUser.php
+++ b/application/Espo/Core/ApplicationUser.php
@@ -59,7 +59,7 @@ class ApplicationUser
/**
* Setup the system user as a current user. The system user is used when no user is logged in.
*/
- public function setupSystemUser() : void
+ public function setupSystemUser(): void
{
$user = $this->entityManagerProxy->getEntity('User', 'system');
@@ -76,7 +76,7 @@ class ApplicationUser
/**
* Set a current user.
*/
- public function setUser(User $user) : void
+ public function setUser(User $user): void
{
$this->container->set('user', $user);
}
diff --git a/application/Espo/Core/Authentication/AuthToken/AuthTokenData.php b/application/Espo/Core/Authentication/AuthToken/AuthTokenData.php
index 1d6099f2df..ef86202e4c 100644
--- a/application/Espo/Core/Authentication/AuthToken/AuthTokenData.php
+++ b/application/Espo/Core/Authentication/AuthToken/AuthTokenData.php
@@ -50,32 +50,32 @@ class AuthTokenData
{
}
- public function getUserId() : string
+ public function getUserId(): string
{
return $this->userId;
}
- public function getPortalId() : ?string
+ public function getPortalId(): ?string
{
return $this->portalId;
}
- public function getHash() : ?string
+ public function getHash(): ?string
{
return $this->hash;
}
- public function getIpAddress() : ?string
+ public function getIpAddress(): ?string
{
return $this->ipAddress;
}
- public function toCreateSecret() : bool
+ public function toCreateSecret(): bool
{
return $this->createSecret;
}
- public static function create(array $data) : self
+ public static function create(array $data): self
{
$object = new self();
diff --git a/application/Espo/Core/Authentication/Authentication.php b/application/Espo/Core/Authentication/Authentication.php
index 11cb235713..20e2a29d8c 100644
--- a/application/Espo/Core/Authentication/Authentication.php
+++ b/application/Espo/Core/Authentication/Authentication.php
@@ -112,12 +112,12 @@ class Authentication
$this->portal = $portal;
}
- protected function isPortal() : bool
+ protected function isPortal(): bool
{
return (bool) $this->portal || $this->applicationState->isPortal();
}
- protected function getPortal() : Portal
+ protected function getPortal(): Portal
{
if ($this->portal) {
return $this->portal;
@@ -133,8 +133,11 @@ class Authentication
* @throws ServiceUnavailable
*/
public function login(
- ?string $username, ?string $password, Request $request, ?string $authenticationMethod = null
- ) : Result {
+ ?string $username,
+ ?string $password,
+ Request $request,
+ ?string $authenticationMethod = null
+ ): Result {
if (
$authenticationMethod &&
@@ -294,7 +297,7 @@ class Authentication
return $result;
}
- private function processAuthTokenCheck(AuthToken $authToken) : bool
+ private function processAuthTokenCheck(AuthToken $authToken): bool
{
if ($this->allowAnyAccess && $authToken->getPortalId() && !$this->isPortal()) {
$portal = $this->entityManager->getEntity('Portal', $authToken->getPortalId());
@@ -327,7 +330,7 @@ class Authentication
return true;
}
- private function processUserCheck(User $user, ?AuthLogRecord $authLogRecord) : bool
+ private function processUserCheck(User $user, ?AuthLogRecord $authLogRecord): bool
{
if (!$user->isActive()) {
$this->log->info(
@@ -379,7 +382,7 @@ class Authentication
return true;
}
- private function processTwoFactor(Result $result, Request $request) : Result
+ private function processTwoFactor(Result $result, Request $request): Result
{
$loggedUser = $result->getLoggedUser();
@@ -404,7 +407,7 @@ class Authentication
return Result::secondStepRequired($result->getUser(), $impl->getLoginData($loggedUser));
}
- private function getUser2FAMethod(User $user) : ?string
+ private function getUser2FAMethod(User $user): ?string
{
$userData = $this->entityManager->getRepository('UserData')->getByUserId($user->id);
@@ -429,7 +432,7 @@ class Authentication
return $method;
}
- private function checkFailedAttemptsLimit(Request $request) : void
+ private function checkFailedAttemptsLimit(Request $request): void
{
$failedAttemptsPeriod = $this->configDataProvider->getFailedAttemptsPeriod();
$maxFailedAttempts = $this->configDataProvider->getMaxFailedAttemptNumber();
@@ -470,7 +473,7 @@ class Authentication
}
}
- private function createAuthToken(User $user, Request $request) : AuthToken
+ private function createAuthToken(User $user, Request $request): AuthToken
{
$createSecret = $request->getHeader('Espo-Authorization-Create-Token-Secret') === 'true';
@@ -496,7 +499,10 @@ class Authentication
$this->setSecretInCookie($authToken->getSecret());
}
- if ($this->configDataProvider->preventConcurrentAuthToken() && $authToken instanceof AuthTokenEntity) {
+ if (
+ $this->configDataProvider->preventConcurrentAuthToken() &&
+ $authToken instanceof AuthTokenEntity
+ ) {
$concurrentAuthTokenList = $this->entityManager
->getRepository('AuthToken')
->select(['id'])
@@ -517,7 +523,7 @@ class Authentication
return $authToken;
}
- public function destroyAuthToken(string $token, Request $request) : bool
+ public function destroyAuthToken(string $token, Request $request): bool
{
$authToken = $this->authTokenManager->get($token);
@@ -539,8 +545,11 @@ class Authentication
}
protected function createAuthLogRecord(
- ?string $username, ?User $user, Request $request, ?string $authenticationMethod = null
- ) : ?AuthLogRecord {
+ ?string $username,
+ ?User $user,
+ Request $request,
+ ?string $authenticationMethod = null
+ ): ?AuthLogRecord {
if ($username === '**logout') {
return null;
@@ -583,7 +592,7 @@ class Authentication
return $authLogRecord;
}
- private function logDenied(?AuthLogRecord $authLogRecord, string $denialReason) : void
+ private function logDenied(?AuthLogRecord $authLogRecord, string $denialReason): void
{
if (!$authLogRecord) {
return;
@@ -594,9 +603,9 @@ class Authentication
$this->entityManager->saveEntity($authLogRecord);
}
- private function setSecretInCookie(?string $secret) : void
+ private function setSecretInCookie(?string $secret): void
{
- $time = $secret ? strtotime('+1000 days') : -1;
+ $time = $secret ? strtotime('+1000 days'): -1;
setcookie('auth-token-secret', $secret, [
'expires' => $time,
diff --git a/application/Espo/Core/Authentication/AuthenticationFactory.php b/application/Espo/Core/Authentication/AuthenticationFactory.php
index 1fede5d90c..28f1e43981 100644
--- a/application/Espo/Core/Authentication/AuthenticationFactory.php
+++ b/application/Espo/Core/Authentication/AuthenticationFactory.php
@@ -40,12 +40,12 @@ class AuthenticationFactory
$this->injectableFactory = $injectableFactory;
}
- public function create() : Authentication
+ public function create(): Authentication
{
return $this->injectableFactory->create(Authentication::class);
}
- public function createWithAnyAccessAllowed() : Authentication
+ public function createWithAnyAccessAllowed(): Authentication
{
return $this->injectableFactory->createWith(Authentication::class, [
'allowAnyAccess' => true,
diff --git a/application/Espo/Core/Authentication/ConfigDataProvider.php b/application/Espo/Core/Authentication/ConfigDataProvider.php
index dcbf70bbda..882e78115c 100644
--- a/application/Espo/Core/Authentication/ConfigDataProvider.php
+++ b/application/Espo/Core/Authentication/ConfigDataProvider.php
@@ -53,7 +53,7 @@ class ConfigDataProvider
/**
* A period for max failed attempts checking.
*/
- public function getFailedAttemptsPeriod() : string
+ public function getFailedAttemptsPeriod(): string
{
return $this->config->get('authFailedAttemptsPeriod', self::FAILED_ATTEMPTS_PERIOD);
}
@@ -61,7 +61,7 @@ class ConfigDataProvider
/**
* Max failed log in attempts.
*/
- public function getMaxFailedAttemptNumber() : int
+ public function getMaxFailedAttemptNumber(): int
{
return $this->config->get('authMaxFailedAttemptNumber', self::MAX_FAILED_ATTEMPT_NUMBER);
}
@@ -69,7 +69,7 @@ class ConfigDataProvider
/**
* Auth token secret won't be created. Can be reasonable for a custom AuthTokenManager implementation.
*/
- public function isAuthTokenSecretDisabled() : bool
+ public function isAuthTokenSecretDisabled(): bool
{
return (bool) $this->config->get('authTokenSecretDisabled');
}
@@ -77,7 +77,7 @@ class ConfigDataProvider
/**
* A maintenance mode. Only admin can log in.
*/
- public function isMaintenanceMode() : bool
+ public function isMaintenanceMode(): bool
{
return (bool) $this->config->get('maintenanceMode');
}
@@ -85,7 +85,7 @@ class ConfigDataProvider
/**
* Whether 2FA is enabled.
*/
- public function isTwoFactorEnabled() : bool
+ public function isTwoFactorEnabled(): bool
{
return (bool) $this->config->get('auth2FA');
}
@@ -95,7 +95,7 @@ class ConfigDataProvider
*
* @return array
*/
- public function getTwoFactorMethodList() : array
+ public function getTwoFactorMethodList(): array
{
return $this->config->get('auth2FAMethodList') ?? [];
}
@@ -103,7 +103,7 @@ class ConfigDataProvider
/**
* A user won't be able to have multiple active auth tokens simultaneously.
*/
- public function preventConcurrentAuthToken() : bool
+ public function preventConcurrentAuthToken(): bool
{
return (bool) $this->config->get('authTokenPreventConcurrent');
}
@@ -111,7 +111,7 @@ class ConfigDataProvider
/**
* A default authentication method.
*/
- public function getDefaultAuthenticationMethod() : string
+ public function getDefaultAuthenticationMethod(): string
{
return $this->config->get('authenticationMethod', 'Espo');
}
@@ -119,7 +119,7 @@ class ConfigDataProvider
/**
* Whether an authentication method can be defined by request itself (in a header).
*/
- public function authenticationMethodIsApi(string $authenticationMethod) : bool
+ public function authenticationMethodIsApi(string $authenticationMethod): bool
{
return (bool) $this->metadata->get(['authenticationMethods', $authenticationMethod, 'api']);
}
diff --git a/application/Espo/Core/Authentication/Helpers/UserFinder.php b/application/Espo/Core/Authentication/Helpers/UserFinder.php
index 5790e58c39..3f4fdd56d1 100644
--- a/application/Espo/Core/Authentication/Helpers/UserFinder.php
+++ b/application/Espo/Core/Authentication/Helpers/UserFinder.php
@@ -44,7 +44,7 @@ class UserFinder
$this->entityManager = $entityManager;
}
- public function find(string $username, string $hash) : ?User
+ public function find(string $username, string $hash): ?User
{
$user = $this->entityManager
->getRepository('User')
@@ -58,7 +58,7 @@ class UserFinder
return $user;
}
- public function findApiHmac(string $apiKey) : ?User
+ public function findApiHmac(string $apiKey): ?User
{
$user = $this->entityManager
->getRepository('User')
@@ -72,7 +72,7 @@ class UserFinder
return $user;
}
- public function findApiApiKey(string $apiKey) : ?User
+ public function findApiApiKey(string $apiKey): ?User
{
$user = $this->entityManager
->getRepository('User')
diff --git a/application/Espo/Core/Authentication/Login.php b/application/Espo/Core/Authentication/Login.php
index 02178d5fd4..f1b783d99f 100644
--- a/application/Espo/Core/Authentication/Login.php
+++ b/application/Espo/Core/Authentication/Login.php
@@ -44,5 +44,5 @@ interface Login
/**
* Check credentials.
*/
- public function login(LoginData $loginData, Request $request) : Result;
+ public function login(LoginData $loginData, Request $request): Result;
}
diff --git a/application/Espo/Core/Authentication/Login/ApiKey.php b/application/Espo/Core/Authentication/Login/ApiKey.php
index 3d44f26356..8c0cf98295 100644
--- a/application/Espo/Core/Authentication/Login/ApiKey.php
+++ b/application/Espo/Core/Authentication/Login/ApiKey.php
@@ -46,7 +46,7 @@ class ApiKey implements Login
$this->userFinder = $userFinder;
}
- public function login(LoginData $loginData, Request $request) : Result
+ public function login(LoginData $loginData, Request $request): Result
{
$apiKey = $request->getHeader('X-Api-Key');
diff --git a/application/Espo/Core/Authentication/Login/Espo.php b/application/Espo/Core/Authentication/Login/Espo.php
index 79e7e8de79..58803f2c44 100644
--- a/application/Espo/Core/Authentication/Login/Espo.php
+++ b/application/Espo/Core/Authentication/Login/Espo.php
@@ -50,7 +50,7 @@ class Espo implements Login
$this->passwordHash = $passwordHash;
}
- public function login(LoginData $loginData, Request $request) : Result
+ public function login(LoginData $loginData, Request $request): Result
{
$username = $loginData->getUsername();
$password = $loginData->getPassword();
diff --git a/application/Espo/Core/Authentication/Login/Hmac.php b/application/Espo/Core/Authentication/Login/Hmac.php
index 9b3990d91f..7134799859 100644
--- a/application/Espo/Core/Authentication/Login/Hmac.php
+++ b/application/Espo/Core/Authentication/Login/Hmac.php
@@ -51,7 +51,7 @@ class Hmac implements Login
$this->apiKeyUtil = $apiKeyUtil;
}
- public function login(LoginData $loginData, Request $request) : Result
+ public function login(LoginData $loginData, Request $request): Result
{
$authString = base64_decode($request->getHeader('X-Hmac-Authorization'));
diff --git a/application/Espo/Core/Authentication/Login/LDAP.php b/application/Espo/Core/Authentication/Login/LDAP.php
index 0d24a7b16e..da8242b7b1 100644
--- a/application/Espo/Core/Authentication/Login/LDAP.php
+++ b/application/Espo/Core/Authentication/Login/LDAP.php
@@ -108,7 +108,7 @@ class LDAP implements Login
'portalRolesIds' => 'portalUserRolesIds',
];
- public function login(LoginData $loginData, Request $request) : Result
+ public function login(LoginData $loginData, Request $request): Result
{
$username = $loginData->getUsername();
$password = $loginData->getPassword();
@@ -396,7 +396,7 @@ class LDAP implements Login
/**
* Load fields for a user.
*/
- private function loadFields(string $type) : array
+ private function loadFields(string $type): array
{
$options = $this->utils->getOptions();
diff --git a/application/Espo/Core/Authentication/LoginData.php b/application/Espo/Core/Authentication/LoginData.php
index e7a0a0c377..a5a1391869 100644
--- a/application/Espo/Core/Authentication/LoginData.php
+++ b/application/Espo/Core/Authentication/LoginData.php
@@ -51,37 +51,37 @@ class LoginData
$this->authToken = $authToken;
}
- public function getUsername() : ?string
+ public function getUsername(): ?string
{
return $this->username;
}
- public function getPassword() : ?string
+ public function getPassword(): ?string
{
return $this->password;
}
- public function getAuthToken() : ?AuthToken
+ public function getAuthToken(): ?AuthToken
{
return $this->authToken;
}
- public function hasUsername() : bool
+ public function hasUsername(): bool
{
return !is_null($this->username);
}
- public function hasPassword() : bool
+ public function hasPassword(): bool
{
return !is_null($this->password);
}
- public function hasAuthToken() : bool
+ public function hasAuthToken(): bool
{
return !is_null($this->authToken);
}
- public static function createBuilder() : LoginDataBuilder
+ public static function createBuilder(): LoginDataBuilder
{
return new LoginDataBuilder();
}
diff --git a/application/Espo/Core/Authentication/LoginDataBuilder.php b/application/Espo/Core/Authentication/LoginDataBuilder.php
index 1b8b6cea0e..c4115f89be 100644
--- a/application/Espo/Core/Authentication/LoginDataBuilder.php
+++ b/application/Espo/Core/Authentication/LoginDataBuilder.php
@@ -41,28 +41,28 @@ class LoginDataBuilder
private $authToken = null;
- public function setUsername(?string $username) : self
+ public function setUsername(?string $username): self
{
$this->username = $username;
return $this;
}
- public function setPassword(?string $password) : self
+ public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
- public function setAuthToken(?AuthToken $authToken) : self
+ public function setAuthToken(?AuthToken $authToken): self
{
$this->authToken = $authToken;
return $this;
}
- public function build() : LoginData
+ public function build(): LoginData
{
return new LoginData($this->username, $this->password, $this->authToken);
}
diff --git a/application/Espo/Core/Authentication/LoginFactory.php b/application/Espo/Core/Authentication/LoginFactory.php
index 190b203b75..b70c600e9d 100644
--- a/application/Espo/Core/Authentication/LoginFactory.php
+++ b/application/Espo/Core/Authentication/LoginFactory.php
@@ -46,7 +46,7 @@ class LoginFactory
$this->metadata = $metadata;
}
- public function create(string $method, bool $isPortal = false) : Login
+ public function create(string $method, bool $isPortal = false): Login
{
$className = $this->metadata->get(['authenticationMethods', $method, 'implementationClassName']);
diff --git a/application/Espo/Core/Authentication/Result.php b/application/Espo/Core/Authentication/Result.php
index cd2a3577c0..170034d5a4 100644
--- a/application/Espo/Core/Authentication/Result.php
+++ b/application/Espo/Core/Authentication/Result.php
@@ -73,7 +73,7 @@ class Result
/**
* Create an instance for a successful login.
*/
- public static function success(User $user) : self
+ public static function success(User $user): self
{
return new self(self::STATUS_SUCCESS, $user);
}
@@ -81,7 +81,7 @@ class Result
/**
* Create an instance for a failed login.
*/
- public static function fail(?string $reason = null) : self
+ public static function fail(?string $reason = null): self
{
$data = $reason ?
ResultData::fromFailReason($reason) :
@@ -93,7 +93,7 @@ class Result
/**
* Create an instance for a login requiring a second step. E.g. for 2FA.
*/
- public static function secondStepRequired(User $user, ResultData $data) : self
+ public static function secondStepRequired(User $user, ResultData $data): self
{
return new self(self::STATUS_SECOND_STEP_REQUIRED, $user, $data);
}
@@ -101,7 +101,7 @@ class Result
/**
* Login is successful.
*/
- public function isSuccess() : bool
+ public function isSuccess(): bool
{
return $this->status === self::STATUS_SUCCESS;
}
@@ -109,7 +109,7 @@ class Result
/**
* Second step is required. E.g. for 2FA.
*/
- public function isSecondStepRequired() : bool
+ public function isSecondStepRequired(): bool
{
return $this->status === self::STATUS_SECOND_STEP_REQUIRED;
}
@@ -117,7 +117,7 @@ class Result
/**
* Login is failed.
*/
- public function isFail() : bool
+ public function isFail(): bool
{
return $this->status === self::STATUS_FAIL;
}
@@ -125,7 +125,7 @@ class Result
/**
* Get a user.
*/
- public function getUser() : ?User
+ public function getUser(): ?User
{
return $this->user;
}
@@ -134,7 +134,7 @@ class Result
* Get a logged user. Considered that an admin user can log in as another user.
* The logged user will be an admin user.
*/
- public function getLoggedUser() : ?User
+ public function getLoggedUser(): ?User
{
return $this->loggedUser ?? $this->user;
}
@@ -142,7 +142,7 @@ class Result
/**
* A status.
*/
- public function getStatus() : string
+ public function getStatus(): string
{
return $this->status;
}
@@ -150,7 +150,7 @@ class Result
/**
* A client view to redirect to for a second step.
*/
- public function getView() : ?string
+ public function getView(): ?string
{
return $this->view;
}
@@ -158,7 +158,7 @@ class Result
/**
* A message to show to end user for a second step.
*/
- public function getMessage() : ?string
+ public function getMessage(): ?string
{
return $this->message;
}
@@ -166,7 +166,7 @@ class Result
/**
* A token can be returned to a client to be used instead of password in a request for a second step.
*/
- public function getToken() : ?string
+ public function getToken(): ?string
{
return $this->token;
}
@@ -174,7 +174,7 @@ class Result
/**
* A fail reason.
*/
- public function getFailReason() : ?string
+ public function getFailReason(): ?string
{
return $this->failReason;
}
diff --git a/application/Espo/Core/Authentication/ResultData.php b/application/Espo/Core/Authentication/ResultData.php
index 66d0fecaf0..a0c8e4df1e 100644
--- a/application/Espo/Core/Authentication/ResultData.php
+++ b/application/Espo/Core/Authentication/ResultData.php
@@ -57,22 +57,22 @@ class ResultData
$this->loggedUser = $loggedUser;
}
- public static function fromNothing() : self
+ public static function fromNothing(): self
{
return new self();
}
- public static function fromFailReason(string $failReason) : self
+ public static function fromFailReason(string $failReason): self
{
return new self(null, $failReason);
}
- public static function fromMessage(string $message) : self
+ public static function fromMessage(string $message): self
{
return new self($message);
}
- public static function fromArray(array $data) : self
+ public static function fromArray(array $data): self
{
return new self(
$data['message'] ?? null,
@@ -83,32 +83,32 @@ class ResultData
);
}
- public function getLoggedUser() : ?User
+ public function getLoggedUser(): ?User
{
return $this->loggedUser;
}
- public function getStatus() : string
+ public function getStatus(): string
{
return $this->status;
}
- public function getView() : ?string
+ public function getView(): ?string
{
return $this->view;
}
- public function getMessage() : ?string
+ public function getMessage(): ?string
{
return $this->message;
}
- public function getToken() : ?string
+ public function getToken(): ?string
{
return $this->token;
}
- public function getFailReason() : ?string
+ public function getFailReason(): ?string
{
return $this->failReason;
}
diff --git a/application/Espo/Core/Authentication/TwoFactor/Factory.php b/application/Espo/Core/Authentication/TwoFactor/Factory.php
index 46f4d39e6c..28b6bef428 100644
--- a/application/Espo/Core/Authentication/TwoFactor/Factory.php
+++ b/application/Espo/Core/Authentication/TwoFactor/Factory.php
@@ -35,6 +35,7 @@ use Espo\Core\Utils\Metadata;
class Factory
{
protected $injectableFactory;
+
protected $config;
public function __construct(InjectableFactory $injectableFactory, Metadata $metadata)
@@ -43,7 +44,7 @@ class Factory
$this->metadata = $metadata;
}
- public function create(string $method) : object
+ public function create(string $method): object
{
$className = $this->metadata->get([
'app', 'auth2FAMethods', $method, 'implementationClassName'
diff --git a/application/Espo/Core/Authentication/TwoFactor/Methods/CodeVerify.php b/application/Espo/Core/Authentication/TwoFactor/Methods/CodeVerify.php
index 18ffc23ae1..027fe3d07f 100644
--- a/application/Espo/Core/Authentication/TwoFactor/Methods/CodeVerify.php
+++ b/application/Espo/Core/Authentication/TwoFactor/Methods/CodeVerify.php
@@ -40,10 +40,10 @@ interface CodeVerify
/**
* Verify a code for a user.
*/
- public function verifyCode(User $user, string $code) : bool;
+ public function verifyCode(User $user, string $code): bool;
/**
* Data to be sent to the front-end for showing a form for a second step.
*/
- public function getLoginData(User $user) : ResultData;
+ public function getLoginData(User $user): ResultData;
}
diff --git a/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php b/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php
index 18bcce1891..4c6fedeaef 100644
--- a/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php
+++ b/application/Espo/Core/Authentication/TwoFactor/Methods/Totp.php
@@ -42,7 +42,7 @@ use Espo\Core\Authentication\{
class Totp implements CodeVerify
{
protected $entityManager;
-
+
protected $totp;
public function __construct(EntityManager $entityManager, TotpUtils $totp)
@@ -51,7 +51,7 @@ class Totp implements CodeVerify
$this->totp = $totp;
}
- public function verifyCode(User $user, string $code) : bool
+ public function verifyCode(User $user, string $code): bool
{
$userData = $this->entityManager
->getRepository('UserData')
@@ -78,7 +78,7 @@ class Totp implements CodeVerify
return $this->totp->verifyCode($secret, $code);
}
- public function getLoginData(User $user) : ResultData
+ public function getLoginData(User $user): ResultData
{
return ResultData::fromMessage('enterTotpCode');
}
diff --git a/application/Espo/Core/Authentication/TwoFactor/User/CodeVerify.php b/application/Espo/Core/Authentication/TwoFactor/User/CodeVerify.php
index 36b53e5ee5..071cc0c91f 100644
--- a/application/Espo/Core/Authentication/TwoFactor/User/CodeVerify.php
+++ b/application/Espo/Core/Authentication/TwoFactor/User/CodeVerify.php
@@ -38,10 +38,10 @@ interface CodeVerify
/**
* Generate data for a user.
*/
- public function generateData(UserData $userData, StdClass $data, string $userName) : StdClass;
+ public function generateData(UserData $userData, StdClass $data, string $userName): StdClass;
/**
* Confirm code before storing.
*/
- public function verify(UserData $userData, string $code) : bool;
+ public function verify(UserData $userData, string $code): bool;
}
diff --git a/application/Espo/Core/Authentication/TwoFactor/User/Totp.php b/application/Espo/Core/Authentication/TwoFactor/User/Totp.php
index 8053225fce..456fd1ea7d 100644
--- a/application/Espo/Core/Authentication/TwoFactor/User/Totp.php
+++ b/application/Espo/Core/Authentication/TwoFactor/User/Totp.php
@@ -41,6 +41,7 @@ use StdClass;
class Totp implements CodeVerify
{
protected $entityManager;
+
protected $totp;
public function __construct(TotpUtils $totp, Config $config)
@@ -49,7 +50,7 @@ class Totp implements CodeVerify
$this->config = $config;
}
- public function generateData(UserData $userData, StdClass $data, string $userName) : StdClass
+ public function generateData(UserData $userData, StdClass $data, string $userName): StdClass
{
$secret = $this->totp->createSecret();
@@ -61,7 +62,7 @@ class Totp implements CodeVerify
];
}
- public function verify(UserData $userData, string $code) : bool
+ public function verify(UserData $userData, string $code): bool
{
if (!$code) {
return false;
diff --git a/application/Espo/Core/Authentication/TwoFactor/UserFactory.php b/application/Espo/Core/Authentication/TwoFactor/UserFactory.php
index d6be2643e5..52306c560d 100644
--- a/application/Espo/Core/Authentication/TwoFactor/UserFactory.php
+++ b/application/Espo/Core/Authentication/TwoFactor/UserFactory.php
@@ -35,6 +35,7 @@ use Espo\Core\Utils\Metadata;
class UserFactory
{
protected $injectableFactory;
+
protected $config;
public function __construct(InjectableFactory $injectableFactory, Metadata $metadata)
@@ -43,7 +44,7 @@ class UserFactory
$this->metadata = $metadata;
}
- public function create(string $method) : object
+ public function create(string $method): object
{
$className = $this->metadata->get([
'app', 'auth2FAMethods', $method, 'implementationUserClassName'
diff --git a/application/Espo/Core/Authentication/TwoFactor/Utils/Totp.php b/application/Espo/Core/Authentication/TwoFactor/Utils/Totp.php
index 14fe8b3529..d3e6c889f5 100644
--- a/application/Espo/Core/Authentication/TwoFactor/Utils/Totp.php
+++ b/application/Espo/Core/Authentication/TwoFactor/Utils/Totp.php
@@ -36,12 +36,14 @@ class Totp
public function verifyCode(string $secret, string $code)
{
$impl = new TwoFactorAuth();
+
return $impl->verifyCode($secret, $code);
}
public function createSecret()
{
$impl = new TwoFactorAuth();
+
return $impl->createSecret();
}
}
diff --git a/application/Espo/Core/Console/Command.php b/application/Espo/Core/Console/Command.php
index 58319ce963..ddc0084fa2 100644
--- a/application/Espo/Core/Console/Command.php
+++ b/application/Espo/Core/Console/Command.php
@@ -34,5 +34,5 @@ namespace Espo\Core\Console;
*/
interface Command
{
- public function run(Params $params, IO $io) : void;
+ public function run(Params $params, IO $io): void;
}
diff --git a/application/Espo/Core/Console/CommandManager.php b/application/Espo/Core/Console/CommandManager.php
index 1e98e0c650..4999eb9607 100644
--- a/application/Espo/Core/Console/CommandManager.php
+++ b/application/Espo/Core/Console/CommandManager.php
@@ -52,7 +52,7 @@ class CommandManager
$this->metadata = $metadata;
}
- public function run(array $argv) : void
+ public function run(array $argv): void
{
$command = $this->getCommandNameFromArgv($argv);
@@ -73,9 +73,9 @@ class CommandManager
$commandObj->run($params, $io);
}
- private function getCommandNameFromArgv(array $argv) : string
+ private function getCommandNameFromArgv(array $argv): string
{
- $command = isset($argv[1]) ? trim($argv[1]) : null;
+ $command = isset($argv[1]) ? trim($argv[1]): null;
if (!$command) {
throw new CommandNotSpecified("Command name is not specifed.");
@@ -84,14 +84,14 @@ class CommandManager
return ucfirst(Util::hyphenToCamelCase($command));
}
- private function createCommand(string $command) : object
+ private function createCommand(string $command): object
{
$className = $this->getClassName($command);
return $this->injectableFactory->create($className);
}
- private function getClassName(string $command) : string
+ private function getClassName(string $command): string
{
$className =
$this->metadata->get(['app', 'consoleCommands', lcfirst($command), 'className']);
@@ -109,7 +109,7 @@ class CommandManager
return $className;
}
- private function createParams(array $argv) : Params
+ private function createParams(array $argv): Params
{
$argumentList = [];
$options = [];
diff --git a/application/Espo/Core/Console/Commands/AclCheck.php b/application/Espo/Core/Console/Commands/AclCheck.php
index 41f46e2ab2..04d853f165 100644
--- a/application/Espo/Core/Console/Commands/AclCheck.php
+++ b/application/Espo/Core/Console/Commands/AclCheck.php
@@ -46,7 +46,7 @@ class AclCheck implements Command
$this->container = $container;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$options = $params->getOptions();
@@ -112,7 +112,7 @@ class AclCheck implements Command
}
}
- protected function check($user, $scope, $id, $action, $container) : bool
+ protected function check($user, $scope, $id, $action, $container): bool
{
$entityManager = $container->get('entityManager');
diff --git a/application/Espo/Core/Console/Commands/AppInfo.php b/application/Espo/Core/Console/Commands/AppInfo.php
index bf06682ef9..cd6ac00d9d 100644
--- a/application/Espo/Core/Console/Commands/AppInfo.php
+++ b/application/Espo/Core/Console/Commands/AppInfo.php
@@ -49,7 +49,7 @@ class AppInfo implements Command
$this->fileManager = $fileManager;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$fileList = $this->fileManager->getFileList('application/Espo/Classes/AppInfo');
@@ -82,7 +82,7 @@ class AppInfo implements Command
$io->writeLine("Not supported flag specified.");
}
- protected function processType(IO $io, string $type, Params $params) : void
+ protected function processType(IO $io, string $type, Params $params): void
{
$className = 'Espo\\Classes\\AppInfo\\' . ucfirst($type);
diff --git a/application/Espo/Core/Console/Commands/AuthTokenCheck.php b/application/Espo/Core/Console/Commands/AuthTokenCheck.php
index a70f3670d8..361f1007ec 100644
--- a/application/Espo/Core/Console/Commands/AuthTokenCheck.php
+++ b/application/Espo/Core/Console/Commands/AuthTokenCheck.php
@@ -49,7 +49,7 @@ class AuthTokenCheck implements Command
$this->authTokenManager = $authTokenManager;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$token = $params->getArgument(0);
diff --git a/application/Espo/Core/Console/Commands/ClearCache.php b/application/Espo/Core/Console/Commands/ClearCache.php
index 2ee0728fc0..575170a9a7 100644
--- a/application/Espo/Core/Console/Commands/ClearCache.php
+++ b/application/Espo/Core/Console/Commands/ClearCache.php
@@ -45,7 +45,7 @@ class ClearCache implements Command
$this->dataManager = $dataManager;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$this->dataManager->clearCache();
diff --git a/application/Espo/Core/Console/Commands/Extension.php b/application/Espo/Core/Console/Commands/Extension.php
index c2e8c88650..c46c421c4a 100644
--- a/application/Espo/Core/Console/Commands/Extension.php
+++ b/application/Espo/Core/Console/Commands/Extension.php
@@ -48,7 +48,7 @@ class Extension implements Command
$this->container = $container;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$options = $params->getOptions();
diff --git a/application/Espo/Core/Console/Commands/Rebuild.php b/application/Espo/Core/Console/Commands/Rebuild.php
index cbf0e73d1a..7ffd7217eb 100644
--- a/application/Espo/Core/Console/Commands/Rebuild.php
+++ b/application/Espo/Core/Console/Commands/Rebuild.php
@@ -45,7 +45,7 @@ class Rebuild implements Command
$this->dataManager = $dataManager;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$this->dataManager->rebuild();
diff --git a/application/Espo/Core/Console/Commands/RunJob.php b/application/Espo/Core/Console/Commands/RunJob.php
index 1a91eab4eb..84fc19100b 100644
--- a/application/Espo/Core/Console/Commands/RunJob.php
+++ b/application/Espo/Core/Console/Commands/RunJob.php
@@ -52,7 +52,7 @@ class RunJob implements Command
$this->entityManager = $entityManager;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$options = $params->getOptions();
$argumentList = $params->getArgumentList();
diff --git a/application/Espo/Core/Console/Commands/SetPassword.php b/application/Espo/Core/Console/Commands/SetPassword.php
index a7b1dbe837..65a41d6b08 100644
--- a/application/Espo/Core/Console/Commands/SetPassword.php
+++ b/application/Espo/Core/Console/Commands/SetPassword.php
@@ -49,7 +49,7 @@ class SetPassword implements Command
$this->passwordHash = $passwordHash;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$userName = $params->getArgument(0);
diff --git a/application/Espo/Core/Console/Commands/Upgrade.php b/application/Espo/Core/Console/Commands/Upgrade.php
index c58ae5d279..e65c46a713 100644
--- a/application/Espo/Core/Console/Commands/Upgrade.php
+++ b/application/Espo/Core/Console/Commands/Upgrade.php
@@ -73,7 +73,7 @@ class Upgrade implements Command
$this->config = $config;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$options = $params->getOptions();
$flagList = $params->getFlagList();
@@ -178,7 +178,7 @@ class Upgrade implements Command
* --file="EspoCRM-upgrade.zip"
* --step="beforeUpgradeScript"
*/
- protected function normalizeParams(array $options, array $flagList, array $argumentList) : object
+ protected function normalizeParams(array $options, array $flagList, array $argumentList): object
{
$params = (object) [
'localMode' => false,
diff --git a/application/Espo/Core/Console/Commands/UpgradeStep.php b/application/Espo/Core/Console/Commands/UpgradeStep.php
index 98c68cbaac..7dd87930c3 100644
--- a/application/Espo/Core/Console/Commands/UpgradeStep.php
+++ b/application/Espo/Core/Console/Commands/UpgradeStep.php
@@ -54,7 +54,7 @@ class UpgradeStep implements Command
return $this->container;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$options = $params->getOptions();
@@ -84,7 +84,7 @@ class UpgradeStep implements Command
echo "true";
}
- protected function runUpgradeStep($stepName, array $params) : bool
+ protected function runUpgradeStep($stepName, array $params): bool
{
$app = new Application();
diff --git a/application/Espo/Core/Console/Commands/Version.php b/application/Espo/Core/Console/Commands/Version.php
index c6dc0463a9..4e212ff28f 100644
--- a/application/Espo/Core/Console/Commands/Version.php
+++ b/application/Espo/Core/Console/Commands/Version.php
@@ -45,7 +45,7 @@ class Version implements Command
$this->config = $config;
}
- public function run(Params $params, IO $io) : void
+ public function run(Params $params, IO $io): void
{
$version = $this->config->get('version');
diff --git a/application/Espo/Core/Console/IO.php b/application/Espo/Core/Console/IO.php
index fe4d6df1b0..a000b76be0 100644
--- a/application/Espo/Core/Console/IO.php
+++ b/application/Espo/Core/Console/IO.php
@@ -40,7 +40,7 @@ class IO
/**
* Write a string to output.
*/
- public function write(string $string) : void
+ public function write(string $string): void
{
fwrite(STDOUT, $string);
}
@@ -48,7 +48,7 @@ class IO
/**
* Write a string followed by the current line terminator to output.
*/
- public function writeLine(string $string) : void
+ public function writeLine(string $string): void
{
fwrite(STDOUT, $string . PHP_EOL);
}
@@ -56,7 +56,7 @@ class IO
/**
* Read a line from input. A string is trimmed.
*/
- public function readLine() : string
+ public function readLine(): string
{
$resource = fopen('php://stdin', 'r');
diff --git a/application/Espo/Core/Console/Params.php b/application/Espo/Core/Console/Params.php
index 1054c7f8d2..c8a15e6c20 100644
--- a/application/Espo/Core/Console/Params.php
+++ b/application/Espo/Core/Console/Params.php
@@ -59,7 +59,7 @@ class Params
/**
* @return array
*/
- public function getOptions() : array
+ public function getOptions(): array
{
return $this->options;
}
@@ -67,7 +67,7 @@ class Params
/**
* @return array
*/
- public function getFlagList() : array
+ public function getFlagList(): array
{
return $this->flagList;
}
@@ -75,7 +75,7 @@ class Params
/**
* @return array
*/
- public function getArgumentList() : array
+ public function getArgumentList(): array
{
return $this->argumentList;
}
@@ -83,7 +83,7 @@ class Params
/**
* Has an option.
*/
- public function hasOption(string $name) : bool
+ public function hasOption(string $name): bool
{
return array_key_exists($name, $this->options);
}
@@ -91,7 +91,7 @@ class Params
/**
* Get an option.
*/
- public function getOption(string $name) : ?string
+ public function getOption(string $name): ?string
{
return $this->options[$name] ?? null;
}
@@ -99,7 +99,7 @@ class Params
/**
* Has a flag.
*/
- public function hasFlag(string $name) : bool
+ public function hasFlag(string $name): bool
{
return in_array($name, $this->flagList);
}
@@ -107,7 +107,7 @@ class Params
/**
* Get an argument by index.
*/
- public function getArgument(int $index) : ?string
+ public function getArgument(int $index): ?string
{
return $this->argumentList[$index] ?? null;
}
diff --git a/application/Espo/Core/Container.php b/application/Espo/Core/Container.php
index d1808f0252..d8b530c662 100644
--- a/application/Espo/Core/Container.php
+++ b/application/Espo/Core/Container.php
@@ -84,7 +84,7 @@ class Container implements ContainerInterface
*
* @throws RuntimeException If not gettable.
*/
- public function get(string $name) : object
+ public function get(string $name): object
{
if (!$this->isSet($name)) {
$this->load($name);
@@ -100,7 +100,7 @@ class Container implements ContainerInterface
/**
* Check whether a service can be obtained.
*/
- public function has(string $name) : bool
+ public function has(string $name): bool
{
if ($this->isSet($name)) {
return true;
@@ -131,12 +131,12 @@ class Container implements ContainerInterface
return false;
}
- protected function isSet(string $name) : bool
+ protected function isSet(string $name): bool
{
return isset($this->data[$name]);
}
- private function initClass(string $name) : void
+ private function initClass(string $name): void
{
if ($this->isSet($name)) {
$object = $this->get($name);
@@ -188,7 +188,7 @@ class Container implements ContainerInterface
*
* @throws RuntimeException If not gettable.
*/
- public function getClass(string $name) : ReflectionClass
+ public function getClass(string $name): ReflectionClass
{
if (!$this->has($name)) {
throw new RuntimeException("Service '{$name}' does not exist.");
@@ -206,7 +206,7 @@ class Container implements ContainerInterface
*
* @throws RuntimeException Is not settable or already set.
*/
- public function set(string $name, object $object) : void
+ public function set(string $name, object $object): void
{
if (!$this->configuration->isSettable($name)) {
throw new RuntimeException("Service '{$name}' is not settable.");
@@ -219,12 +219,12 @@ class Container implements ContainerInterface
$this->setForced($name, $object);
}
- protected function setForced(string $name, object $object) : void
+ protected function setForced(string $name, object $object): void
{
$this->data[$name] = $object;
}
- private function getLoader(string $name) : ?Loader
+ private function getLoader(string $name): ?Loader
{
$loaderClassName = $this->getLoaderClassName($name);
@@ -235,12 +235,12 @@ class Container implements ContainerInterface
return $this->injectableFactory->create($loaderClassName);
}
- private function getLoaderClassName(string $name) : ?string
+ private function getLoaderClassName(string $name): ?string
{
return $this->loaderClassNames[$name] ?? $this->configuration->getLoaderClassName($name);
}
- private function load(string $name) : void
+ private function load(string $name): void
{
$loadMethodName = 'load' . ucfirst($name);
@@ -283,12 +283,12 @@ class Container implements ContainerInterface
$this->data[$name] = $this->injectableFactory->create($className);
}
- protected function loadContainer() : Container
+ protected function loadContainer(): Container
{
return $this;
}
- protected function loadInjectableFactory() : InjectableFactory
+ protected function loadInjectableFactory(): InjectableFactory
{
return new InjectableFactory($this, $this->bindingContainer);
}
diff --git a/application/Espo/Core/Container/Container.php b/application/Espo/Core/Container/Container.php
index 054aca13b4..25fbbbe533 100644
--- a/application/Espo/Core/Container/Container.php
+++ b/application/Espo/Core/Container/Container.php
@@ -44,24 +44,24 @@ interface Container
*
* @throws RuntimeException If not gettable.
*/
- public function get(string $name) : object;
+ public function get(string $name): object;
/**
* Check whether a service can be obtained.
*/
- public function has(string $name) : bool;
+ public function has(string $name): bool;
/**
* Set a service object. Must be configured as settable.
*
* @throws RuntimeException Is not settable or already set.
*/
- public function set(string $name, object $object) : void;
+ public function set(string $name, object $object): void;
/**
* Get a class of a service.
*
* @throws RuntimeException If not gettable.
*/
- public function getClass(string $name) : ReflectionClass;
+ public function getClass(string $name): ReflectionClass;
}
diff --git a/application/Espo/Core/Container/ContainerBuilder.php b/application/Espo/Core/Container/ContainerBuilder.php
index c0e9e506f9..aa4a62336d 100644
--- a/application/Espo/Core/Container/ContainerBuilder.php
+++ b/application/Espo/Core/Container/ContainerBuilder.php
@@ -70,14 +70,14 @@ class ContainerBuilder
'metadata' => MetadataLoader::class,
];
- public function withBindingLoader(BindingLoader $bindingLoader) : self
+ public function withBindingLoader(BindingLoader $bindingLoader): self
{
$this->bindingLoader = $bindingLoader;
return $this;
}
- public function withServices(array $services) : self
+ public function withServices(array $services): self
{
foreach ($services as $key => $value) {
$this->services[$key] = $value;
@@ -86,7 +86,7 @@ class ContainerBuilder
return $this;
}
- public function withLoaderClassNames(array $classNames) : self
+ public function withLoaderClassNames(array $classNames): self
{
foreach ($classNames as $key => $value) {
$this->loaderClassNames[$key] = $value;
@@ -95,42 +95,42 @@ class ContainerBuilder
return $this;
}
- public function withContainerClassName(string $containerClassName) : self
+ public function withContainerClassName(string $containerClassName): self
{
$this->containerClassName = $containerClassName;
return $this;
}
- public function withContainerConfigurationClassName(string $containerConfigurationClassName) : self
+ public function withContainerConfigurationClassName(string $containerConfigurationClassName): self
{
$this->containerConfigurationClassName = $containerConfigurationClassName;
return $this;
}
- public function withConfigClassName(string $configClassName) : self
+ public function withConfigClassName(string $configClassName): self
{
$this->configClassName = $configClassName;
return $this;
}
- public function withFileManagerClassName(string $fileManagerClassName) : self
+ public function withFileManagerClassName(string $fileManagerClassName): self
{
$this->fileManagerClassName = $fileManagerClassName;
return $this;
}
- public function withDataCacheClassName(string $dataCacheClassName) : self
+ public function withDataCacheClassName(string $dataCacheClassName): self
{
$this->dataCacheClassName = $dataCacheClassName;
return $this;
}
- public function build() : Container
+ public function build(): Container
{
$config = $this->services['config'] ?? (
new $this->configClassName(
diff --git a/application/Espo/Core/Container/ContainerConfiguration.php b/application/Espo/Core/Container/ContainerConfiguration.php
index 24d0c66052..ef54005ea4 100644
--- a/application/Espo/Core/Container/ContainerConfiguration.php
+++ b/application/Espo/Core/Container/ContainerConfiguration.php
@@ -50,7 +50,7 @@ class ContainerConfiguration
$this->metadata = $metadata;
}
- public function getLoaderClassName(string $name) : ?string
+ public function getLoaderClassName(string $name): ?string
{
$className = null;
@@ -85,17 +85,17 @@ class ContainerConfiguration
return null;
}
- public function getServiceClassName(string $name) : ?string
+ public function getServiceClassName(string $name): ?string
{
return $this->metadata->get(['app', 'containerServices', $name, 'className']) ?? null;
}
- public function getServiceDependencyList(string $name) : ?array
+ public function getServiceDependencyList(string $name): ?array
{
return $this->metadata->get(['app', 'containerServices', $name, 'dependencyList']) ?? null;
}
- public function isSettable(string $name) : bool
+ public function isSettable(string $name): bool
{
return $this->metadata->get(['app', 'containerServices', $name, 'settable']) ?? false;
}
diff --git a/application/Espo/Core/Container/Loader.php b/application/Espo/Core/Container/Loader.php
index dd79c5d3ce..54412f972e 100644
--- a/application/Espo/Core/Container/Loader.php
+++ b/application/Espo/Core/Container/Loader.php
@@ -35,5 +35,5 @@ namespace Espo\Core\Container;
interface Loader
{
// @todo Uncomment when PHP 7.4 is a min supported version.
- //public function load() : object;
+ //public function load(): object;
}
diff --git a/application/Espo/Core/ControllerManager.php b/application/Espo/Core/ControllerManager.php
index 826de790d3..429a385d97 100644
--- a/application/Espo/Core/ControllerManager.php
+++ b/application/Espo/Core/ControllerManager.php
@@ -44,8 +44,9 @@ use ReflectionClass;
*/
class ControllerManager
{
- protected $injectableFactory;
- protected $classFinder;
+ private $injectableFactory;
+
+ private $classFinder;
public function __construct(InjectableFactory $injectableFactory, ClassFinder $classFinder)
{
@@ -53,8 +54,16 @@ class ControllerManager
$this->classFinder = $classFinder;
}
- public function process(string $controllerName, string $actionName, Request $request, Response $response)
- {
+ /**
+ * @return mixed
+ */
+ public function process(
+ string $controllerName,
+ string $actionName,
+ Request $request,
+ Response $response
+ ) {
+
$controller = $this->createController($controllerName);
$requestMethod = $request->getMethod();
@@ -114,7 +123,7 @@ class ControllerManager
return $result;
}
- protected function useShortParamList(object $controller, string $methodName) : bool
+ protected function useShortParamList(object $controller, string $methodName): bool
{
$class = new ReflectionClass($controller);
@@ -144,7 +153,7 @@ class ControllerManager
return false;
}
- protected function getControllerClassName(string $name) : string
+ protected function getControllerClassName(string $name): string
{
$className = $this->classFinder->find('Controllers', $name);
@@ -159,7 +168,7 @@ class ControllerManager
return $className;
}
- protected function createController(string $name) : object
+ protected function createController(string $name): object
{
return $this->injectableFactory->createWith($this->getControllerClassName($name), [
'name' => $name,
diff --git a/application/Espo/Core/Controllers/Record.php b/application/Espo/Core/Controllers/Record.php
index 289405c7a6..bb7535d8b0 100644
--- a/application/Espo/Core/Controllers/Record.php
+++ b/application/Espo/Core/Controllers/Record.php
@@ -54,7 +54,7 @@ class Record extends Base
return $this->getContainer()->get('entityManager');
}
- protected function getRecordService(?string $name = null) : object
+ protected function getRecordService(?string $name = null): object
{
$name = $name ?? $this->name;
@@ -242,13 +242,17 @@ class Record extends Base
if (is_array($result)) {
return [
'total' => $result['total'],
- 'list' => isset($result['collection']) ? $result['collection']->getValueMapList() : $result['list']
+ 'list' => isset($result['collection']) ?
+ $result['collection']->getValueMapList() :
+ $result['list']
];
}
return (object) [
'total' => $result->total,
- 'list' => isset($result->collection) ? $result->collection->getValueMapList() : $result->list
+ 'list' => isset($result->collection) ?
+ $result->collection->getValueMapList() :
+ $result->list
];
}
diff --git a/application/Espo/Core/Controllers/RecordTree.php b/application/Espo/Core/Controllers/RecordTree.php
index 1100812da3..4721e5736f 100644
--- a/application/Espo/Core/Controllers/RecordTree.php
+++ b/application/Espo/Core/Controllers/RecordTree.php
@@ -50,10 +50,16 @@ class RecordTree extends Record
$maxDepth = $request->get('maxDepth');
$onlyNotEmpty = $request->get('onlyNotEmpty');
- $collection = $this->getRecordService()->getTree($parentId, [
- 'where' => $where,
- 'onlyNotEmpty' => $onlyNotEmpty
- ], 0, $maxDepth);
+ $collection = $this->getRecordService()->getTree(
+ $parentId,
+ [
+ 'where' => $where,
+ 'onlyNotEmpty' => $onlyNotEmpty,
+ ],
+ 0,
+ $maxDepth
+ );
+
return (object) [
'list' => $collection->toArray(),
'path' => $this->getRecordService()->getTreeItemPath($parentId),
diff --git a/application/Espo/Core/Currency/DatabasePopulator.php b/application/Espo/Core/Currency/DatabasePopulator.php
index 2d663e0320..40053f5f34 100644
--- a/application/Espo/Core/Currency/DatabasePopulator.php
+++ b/application/Espo/Core/Currency/DatabasePopulator.php
@@ -40,6 +40,7 @@ use Espo\Core\{
class DatabasePopulator
{
private $config;
+
private $entityManager;
public function __construct(Config $config, EntityManager $entityManager)
@@ -76,7 +77,7 @@ class DatabasePopulator
}
}
- protected function exchangeRates(string $baseCurrency, string $defaultCurrency, array $currencyRates) : array
+ protected function exchangeRates(string $baseCurrency, string $defaultCurrency, array $currencyRates): array
{
$precision = 5;
$defaultCurrencyRate = round(1 / $currencyRates[$defaultCurrency], $precision);
diff --git a/application/Espo/Core/HookManager.php b/application/Espo/Core/HookManager.php
index 029cb9be0a..952587b960 100644
--- a/application/Espo/Core/HookManager.php
+++ b/application/Espo/Core/HookManager.php
@@ -156,7 +156,7 @@ class HookManager
}
}
- protected function createHookByClassName(string $className) : object
+ protected function createHookByClassName(string $className): object
{
if (!class_exists($className)) {
$GLOBALS['log']->error("Hook class '{$className}' does not exist.");
@@ -172,7 +172,7 @@ class HookManager
*
* @param $hookDirs - can be ['Espo/Hooks', 'Espo/Custom/Hooks', 'Espo/Modules/Crm/Hooks']
*/
- protected function getHookData($hookDirs, array $hookData = []) : array
+ protected function getHookData($hookDirs, array $hookData = []): array
{
if (is_string($hookDirs)) {
$hookDirs = (array) $hookDirs;
@@ -226,7 +226,7 @@ class HookManager
/**
* Sort hooks by the order param.
*/
- protected function sortHooks(array $hooks) : array
+ protected function sortHooks(array $hooks): array
{
foreach ($hooks as $scopeName => &$scopeHooks) {
foreach ($scopeHooks as $hookName => &$hookList) {
@@ -240,7 +240,7 @@ class HookManager
/**
* Get sorted hook list.
*/
- protected function getHookList(string $scope, string $hookName) : array
+ protected function getHookList(string $scope, string $hookName): array
{
$key = $scope . '_' . $hookName;
@@ -271,7 +271,7 @@ class HookManager
/**
* Check if hook exists in the list.
*/
- protected function hookExists(string $className, array $hookData) : bool
+ protected function hookExists(string $className, array $hookData): bool
{
$class = preg_replace('/^.*\\\(.*)$/', '$1', $className);
diff --git a/application/Espo/Core/RecordServiceContainer.php b/application/Espo/Core/RecordServiceContainer.php
index ab91476072..9fcbca4271 100644
--- a/application/Espo/Core/RecordServiceContainer.php
+++ b/application/Espo/Core/RecordServiceContainer.php
@@ -59,7 +59,7 @@ class RecordServiceContainer
$this->metadata = $metadata;
}
- public function get(string $entityType) : Record
+ public function get(string $entityType): Record
{
if (!array_key_exists($entityType, $this->data)) {
$this->load($entityType);
@@ -68,7 +68,7 @@ class RecordServiceContainer
return $this->data[$entityType];
}
- private function load(string $entityType) : void
+ private function load(string $entityType): void
{
if (!$this->metadata->get(['scopes', $entityType, 'entity'])) {
throw new Error("Can't create record service {$entityType}, there's no such entity type.");