type fixes
This commit is contained in:
@@ -34,6 +34,8 @@ use Espo\Core\Utils\System;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
use Espo\Core\{
|
||||
Container,
|
||||
Upgrades\ActionManager,
|
||||
@@ -156,6 +158,9 @@ abstract class Base
|
||||
return $this->getContainer()->get('log');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FileManager
|
||||
*/
|
||||
protected function getFileManager()
|
||||
{
|
||||
return $this->getContainer()->get('fileManager');
|
||||
@@ -773,11 +778,12 @@ abstract class Base
|
||||
/**
|
||||
* Delete temporary package files.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function deletePackageFiles()
|
||||
{
|
||||
$packagePath = $this->getPackagePath();
|
||||
|
||||
$res = $this->getFileManager()->removeInDir($packagePath, true);
|
||||
|
||||
return $res;
|
||||
@@ -786,11 +792,12 @@ abstract class Base
|
||||
/**
|
||||
* Delete temporary package archive.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function deletePackageArchive()
|
||||
{
|
||||
$packageArchive = $this->getPackagePath(true);
|
||||
|
||||
$res = $this->getFileManager()->removeFile($packageArchive);
|
||||
|
||||
return $res;
|
||||
|
||||
@@ -53,15 +53,18 @@ class Install extends \Espo\Core\Upgrades\Actions\Base\Install
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete temporary package files
|
||||
* Delete temporary package files.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function deletePackageFiles()
|
||||
{
|
||||
$res = parent::deletePackageFiles();
|
||||
|
||||
$res &= $this->deletePackageArchive();
|
||||
|
||||
/** @var bool @res */
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class Helper
|
||||
* Create PDO connection.
|
||||
*
|
||||
* @param array $params
|
||||
* @return PDO|\PDOException
|
||||
* @return PDO|null
|
||||
*/
|
||||
public function createPdoConnection(array $params = null)
|
||||
{
|
||||
|
||||
@@ -88,14 +88,14 @@ class RelationManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Get foreign Link
|
||||
*
|
||||
* @param string $parentLinkName
|
||||
* @param array $parentLinkParams
|
||||
* @param array $currentEntityDefs
|
||||
*
|
||||
* @return array - in format array('name', 'params')
|
||||
*/
|
||||
* Get foreign link.
|
||||
*
|
||||
* @param string $parentLinkName
|
||||
* @param array $parentLinkParams
|
||||
* @param array $currentEntityDefs
|
||||
*
|
||||
* @return array|false Formatted as ['name', 'params'].
|
||||
*/
|
||||
private function getForeignLink($parentLinkName, $parentLinkParams, $currentEntityDefs)
|
||||
{
|
||||
if (isset($parentLinkParams['foreign']) && isset($currentEntityDefs['links'][$parentLinkParams['foreign']])) {
|
||||
|
||||
@@ -387,7 +387,7 @@ class Permission
|
||||
/**
|
||||
* Get default owner user.
|
||||
*
|
||||
* @return int owner id.
|
||||
* @return int|false owner id.
|
||||
*/
|
||||
public function getDefaultOwner(bool $usePosix = false)
|
||||
{
|
||||
@@ -538,7 +538,7 @@ class Permission
|
||||
*
|
||||
* @param string $search
|
||||
* @param array $array
|
||||
* @return bool
|
||||
* @return int
|
||||
*/
|
||||
protected function getSearchCount($search, array $array)
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ class Metadata
|
||||
* @param bool $isJSON
|
||||
* @param bool $reload
|
||||
*
|
||||
* @return array
|
||||
* @return array|string
|
||||
*/
|
||||
public function getAll(bool $isJSON = false, bool $reload = false)
|
||||
{
|
||||
@@ -384,6 +384,7 @@ class Metadata
|
||||
public function saveCustom(string $key1, string $key2, $data): void
|
||||
{
|
||||
if (is_object($data)) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
foreach ($data as $key => $item) {
|
||||
if ($item == new stdClass()) {
|
||||
unset($data->$key);
|
||||
|
||||
@@ -111,9 +111,8 @@ class Util
|
||||
* Convert name from Camel Case format.
|
||||
* ex. camelCase to camel-case
|
||||
*
|
||||
* @param string | array $name
|
||||
*
|
||||
* @return string
|
||||
* @param string|string[] $name
|
||||
* @return string|string[]
|
||||
*/
|
||||
public static function fromCamelCase($name, $symbol = '_')
|
||||
{
|
||||
@@ -139,9 +138,8 @@ class Util
|
||||
* Convert name from Camel Case format to underscore.
|
||||
* ex. camelCase to camel_case
|
||||
*
|
||||
* @param string | array $name
|
||||
*
|
||||
* @return string
|
||||
* @param string|string[] $name
|
||||
* @return string|string[]
|
||||
*/
|
||||
public static function toUnderScore($name)
|
||||
{
|
||||
@@ -220,7 +218,7 @@ class Util
|
||||
{
|
||||
$doReindex = false;
|
||||
|
||||
foreach($haystack as $key => $value) {
|
||||
foreach ($haystack as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$haystack[$key] = static::unsetInArrayByValue($needle, $value);
|
||||
}
|
||||
@@ -354,13 +352,15 @@ class Util
|
||||
* @param string $prePostFix
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getNaming($name, $prePostFix, $type = 'prefix', $symbol = '_')
|
||||
{
|
||||
if ($type == 'prefix') {
|
||||
return static::toCamelCase($prePostFix.$symbol.$name, $symbol);
|
||||
} else if ($type == 'postfix') {
|
||||
}
|
||||
|
||||
if ($type == 'postfix') {
|
||||
return static::toCamelCase($name.$symbol.$prePostFix, $symbol);
|
||||
}
|
||||
|
||||
@@ -372,10 +372,9 @@ class Util
|
||||
*
|
||||
* @param string $search
|
||||
* @param string $replace
|
||||
* @param string|false $array
|
||||
* @param string[]|false $array
|
||||
* @param bool $isKeys
|
||||
*
|
||||
* @return array
|
||||
* @return string[]|string
|
||||
*/
|
||||
public static function replaceInArray($search = '', $replace = '', $array = false, $isKeys = true)
|
||||
{
|
||||
@@ -383,14 +382,15 @@ class Util
|
||||
return str_replace($search, $replace, $array);
|
||||
}
|
||||
|
||||
$newArr = array();
|
||||
$newArr = [];
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$addKey = $key;
|
||||
if ($isKeys) { //Replace keys
|
||||
|
||||
if ($isKeys) {
|
||||
$addKey = str_replace($search, $replace, $key);
|
||||
}
|
||||
|
||||
// Recurse
|
||||
$newArr[$addKey] = static::replaceInArray($search, $replace, $value, $isKeys);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user