type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-22 12:22:29 +02:00
parent 80fa7407d4
commit 1d4030b29e
6 changed files with 36 additions and 2 deletions
+8
View File
@@ -48,6 +48,7 @@ class Route
* route:string,
* method:string,
* noAuth?:bool,
* params?:array<string,mixed>,
* }
* >
*/
@@ -92,6 +93,8 @@ class Route
$this->init();
}
assert($this->data !== null);
return array_map(
function (array $item): RouteItem {
return new RouteItem(
@@ -117,6 +120,7 @@ class Route
* route:string,
* method:string,
* noAuth?:bool,
* params?:array<string,mixed>,
* }
* >
*/
@@ -141,6 +145,7 @@ class Route
* route:string,
* method:string,
* noAuth?:bool,
* params?:array<string,mixed>,
* }
* >
*/
@@ -175,6 +180,7 @@ class Route
* route:string,
* method:string,
* noAuth?:bool,
* params?:array<string,mixed>,
* }
* > $currentData
* @return array<
@@ -183,6 +189,7 @@ class Route
* route:string,
* method:string,
* noAuth?:bool,
* params?:array<string,mixed>,
* }
* >
*/
@@ -256,6 +263,7 @@ class Route
private function adjustPath(string $path): string
{
// to fast route format
/** @var string */
$pathFormatteted = preg_replace('/\:([a-zA-Z0-9]+)/', '{${1}}', trim($path));
if (substr($pathFormatteted, 0, 1) !== '/') {
+2 -1
View File
@@ -136,7 +136,8 @@ class ScheduledJob
$command = isset($this->cronSetup[$OS]) ? $this->cronSetup[$OS] : $this->cronSetup['default'];
foreach ($data as $name => $value) {
$command = str_replace('{'.$name.'}', $value, $command);
/** @var string */
$command = str_replace('{' . $name . '}', $value ?? '', $command);
}
return [
@@ -310,7 +310,9 @@ class SystemRequirements
case 'requiredMysqlVersion':
case 'requiredMariadbVersion':
/** @var string $data */
/** @var PDO $pdo */
$actualVersion = $databaseHelper->getPdoDatabaseVersion($pdo);
$requiredVersion = $data;
$acceptable = true;
@@ -331,6 +333,9 @@ class SystemRequirements
/** @var string[] $data */
foreach ($data as $name => $value) {
$requiredValue = $value;
/** @var PDO $pdo */
$actualValue = $databaseHelper->getPdoDatabaseParam($name, $pdo);
$acceptable = false;
+12
View File
@@ -71,6 +71,7 @@ class Util
*/
public static function toFormat($name, $delimiter = '/')
{
/** @var string */
return preg_replace("/[\/\\\]/", $delimiter, $name);
}
@@ -99,6 +100,7 @@ class Util
$input = ucfirst($input);
}
/** @var string */
return preg_replace_callback(
'/' . $symbol . '([a-zA-Z])/',
/**
@@ -129,6 +131,7 @@ class Util
$input[0] = strtolower($input[0]);
/** @var string */
return preg_replace_callback(
'/([A-Z])/',
function ($matches) use ($symbol) {
@@ -491,7 +494,9 @@ class Util
*/
public static function getClassName(string $filePath): string
{
/** @var string */
$className = preg_replace('/\.php$/i', '', $filePath);
/** @var string */
$className = preg_replace('/^(application|custom)(\/|\\\)/i', '', $className);
$className = static::toFormat($className, '\\');
@@ -636,6 +641,7 @@ class Util
public static function sanitizeFileName(string $fileName): string
{
/** @var string */
return preg_replace("/([^\w\s\d\-_~,;:\[\]\(\).])/u", '_', $fileName);
}
@@ -839,6 +845,7 @@ class Util
$sanitized = htmlspecialchars($text, \ENT_QUOTES | \ENT_HTML5, 'UTF-8');
foreach ($permittedHtmlTags as $htmlTag) {
/** @var string */
$sanitized = preg_replace('/&lt;(\/)?(' . $htmlTag . ')&gt;/i', '<$1$2>', $sanitized);
}
@@ -858,7 +865,9 @@ class Util
];
$url = trim($url);
/** @var string */
$url = preg_replace('/\/\?$/', '', $url);
/** @var string */
$url = preg_replace('/\/$/', '', $url);
return $url . '/?' . http_build_query($params);
@@ -888,8 +897,11 @@ class Util
$newUrl = str_replace($urlQuery, http_build_query($params), $url);
if (empty($params)) {
/** @var string */
$newUrl = preg_replace('/\/\?$/', '', $newUrl);
/** @var string */
$newUrl = preg_replace('/\/$/', '', $newUrl);
$newUrl .= $suffix;
}
@@ -43,6 +43,8 @@ use Espo\Entities\{
Webhook,
};
use RuntimeException;
/**
* Processes events. Holds an information about existing events.
*/
@@ -106,6 +108,10 @@ class Manager
private function storeDataToCache(): void
{
if ($this->data === null) {
throw new RuntimeException("No data to store.");
}
$this->dataCache->store($this->cacheKey, $this->data);
}
+3 -1
View File
@@ -198,12 +198,14 @@ class Queue
->limit(0, $batchSize)
->find();
$webhook = $this->entityManager->getEntity(Webhook::ENTITY_TYPE, $webhookId);
$webhook = $this->entityManager->getEntityById(Webhook::ENTITY_TYPE, $webhookId);
if (!$webhook || !$webhook->get('isActive')) {
foreach ($itemList as $item) {
$this->deleteQueueItem($item);
}
return;
}
$forbiddenAttributeList = [];