From d8da1f8fea13ac36e62dc14000a4ec80ad9db719 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 26 Apr 2023 20:24:10 +1000 Subject: [PATCH] Static analysis cleanup --- app/Helpers/Invoice/InvoiceItemSum.php | 6 ++--- app/Helpers/Invoice/InvoiceSum.php | 3 ++- app/Http/Controllers/SelfUpdateController.php | 26 ------------------- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 3b55c81138..4a8348b8c9 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -108,9 +108,9 @@ class InvoiceItemSum $this->line_items = []; } - public function process() + public function process(): self { - if (! $this->invoice->line_items || ! is_array($this->invoice->line_items) || count($this->invoice->line_items) == 0) { + if (!$this->invoice->line_items || !is_array($this->invoice->line_items)) { $this->items = []; return $this; @@ -121,7 +121,7 @@ class InvoiceItemSum return $this; } - private function calcLineItems() + private function calcLineItems(): self { foreach ($this->invoice->line_items as $this->item) { $this->cleanLineItem() diff --git a/app/Helpers/Invoice/InvoiceSum.php b/app/Helpers/Invoice/InvoiceSum.php index 9bf0b7e7cb..5097fac0c2 100644 --- a/app/Helpers/Invoice/InvoiceSum.php +++ b/app/Helpers/Invoice/InvoiceSum.php @@ -16,6 +16,7 @@ use App\Utils\Number; use App\Models\Credit; use App\Models\Invoice; use App\Models\PurchaseOrder; +use App\Models\RecurringQuote; use App\Models\RecurringInvoice; use Illuminate\Support\Collection; use App\Utils\Traits\NumberFormatter; @@ -27,7 +28,7 @@ class InvoiceSum use Discounter; use NumberFormatter; - protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder $invoice; + protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice; public $tax_map; diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index c7cdb99881..fcd642c284 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -99,9 +99,6 @@ class SelfUpdateController extends BaseController nlog('Extracting zip'); - //clean up old snappdf installations - //$this->cleanOldSnapChromeBinaries(); - $zipFile = new \PhpZip\ZipFile(); $zipFile->openFile($file); @@ -144,29 +141,6 @@ class SelfUpdateController extends BaseController return response()->json(['message' => 'Update completed'], 200); } - private function cleanOldSnapChromeBinaries() - { - $current_revision = base_path('vendor/beganovich/snappdf/versions/revision.txt'); - $current_revision_text = file_get_contents($current_revision); - - $iterator = new \DirectoryIterator(base_path('vendor/beganovich/snappdf/versions')); - - foreach ($iterator as $file) { - if ($file->isDir() && ! $file->isDot() && ($current_revision_text != $file->getFileName())) { - $directoryIterator = new \RecursiveDirectoryIterator(base_path('vendor/beganovich/snappdf/versions/'.$file->getFileName()), \RecursiveDirectoryIterator::SKIP_DOTS); - - foreach (new \RecursiveIteratorIterator($directoryIterator) as $filex) { - unlink($filex->getPathName()); - } - - $this->deleteDirectory(base_path('vendor/beganovich/snappdf/versions/'.$file->getFileName())); - } - } - - $iterator = null; - - } - private function deleteDirectory($dir) { if (! file_exists($dir)) {