1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Static analysis

This commit is contained in:
David Bomba 2024-07-11 15:53:18 +10:00
parent e371721b3f
commit d22c9a3bd9
24 changed files with 38 additions and 31 deletions

View File

@ -57,6 +57,7 @@ class ActivityExport extends BaseExport
$report = $query->cursor() $report = $query->cursor()
->map(function ($resource) { ->map(function ($resource) {
/** @var \App\Models\Activity $resource */
$row = $this->buildActivityRow($resource); $row = $this->buildActivityRow($resource);
return $this->processMetaData($row, $resource); return $this->processMetaData($row, $resource);
})->toArray(); })->toArray();
@ -128,6 +129,9 @@ class ActivityExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($entity) { ->each(function ($entity) {
/** @var \App\Models\Activity $entity */
$this->buildRow($entity); $this->buildRow($entity);
}); });

View File

@ -102,6 +102,8 @@ class ClientExport extends BaseExport
$report = $query->cursor() $report = $query->cursor()
->map(function ($client) { ->map(function ($client) {
/** @var \App\Models\Client $client */
$row = $this->buildRow($client); $row = $this->buildRow($client);
return $this->processMetaData($row, $client); return $this->processMetaData($row, $client);
})->toArray(); })->toArray();
@ -154,6 +156,8 @@ class ClientExport extends BaseExport
$query->cursor() $query->cursor()
->each(function ($client) { ->each(function ($client) {
/** @var \App\Models\Client $client */
$this->csv->insertOne($this->buildRow($client)); $this->csv->insertOne($this->buildRow($client));
}); });

View File

@ -161,7 +161,7 @@ class TaskExport extends BaseExport
} }
if (is_null($task->time_log) || (is_array(json_decode($task->time_log, 1)) && count(json_decode($task->time_log, 1)) == 0)) { if (is_null($task->time_log) || (is_array(json_decode($task->time_log, true)) && count(json_decode($task->time_log, true)) == 0)) {
$this->storage_array[] = $entity; $this->storage_array[] = $entity;
} else { } else {
$this->iterateLogs($task, $entity); $this->iterateLogs($task, $entity);
@ -178,7 +178,7 @@ class TaskExport extends BaseExport
$timezone_name = $timezone->name; $timezone_name = $timezone->name;
} }
$logs = json_decode($task->time_log, 1); $logs = json_decode($task->time_log, true);
$date_format_default = $this->date_format; $date_format_default = $this->date_format;

View File

@ -48,7 +48,7 @@ class TaskDecorator extends Decorator implements DecoratorInterface
$timezone_name = $timezone->name; $timezone_name = $timezone->name;
} }
$logs = json_decode($task->time_log, 1); $logs = json_decode($task->time_log, true);
$date_format_default = 'Y-m-d'; $date_format_default = 'Y-m-d';
@ -77,7 +77,7 @@ class TaskDecorator extends Decorator implements DecoratorInterface
$timezone_name = $timezone->name; $timezone_name = $timezone->name;
} }
$logs = json_decode($task->time_log, 1); $logs = json_decode($task->time_log, true);
$date_format_default = 'Y-m-d'; $date_format_default = 'Y-m-d';

View File

@ -175,7 +175,7 @@ class RecurringExpenseToExpenseFactory
$_value = explode($_operation, $right); // [MONTHYEAR, 4] $_value = explode($_operation, $right); // [MONTHYEAR, 4]
$_right = Carbon::createFromDate(now()->year, now()->month)->addMonths($_value[1])->translatedFormat('F Y'); $_right = Carbon::createFromDate(now()->year, now()->month)->addMonths($_value[1])->translatedFormat('F Y'); //@phpstan-ignore-line
} }
$replacement = sprintf('%s to %s', $_left, $_right); $replacement = sprintf('%s to %s', $_left, $_right);

View File

@ -27,7 +27,7 @@ function nlog($output, $context = []): void
} }
if (gettype($output) == 'object') { if (gettype($output) == 'object') {
$output = print_r($output, 1); $output = print_r($output, true);
} }
// $trace = debug_backtrace(); // $trace = debug_backtrace();
@ -53,7 +53,7 @@ function nrlog($output, $context = []): void
} }
if (gettype($output) == 'object') { if (gettype($output) == 'object') {
$output = print_r($output, 1); $output = print_r($output, true);
} }
// $trace = debug_backtrace(); // $trace = debug_backtrace();

View File

@ -267,7 +267,7 @@ class MigrationController extends BaseController
if ($request->companies) { if ($request->companies) {
//handle Laravel 5.5 UniHTTP //handle Laravel 5.5 UniHTTP
$companies = json_decode($request->companies, 1); $companies = json_decode($request->companies, true);
} else { } else {
//handle Laravel 6 Guzzle //handle Laravel 6 Guzzle
$companies = []; $companies = [];
@ -275,7 +275,7 @@ class MigrationController extends BaseController
foreach ($request->all() as $input) { foreach ($request->all() as $input) {
if ($input instanceof UploadedFile) { if ($input instanceof UploadedFile) {
} else { } else {
$companies[] = json_decode($input, 1); $companies[] = json_decode($input, true);
} }
} }
} }

View File

@ -288,7 +288,7 @@ class PreviewController extends BaseController
/** @var \App\Models\Company $company */ /** @var \App\Models\Company $company */
$company = $user->company(); $company = $user->company();
$design_object = json_decode(json_encode(request()->input('design')), 1); $design_object = json_decode(json_encode(request()->input('design')), true);
$ts = (new TemplateService()); $ts = (new TemplateService());

View File

@ -69,7 +69,7 @@ class StoreTaskRequest extends Request
foreach ($values as $k) { foreach ($values as $k) {
if (!is_int($k[0]) || !is_int($k[1])) { if (!is_int($k[0]) || !is_int($k[1])) {
return $fail('The '.$attribute.' - '.print_r($k, 1).' is invalid. Unix timestamps only.'); return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
} }
} }

View File

@ -75,7 +75,7 @@ class UpdateTaskRequest extends Request
foreach ($values as $k) { foreach ($values as $k) {
if (!is_int($k[0]) || !is_int($k[1])) { if (!is_int($k[0]) || !is_int($k[1])) {
return $fail('The '.$attribute.' - '.print_r($k, 1).' is invalid. Unix timestamps only.'); return $fail('The '.$attribute.' - '.print_r($k, true).' is invalid. Unix timestamps only.');
} }
} }

View File

@ -42,7 +42,7 @@ class ExpenseTransformer extends BaseTransformer
'client_id' => isset($data['expense.client']) 'client_id' => isset($data['expense.client'])
? $this->getClientId($data['expense.client']) ? $this->getClientId($data['expense.client'])
: null, : null,
'date' => strlen($this->getString($data, 'expense.date') > 1) ? $this->parseDate($data['expense.date']) : now()->format('Y-m-d'), 'date' => strlen($this->getString($data, 'expense.date')) > 1 ? $this->parseDate($data['expense.date']) : now()->format('Y-m-d'),
'public_notes' => $this->getString($data, 'expense.public_notes'), 'public_notes' => $this->getString($data, 'expense.public_notes'),
'private_notes' => $this->getString($data, 'expense.private_notes'), 'private_notes' => $this->getString($data, 'expense.private_notes'),
'category_id' => isset($data['expense.category']) 'category_id' => isset($data['expense.category'])

View File

@ -140,6 +140,6 @@ class UpdateOrCreateProduct implements ShouldQueue
public function failed($exception = null) public function failed($exception = null)
{ {
info('update create failed with = '); info('update create failed with = ');
info(print_r($exception->getMessage(), 1)); nlog($exception->getMessage());
} }
} }

View File

@ -202,6 +202,6 @@ class SendRecurring implements ShouldQueue
LightLogs::create($job_failure) LightLogs::create($job_failure)
->send(); ->send();
nlog(print_r($exception->getMessage(), 1)); nlog($exception->getMessage());
} }
} }

View File

@ -212,7 +212,7 @@ class Import implements ShouldQueue
$user->setCompany($this->company); $user->setCompany($this->company);
$array = json_decode(file_get_contents($this->file_path), 1); $array = json_decode(file_get_contents($this->file_path), true);
$data = $array['data']; $data = $array['data'];
foreach ($this->available_imports as $import) { foreach ($this->available_imports as $import) {
@ -2010,7 +2010,7 @@ class Import implements ShouldQueue
public function transformId($resource, string $old): int public function transformId($resource, string $old): int
{ {
if (! array_key_exists($resource, $this->ids)) { if (! array_key_exists($resource, $this->ids)) {
info(print_r($resource, 1)); nlog($resource);
throw new Exception("Resource {$resource} not available."); throw new Exception("Resource {$resource} not available.");
} }
@ -2067,11 +2067,10 @@ class Import implements ShouldQueue
LightLogs::create($job_failure) LightLogs::create($job_failure)
->queue(); ->queue();
nlog(print_r($exception->getMessage(), 1)); nlog($exception->getMessage());
// if (Ninja::isHosted()) {
app('sentry')->captureException($exception); app('sentry')->captureException($exception);
// }
} }

View File

@ -168,6 +168,6 @@ class StartMigration implements ShouldQueue
public function failed($exception = null) public function failed($exception = null)
{ {
info(print_r($exception->getMessage(), 1)); nlog($exception->getMessage());
} }
} }

View File

@ -199,7 +199,7 @@ class CreatePurchaseOrderPdf implements ShouldQueue
} }
} }
} catch (\Exception $e) { } catch (\Exception $e) {
nlog(print_r($e->getMessage(), 1)); nlog($e->getMessage());
} }
if (config('ninja.log_pdf_html')) { if (config('ninja.log_pdf_html')) {

View File

@ -87,7 +87,7 @@ class PaymentMigrationRepository extends BaseRepository
if (! array_key_exists('status_id', $data)) { if (! array_key_exists('status_id', $data)) {
info('payment with no status id?'); info('payment with no status id?');
info(print_r($data, 1)); info(print_r($data, true));
} }
$payment->status_id = $data['status_id']; $payment->status_id = $data['status_id'];

View File

@ -130,7 +130,7 @@ class SubscriptionRepository extends BaseRepository
private function convertV3Bundle($bundle): array private function convertV3Bundle($bundle): array
{ {
if(is_object($bundle)) { if(is_object($bundle)) {
$bundle = json_decode(json_encode($bundle), 1); $bundle = json_decode(json_encode($bundle), true);
} }
$items = []; $items = [];

View File

@ -386,7 +386,7 @@ class PdfConfiguration
$decimal = $this->country->decimal_separator; $decimal = $this->country->decimal_separator;
} }
if (isset($this->country->swap_currency_symbol) && strlen($this->country->swap_currency_symbol) >= 1) { if (isset($this->country->swap_currency_symbol) && $this->country->swap_currency_symbol == 1) {
$swapSymbol = $this->country->swap_currency_symbol; $swapSymbol = $this->country->swap_currency_symbol;
} }

View File

@ -102,7 +102,7 @@ class PdfService
} }
} catch (\Exception $e) { } catch (\Exception $e) {
nlog(print_r($e->getMessage(), 1)); nlog($e->getMessage());
throw new \Exception($e->getMessage(), $e->getCode()); throw new \Exception($e->getMessage(), $e->getCode());
} }

View File

@ -279,7 +279,7 @@ class Helpers
$_value = explode($_operation, $right); // [MONTHYEAR, 4] $_value = explode($_operation, $right); // [MONTHYEAR, 4]
$_right = Carbon::createFromDate($currentDateTime->year, $currentDateTime->month)->addMonths($_value[1])->translatedFormat('F Y'); $_right = Carbon::createFromDate($currentDateTime->year, $currentDateTime->month)->addMonths($_value[1])->translatedFormat('F Y'); //@phpstan-ignore-line
} }
$replacement = sprintf('%s to %s', $_left, $_right); $replacement = sprintf('%s to %s', $_left, $_right);

View File

@ -255,7 +255,7 @@ class Number
$decimal = $country->decimal_separator; $decimal = $country->decimal_separator;
} }
if (isset($country->swap_currency_symbol) && strlen($country->swap_currency_symbol) >= 1) { if (isset($country->swap_currency_symbol) && $country->swap_currency_symbol == 1) {
$swapSymbol = $country->swap_currency_symbol; $swapSymbol = $country->swap_currency_symbol;
} }

View File

@ -20,8 +20,8 @@ trait PdfMaker
/** /**
* Returns a PDF stream. * Returns a PDF stream.
* *
* @param string $header Header to be included in PDF * @param string|null $header Header to be included in PDF
* @param string $footer Footer to be included in PDF * @param string|null $footer Footer to be included in PDF
* @param string $html The HTML object to be converted into PDF * @param string $html The HTML object to be converted into PDF
* *
* @return string The PDF string * @return string The PDF string

View File

@ -3,7 +3,7 @@ includes:
- ./vendor/spaze/phpstan-stripe/extension.neon - ./vendor/spaze/phpstan-stripe/extension.neon
- phpstan-baseline.neon - phpstan-baseline.neon
parameters: parameters:
level: 4 level: 5
paths: paths:
- app - app
excludePaths: excludePaths: