From 3035a7bc7fe4f9bbc2ddd24bb344c0c2f61ee98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 7 Mar 2024 22:13:09 +0100 Subject: [PATCH] fix phpstan (#28695) * fix phpstan * fix typo * fix phpstan * fix phpstan * fix phpstan --- htdocs/core/class/dolreceiptprinter.class.php | 16 +++++++++++++--- htdocs/langs/en_US/receiptprinter.lang | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 0efd7b5a923..4d8c8b0f785 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2024 Frédéric France * Copyright (C) 2020 Andreu Bisquerra * * This program is free software; you can redistribute it and/or modify @@ -133,6 +133,10 @@ class dolReceiptPrinter extends Printer * @var string[] array of tags */ public $tags; + + /** + * @var \Mike42\Escpos\Printer + */ public $printer; public $template; @@ -1033,6 +1037,7 @@ class dolReceiptPrinter extends Printer try { $type = $obj['fk_type']; + $found = true; switch ($type) { case 1: $this->connector = new DummyPrintConnector(); @@ -1051,10 +1056,15 @@ class dolReceiptPrinter extends Printer $this->connector = new CupsPrintConnector($parameter); break; default: - $this->connector = 'CONNECTOR_UNKNOWN'; + $found = false;; break; } - $this->printer = new Printer($this->connector, $this->profile); + if ($found) { + $this->printer = new Printer($this->connector, $this->profile); + } else { + $error++; + $this->errors[] = 'CONNECTOR_UNKNOWN'; + } } catch (Exception $e) { $this->errors[] = $e->getMessage(); $error++; diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 28bf2c4f1d5..3cb8275383c 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -12,6 +12,8 @@ ReceiptPrinterProfileDesc=Description of Receipt Printer's Profile ListPrinters=List of Printers FromServerPointOfView=From the web server point of view. This method must be reachable from the web server hosting. SetupReceiptTemplate=Template Setup +PrinterNameEmpty=Printer name is empty +PrinterParameterEmpty=Printer parameters are empty CONNECTOR_DUMMY=Dummy Printer CONNECTOR_NETWORK_PRINT=Network Printer CONNECTOR_FILE_PRINT=Local Printer