Fix phpstan issues.

This commit is contained in:
James Cole
2024-04-23 19:40:48 +02:00
parent f43aadf02d
commit fa3ccbda33
18 changed files with 61 additions and 111 deletions

View File

@@ -55,11 +55,7 @@ class AccountController extends Controller
function ($request, $next) { function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$this->adminRepository = app(AdminAccountRepositoryInterface::class); $this->adminRepository = app(AdminAccountRepositoryInterface::class);
$this->adminRepository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->adminRepository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }
@@ -85,7 +81,7 @@ class AccountController extends Controller
$types = $data['types']; $types = $data['types'];
$query = $data['query']; $query = $data['query'];
$date = $this->parameters->get('date') ?? today(config('app.timezone')); $date = $this->parameters->get('date') ?? today(config('app.timezone'));
$result = $this->adminRepository->searchAccount((string)$query, $types, $data['limit']); $result = $this->adminRepository->searchAccount((string) $query, $types, $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency(); $defaultCurrency = app('amount')->getDefaultCurrency();
$groupedResult = []; $groupedResult = [];
$allItems = []; $allItems = [];
@@ -99,19 +95,19 @@ class AccountController extends Controller
$balance = app('steam')->balance($account, $date); $balance = app('steam')->balance($account, $date);
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false)); $nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
} }
$type = (string)trans(sprintf('firefly.%s', $account->accountType->type)); $type = (string) trans(sprintf('firefly.%s', $account->accountType->type));
$groupedResult[$type] ??= [ $groupedResult[$type] ??= [
'group ' => $type, 'group ' => $type,
'items' => [], 'items' => [],
]; ];
$allItems[] = [ $allItems[] = [
'id' => (string)$account->id, 'id' => (string) $account->id,
'value' => (string)$account->id, 'value' => (string) $account->id,
'name' => $account->name, 'name' => $account->name,
'name_with_balance' => $nameWithBalance, 'name_with_balance' => $nameWithBalance,
'label' => $nameWithBalance, 'label' => $nameWithBalance,
'type' => $account->accountType->type, 'type' => $account->accountType->type,
'currency_id' => (string)$currency->id, 'currency_id' => (string) $currency->id,
'currency_name' => $currency->name, 'currency_name' => $currency->name,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
@@ -123,8 +119,8 @@ class AccountController extends Controller
$allItems, $allItems,
static function (array $left, array $right): int { static function (array $left, array $right): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posLeft = (int)array_search($left['type'], $order, true); $posLeft = (int) array_search($left['type'], $order, true);
$posRight = (int)array_search($right['type'], $order, true); $posRight = (int) array_search($right['type'], $order, true);
return $posLeft - $posRight; return $posLeft - $posRight;
} }

View File

@@ -45,11 +45,7 @@ class CategoryController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class); $this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -45,11 +45,7 @@ class TagController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class); $this->repository = app(TagRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -45,11 +45,7 @@ class TransactionController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(JournalRepositoryInterface::class); $this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -55,8 +55,7 @@ class AccountController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
$userGroup = $this->validateUserGroup($request); $this->repository->setUserGroup($this->validateUserGroup($request));
$this->repository->setUserGroup($userGroup);
return $next($request); return $next($request);
} }

View File

@@ -64,12 +64,9 @@ class BudgetController extends Controller
$this->blRepository = app(BudgetLimitRepositoryInterface::class); $this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository = app(OperationsRepositoryInterface::class);
$this->currency = app('amount')->getDefaultCurrency(); $this->currency = app('amount')->getDefaultCurrency();
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) { $this->repository->setUserGroup($userGroup);
$this->repository->setUserGroup($userGroup); $this->opsRepository->setUserGroup($userGroup);
$this->opsRepository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }
@@ -81,13 +78,13 @@ class BudgetController extends Controller
*/ */
public function dashboard(DateRequest $request): JsonResponse public function dashboard(DateRequest $request): JsonResponse
{ {
$params = $request->getAll(); $params = $request->getAll();
/** @var Carbon $start */ /** @var Carbon $start */
$start = $params['start']; $start = $params['start'];
/** @var Carbon $end */ /** @var Carbon $end */
$end = $params['end']; $end = $params['end'];
// code from FrontpageChartGenerator, but not in separate class // code from FrontpageChartGenerator, but not in separate class
$budgets = $this->repository->getActiveBudgets(); $budgets = $this->repository->getActiveBudgets();
@@ -124,11 +121,11 @@ class BudgetController extends Controller
foreach ($rows as $row) { foreach ($rows as $row) {
$current = [ $current = [
'label' => $budget->name, 'label' => $budget->name,
'currency_id' => (string)$row['currency_id'], 'currency_id' => (string) $row['currency_id'],
'currency_code' => $row['currency_code'], 'currency_code' => $row['currency_code'],
'currency_name' => $row['currency_name'], 'currency_name' => $row['currency_name'],
'currency_decimal_places' => $row['currency_decimal_places'], 'currency_decimal_places' => $row['currency_decimal_places'],
'native_currency_id' => (string)$row['native_currency_id'], 'native_currency_id' => (string) $row['native_currency_id'],
'native_currency_code' => $row['native_currency_code'], 'native_currency_code' => $row['native_currency_code'],
'native_currency_name' => $row['native_currency_name'], 'native_currency_name' => $row['native_currency_name'],
'native_currency_decimal_places' => $row['native_currency_decimal_places'], 'native_currency_decimal_places' => $row['native_currency_decimal_places'],
@@ -189,12 +186,12 @@ class BudgetController extends Controller
foreach ($array as $currencyId => $block) { foreach ($array as $currencyId => $block) {
$this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId); $this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
$return[$currencyId] ??= [ $return[$currencyId] ??= [
'currency_id' => (string)$currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $block['currency_code'], 'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'], 'currency_name' => $block['currency_name'],
'currency_symbol' => $block['currency_symbol'], 'currency_symbol' => $block['currency_symbol'],
'currency_decimal_places' => (int)$block['currency_decimal_places'], 'currency_decimal_places' => (int) $block['currency_decimal_places'],
'native_currency_id' => (string)$this->currency->id, 'native_currency_id' => (string) $this->currency->id,
'native_currency_code' => $this->currency->code, 'native_currency_code' => $this->currency->code,
'native_currency_name' => $this->currency->name, 'native_currency_name' => $this->currency->name,
'native_currency_symbol' => $this->currency->symbol, 'native_currency_symbol' => $this->currency->symbol,
@@ -208,14 +205,14 @@ class BudgetController extends Controller
'overspent' => '0', 'overspent' => '0',
'native_overspent' => '0', 'native_overspent' => '0',
]; ];
$currentBudgetArray = $block['budgets'][$budgetId]; $currentBudgetArray = $block['budgets'][$budgetId];
// var_dump($return); // var_dump($return);
/** @var array $journal */ /** @var array $journal */
foreach ($currentBudgetArray['transaction_journals'] as $journal) { foreach ($currentBudgetArray['transaction_journals'] as $journal) {
// convert the amount to the native currency. // convert the amount to the native currency.
$rate = $converter->getCurrencyRate($this->currencies[$currencyId], $this->currency, $journal['date']); $rate = $converter->getCurrencyRate($this->currencies[$currencyId], $this->currency, $journal['date']);
$convertedAmount = bcmul($journal['amount'], $rate); $convertedAmount = bcmul($journal['amount'], $rate);
if ($journal['foreign_currency_id'] === $this->currency->id) { if ($journal['foreign_currency_id'] === $this->currency->id) {
$convertedAmount = $journal['foreign_amount']; $convertedAmount = $journal['foreign_amount'];
} }
@@ -258,7 +255,7 @@ class BudgetController extends Controller
private function processLimit(Budget $budget, BudgetLimit $limit): array private function processLimit(Budget $budget, BudgetLimit $limit): array
{ {
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$end = clone $limit->end_date; $end = clone $limit->end_date;
$end->endOfDay(); $end->endOfDay();
$spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget])); $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget]));
$limitCurrencyId = $limit->transaction_currency_id; $limitCurrencyId = $limit->transaction_currency_id;
@@ -276,7 +273,7 @@ class BudgetController extends Controller
$filtered[$currencyId] = $entry; $filtered[$currencyId] = $entry;
} }
} }
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end); $result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) { if (1 === count($result)) {
$compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent'])); $compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
if (1 === $compare) { if (1 === $compare) {

View File

@@ -57,10 +57,7 @@ class CategoryController extends Controller
function ($request, $next) { function ($request, $next) {
$this->accountRepos = app(AccountRepositoryInterface::class); $this->accountRepos = app(AccountRepositoryInterface::class);
$this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->currencyRepos = app(CurrencyRepositoryInterface::class);
$userGroup = $this->validateUserGroup($request); $this->accountRepos->setUserGroup($this->validateUserGroup($request));
if (null !== $userGroup) {
$this->accountRepos->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }
@@ -80,7 +77,7 @@ class CategoryController extends Controller
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
/** @var Carbon $start */ /** @var Carbon $start */
$start = $this->parameters->get('start'); $start = $this->parameters->get('start');
/** @var Carbon $end */ /** @var Carbon $end */
$end = $this->parameters->get('end'); $end = $this->parameters->get('end');
@@ -92,33 +89,33 @@ class CategoryController extends Controller
// get journals for entire period: // get journals for entire period:
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)->withAccountInformation(); $collector->setRange($start, $end)->withAccountInformation();
$collector->setXorAccounts($accounts)->withCategoryInformation(); $collector->setXorAccounts($accounts)->withCategoryInformation();
$collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::RECONCILIATION]); $collector->setTypes([TransactionType::WITHDRAWAL, TransactionType::RECONCILIATION]);
$journals = $collector->getExtractedJournals(); $journals = $collector->getExtractedJournals();
/** @var array $journal */ /** @var array $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
$currencyId = (int)$journal['currency_id']; $currencyId = (int) $journal['currency_id'];
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId); $currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency; $currencies[$currencyId] = $currency;
$categoryName = null === $journal['category_name'] ? (string)trans('firefly.no_category') : $journal['category_name']; $categoryName = null === $journal['category_name'] ? (string) trans('firefly.no_category') : $journal['category_name'];
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount); $nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
$key = sprintf('%s-%s', $categoryName, $currency->code); $key = sprintf('%s-%s', $categoryName, $currency->code);
if ((int)$journal['foreign_currency_id'] === $default->id) { if ((int) $journal['foreign_currency_id'] === $default->id) {
$nativeAmount = app('steam')->positive($journal['foreign_amount']); $nativeAmount = app('steam')->positive($journal['foreign_amount']);
} }
// create arrays // create arrays
$return[$key] ??= [ $return[$key] ??= [
'label' => $categoryName, 'label' => $categoryName,
'currency_id' => (string)$currency->id, 'currency_id' => (string) $currency->id,
'currency_code' => $currency->code, 'currency_code' => $currency->code,
'currency_name' => $currency->name, 'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places, 'currency_decimal_places' => $currency->decimal_places,
'native_currency_id' => (string)$default->id, 'native_currency_id' => (string) $default->id,
'native_currency_code' => $default->code, 'native_currency_code' => $default->code,
'native_currency_name' => $default->name, 'native_currency_name' => $default->name,
'native_currency_symbol' => $default->symbol, 'native_currency_symbol' => $default->symbol,
@@ -134,11 +131,11 @@ class CategoryController extends Controller
$return[$key]['amount'] = bcadd($return[$key]['amount'], $amount); $return[$key]['amount'] = bcadd($return[$key]['amount'], $amount);
$return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], $nativeAmount); $return[$key]['native_amount'] = bcadd($return[$key]['native_amount'], $nativeAmount);
} }
$return = array_values($return); $return = array_values($return);
// order by native amount // order by native amount
usort($return, static function (array $a, array $b) { usort($return, static function (array $a, array $b) {
return (float)$a['native_amount'] < (float)$b['native_amount'] ? 1 : -1; return (float) $a['native_amount'] < (float) $b['native_amount'] ? 1 : -1;
}); });
$converter->summarize(); $converter->summarize();

View File

@@ -45,11 +45,7 @@ class UpdateController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
// new way of user group validation $this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }
@@ -63,17 +59,16 @@ class UpdateController extends Controller
{ {
app('log')->debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData(); $data = $request->getUpdateData();
$data['type'] = config('firefly.shortNamesByFullName.'.$account->accountType->type); $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$account = $this->repository->update($account, $data); $account = $this->repository->update($account, $data);
$account->refresh(); $account->refresh();
app('preferences')->mark(); app('preferences')->mark();
$transformer = new AccountTransformer(); $transformer = new AccountTransformer();
$transformer->setParameters($this->parameters); $transformer->setParameters($this->parameters);
return response() return response()
->api($this->jsonApiObject('accounts', $account, $transformer)) ->api($this->jsonApiObject('accounts', $account, $transformer))
->header('Content-Type', self::CONTENT_TYPE) ->header('Content-Type', self::CONTENT_TYPE);
;
} }
} }

View File

@@ -46,12 +46,7 @@ class IndexController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class); $this->repository = app(BillRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
// new way of user group validation
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -46,12 +46,7 @@ class ShowController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class); $this->repository = app(BillRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
// new way of user group validation
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -45,11 +45,7 @@ class SumController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class); $this->repository = app(BillRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -46,11 +46,7 @@ class IndexController extends Controller
$this->middleware( $this->middleware(
function ($request, $next) { function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class); $this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }

View File

@@ -51,11 +51,9 @@ class NetWorthController extends Controller
$this->netWorth = app(NetWorthInterface::class); $this->netWorth = app(NetWorthInterface::class);
$this->repository = app(AccountRepositoryInterface::class); $this->repository = app(AccountRepositoryInterface::class);
// new way of user group validation // new way of user group validation
$userGroup = $this->validateUserGroup($request); $userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) { $this->netWorth->setUserGroup($userGroup);
$this->netWorth->setUserGroup($userGroup); $this->repository->setUserGroup($userGroup);
$this->repository->setUserGroup($userGroup);
}
return $next($request); return $next($request);
} }
@@ -81,7 +79,7 @@ class NetWorthController extends Controller
); );
// skip accounts that should not be in the net worth // skip accounts that should not be in the net worth
$result = $this->netWorth->byAccounts($filtered, $date); $result = $this->netWorth->byAccounts($filtered, $date);
return response()->api($result); return response()->api($result);
} }

View File

@@ -151,8 +151,8 @@ class HomeController extends Controller
} }
/** @var Carbon $start */ /** @var Carbon $start */
/** @var Carbon $end */
$start = session('start', today(config('app.timezone'))->startOfMonth()); $start = session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */
$end = session('end', today(config('app.timezone'))->endOfMonth()); $end = session('end', today(config('app.timezone'))->endOfMonth());
$accounts = $repository->getAccountsById($frontpageArray); $accounts = $repository->getAccountsById($frontpageArray);
$today = today(config('app.timezone')); $today = today(config('app.timezone'));

View File

@@ -130,12 +130,12 @@ class MailError extends Job implements ShouldQueue
} }
if (file_exists($file)) { if (file_exists($file)) {
Log::debug(sprintf('Read file in "%s"', $file)); Log::debug(sprintf('Read file in "%s"', $file));
$limits = json_decode(file_get_contents($file), true); $limits = json_decode((string)file_get_contents($file), true);
} }
// limit reached? // limit reached?
foreach ($types as $type => $info) { foreach ($types as $type => $info) {
Log::debug(sprintf('Now checking limit "%s"', $type), $info); Log::debug(sprintf('Now checking limit "%s"', $type), $info);
if (!isset($limits[$type])) { if (!array_key_exists($type, $limits)) {
Log::debug(sprintf('Limit "%s" reset to zero, did not exist yet.', $type)); Log::debug(sprintf('Limit "%s" reset to zero, did not exist yet.', $type));
$limits[$type] = [ $limits[$type] = [
'time' => time(), 'time' => time(),

View File

@@ -81,7 +81,7 @@ trait ValidatesUserGroupTrait
throw new AuthorizationException((string) trans('validation.belongs_user_or_user_group')); throw new AuthorizationException((string) trans('validation.belongs_user_or_user_group'));
} }
Log::debug(sprintf('validateUserGroup: validate access of user to group #%d ("%s").', $groupId, $group->title)); Log::debug(sprintf('validateUserGroup: validate access of user to group #%d ("%s").', $groupId, $group->title));
$roles = property_exists($this, 'acceptedRoles') ? $this->acceptedRoles : []; $roles = property_exists($this, 'acceptedRoles') ? $this->acceptedRoles : []; // @phpstan-ignore-line
if (0 === count($roles)) { if (0 === count($roles)) {
Log::debug('validateUserGroup: no roles defined, so no access.'); Log::debug('validateUserGroup: no roles defined, so no access.');

View File

@@ -159,9 +159,7 @@ trait ConvertsDataTypes
if (method_exists($this, 'validateUserGroup')) { // @phpstan-ignore-line if (method_exists($this, 'validateUserGroup')) { // @phpstan-ignore-line
$userGroup = $this->validateUserGroup($this); $userGroup = $this->validateUserGroup($this);
if (null !== $userGroup) {
$repository->setUserGroup($userGroup); $repository->setUserGroup($userGroup);
}
} }
// set administration ID // set administration ID

View File

@@ -62,7 +62,7 @@ return [
| |
*/ */
'editor' => env('DEBUGBAR_EDITOR') ?: env('IGNITION_EDITOR', 'phpstorm'), 'editor' => env('DEBUGBAR_EDITOR') ?? env('IGNITION_EDITOR', 'phpstorm'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------