From df3f4c7a2160d3e6b3e20fa21b3fbdd570b0c5b1 Mon Sep 17 00:00:00 2001 From: robmachado Date: Wed, 12 Jun 2024 09:42:01 -0300 Subject: [PATCH] Ajustes phpstan --- phpstan-baseline.neon | 4 ---- src/Common/Tools.php | 6 +++--- src/Traits/TraitEPECNfce.php | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6e466977..42432bbf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -30,8 +30,4 @@ parameters: count: 1 path: src/Exception/DocumentsException.php - - - message: "#^Variable \\$tpEmis might not be defined\\.$#" - count: 1 - path: src/Factories/Contingency.php diff --git a/src/Common/Tools.php b/src/Common/Tools.php index b33b758a..3e3dd7bf 100755 --- a/src/Common/Tools.php +++ b/src/Common/Tools.php @@ -60,9 +60,9 @@ class Tools public $tpAmb = 2; /** * contingency class - * @var Contingency + * @var Contingency|null */ - public $contingency; + public $contingency = null; /** * soap class * @var ?SoapInterface @@ -395,7 +395,7 @@ protected function isValid(string $version, string $body, string $method): bool */ protected function checkContingencyForWebServices(string $service) { - $type = $this->contingency->type ?? null; + $type = !empty($this->contingency) ? $this->contingency->type : ''; $mod = $this->modelo; if (!empty($type)) { if ($this->modelo == 65) { diff --git a/src/Traits/TraitEPECNfce.php b/src/Traits/TraitEPECNfce.php index e8517155..aeefa0d2 100644 --- a/src/Traits/TraitEPECNfce.php +++ b/src/Traits/TraitEPECNfce.php @@ -70,7 +70,7 @@ public function sefazEpecNfce(string &$xml, string $verAplic = null): string $dom->loadXML($xml); $infNFe = $dom->getElementsByTagName('infNFe')->item(0); $ide = $dom->getElementsByTagName('ide')->item(0); - $tpEmis = (int) $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue ?? 0; + $tpEmis = (int) $ide->getElementsByTagName('tpEmis')->item(0)->nodeValue; $dhCont = $ide->getElementsByTagName('dhCont')->item(0)->nodeValue ?? ''; $xJust = $ide->getElementsByTagName('xJust')->item(0)->nodeValue ?? ''; if ($tpEmis !== 4 || empty($dhCont) || empty($xJust)) {