From 5bd939b9cc876cc56b165102f1b8a09e691e44f9 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 4 Mar 2025 14:05:11 -0600 Subject: [PATCH 01/23] Update development tools --- .phive/phars.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 0028181..38968b0 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,8 +1,8 @@ - - - - - + + + + + From edbd7d688d41fbb3f62d854fa58b4bfe83634fd1 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Tue, 4 Mar 2025 14:05:01 -0600 Subject: [PATCH 02/23] Fix PHPStan issues level 10 --- src/Finkok.php | 1 + src/Helpers/AcceptRejectSigner.php | 5 +- src/Helpers/GetRelatedSigner.php | 5 +- src/Internal/MethodsFilterVariablesTrait.php | 60 +++++++++++++++++++ src/Services/AbstractResult.php | 5 +- .../Cancel/AcceptRejectSignatureResult.php | 7 ++- src/Services/Cancel/AcceptRejectUuidList.php | 13 ++-- src/Services/Cancel/CancelSignatureResult.php | 5 +- src/Services/Cancel/CancelledDocument.php | 5 +- src/Services/Cancel/CancelledDocuments.php | 4 -- src/Services/Cancel/GetPendingResult.php | 8 +-- .../Cancel/GetRelatedSignatureResult.php | 7 ++- src/Services/Cancel/RelatedItems.php | 13 ++-- src/Services/Manifest/GetContractsResult.php | 4 +- src/Services/Registration/Customer.php | 5 +- src/Services/Registration/Customers.php | 4 -- .../Registration/ObtainCustomersResult.php | 5 +- src/Services/Registration/ObtainResult.php | 5 +- src/Services/Stamping/StampingAlert.php | 5 +- src/Services/Stamping/StampingAlerts.php | 4 -- src/Services/Stamping/StampingResult.php | 5 +- src/Services/Utilities/ReportCreditResult.php | 14 +++-- src/Services/Utilities/ReportTotalResult.php | 7 ++- src/Services/Utilities/ReportUuidResult.php | 14 +++-- .../Services/Cancel/GetPendingServiceTest.php | 3 +- .../Manifest/GetContractsServiceTest.php | 4 +- .../Registration/AssignServiceTest.php | 1 + tests/TestCase.php | 3 +- tests/Unit/FinkokTest.php | 8 +-- tests/Unit/Helpers/DocumentSignerTest.php | 3 +- tests/Unit/Helpers/JsonDecoderLoggerTest.php | 6 +- .../Services/Registration/CustomersTest.php | 4 +- .../Services/Stamping/StampingAlertsTest.php | 5 +- 33 files changed, 168 insertions(+), 79 deletions(-) create mode 100644 src/Internal/MethodsFilterVariablesTrait.php diff --git a/src/Finkok.php b/src/Finkok.php index fd04ae2..c7069b8 100644 --- a/src/Finkok.php +++ b/src/Finkok.php @@ -42,6 +42,7 @@ */ class Finkok { + /** @var array */ protected const SERVICES_MAP = [ 'stamp' => [Stamping\StampService::class, Stamping\StampingCommand::class], 'quickstamp' => [Stamping\QuickStampService::class, Stamping\StampingCommand::class], diff --git a/src/Helpers/AcceptRejectSigner.php b/src/Helpers/AcceptRejectSigner.php index ca04427..3faf115 100644 --- a/src/Helpers/AcceptRejectSigner.php +++ b/src/Helpers/AcceptRejectSigner.php @@ -12,6 +12,7 @@ class AcceptRejectSigner { + /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; /** @var string */ @@ -31,8 +32,8 @@ class AcceptRejectSigner * * @param string $uuid * @param CancelAnswer $answer - * @param DateTimeImmutable|null $dateTime If null or ommited then use current time and time zone - * @param string $pacRfc If empty or ommited then uses DEFAULT_PACRFC + * @param DateTimeImmutable|null $dateTime If null or omitted then use current time and time zone + * @param string $pacRfc If empty or omitted then uses DEFAULT_PACRFC */ public function __construct( string $uuid, diff --git a/src/Helpers/GetRelatedSigner.php b/src/Helpers/GetRelatedSigner.php index d708341..aadf341 100644 --- a/src/Helpers/GetRelatedSigner.php +++ b/src/Helpers/GetRelatedSigner.php @@ -11,6 +11,7 @@ class GetRelatedSigner { + /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; /** @var string */ @@ -26,8 +27,8 @@ class GetRelatedSigner * GetRelatedSigner constructor. * * @param string $uuid - * @param RfcRole|null $role If null or ommited then uses issuer role - * @param string $pacRfc If empty or ommited then uses DEFAULT_PACRFC + * @param RfcRole|null $role If null or omitted then uses issuer role + * @param string $pacRfc If empty or omitted then uses DEFAULT_PACRFC */ public function __construct(string $uuid, RfcRole $role = null, string $pacRfc = self::DEFAULT_PACRFC) { diff --git a/src/Internal/MethodsFilterVariablesTrait.php b/src/Internal/MethodsFilterVariablesTrait.php new file mode 100644 index 0000000..c25209d --- /dev/null +++ b/src/Internal/MethodsFilterVariablesTrait.php @@ -0,0 +1,60 @@ + + */ + private function filterArrayOfStdClass($variable): array + { + if (! is_array($variable)) { + return []; + } + $result = []; + foreach ($variable as $index => $item) { + if (! $item instanceof stdClass) { + return []; + } + $result[$index] = $item; + } + return $result; + } + + /** + * @param mixed $variable + * @return array + */ + private function filterArrayOfStrings($variable): array + { + if (! is_array($variable)) { + return []; + } + $result = []; + foreach ($variable as $index => $item) { + if (! is_string($item)) { + return []; + } + $result[$index] = $item; + } + return $result; + } + + /** + * @param mixed $variable + * @return string + */ + private function filterString($variable): string + { + if (! is_scalar($variable)) { + return ''; + } + return strval($variable); + } +} diff --git a/src/Services/AbstractResult.php b/src/Services/AbstractResult.php index 03dad6d..257df7c 100644 --- a/src/Services/AbstractResult.php +++ b/src/Services/AbstractResult.php @@ -5,10 +5,13 @@ namespace PhpCfdi\Finkok\Services; use InvalidArgumentException; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use stdClass; abstract class AbstractResult { + use MethodsFilterVariablesTrait; + /** @var stdClass */ protected $data; @@ -54,6 +57,6 @@ protected function findInDescendent($haystack, string ...$location) protected function get(string $keyword): string { - return strval($this->root->{$keyword} ?? ''); + return $this->filterString($this->root->{$keyword} ?? ''); } } diff --git a/src/Services/Cancel/AcceptRejectSignatureResult.php b/src/Services/Cancel/AcceptRejectSignatureResult.php index 553f86a..4fdfa1d 100644 --- a/src/Services/Cancel/AcceptRejectSignatureResult.php +++ b/src/Services/Cancel/AcceptRejectSignatureResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Cancel; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class AcceptRejectSignatureResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var AcceptRejectUuidList */ private $uuids; @@ -23,8 +26,8 @@ public function __construct(stdClass $data) $rechazo = $this->findInDescendent($data, $container, 'rechazo'); $this->uuids = new AcceptRejectUuidList( array_merge( - is_array($aceptacion) ? $aceptacion : [], - is_array($rechazo) ? $rechazo : [] + $this->filterArrayOfStdClass($aceptacion), + $this->filterArrayOfStdClass($rechazo), ) ); $this->error = $this->get('error'); diff --git a/src/Services/Cancel/AcceptRejectUuidList.php b/src/Services/Cancel/AcceptRejectUuidList.php index 2ac734f..e181fa2 100644 --- a/src/Services/Cancel/AcceptRejectUuidList.php +++ b/src/Services/Cancel/AcceptRejectUuidList.php @@ -4,20 +4,19 @@ namespace PhpCfdi\Finkok\Services\Cancel; -use ArrayIterator; use OutOfRangeException; use PhpCfdi\Finkok\Definitions\CancelAnswer; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractCollection; use stdClass; /** - * @method AcceptRejectUuidItem get(int $index) - * @method AcceptRejectUuidItem first() - * @method ArrayIterator|AcceptRejectUuidItem[] getIterator() * @extends AbstractCollection */ class AcceptRejectUuidList extends AbstractCollection { + use MethodsFilterVariablesTrait; + public function findByUuidOrFail(string $uuid): AcceptRejectUuidItem { $found = $this->findByUuid($uuid); @@ -40,9 +39,11 @@ public function findByUuid(string $uuid): ?AcceptRejectUuidItem protected function createItemFromStdClass(stdClass $content): object { if (isset($content->{'Acepta'})) { + /** @var stdClass $source */ $source = $content->{'Acepta'}; $answer = CancelAnswer::accept(); } elseif (isset($content->{'Rechaza'})) { + /** @var stdClass $source */ $source = $content->{'Rechaza'}; $answer = CancelAnswer::reject(); } else { @@ -50,8 +51,8 @@ protected function createItemFromStdClass(stdClass $content): object $answer = CancelAnswer::accept(); } return new AcceptRejectUuidItem( - strval($source->uuid ?? ''), - new AcceptRejectUuidStatus($source->status ?? '0'), + $this->filterString($source->uuid ?? ''), + new AcceptRejectUuidStatus($this->filterString($source->status ?? '0')), $answer ); } diff --git a/src/Services/Cancel/CancelSignatureResult.php b/src/Services/Cancel/CancelSignatureResult.php index 319c698..e308b27 100644 --- a/src/Services/Cancel/CancelSignatureResult.php +++ b/src/Services/Cancel/CancelSignatureResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Cancel; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class CancelSignatureResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var CancelledDocuments */ private $documents; @@ -16,7 +19,7 @@ public function __construct(stdClass $data) { parent::__construct($data, 'cancel_signatureResult'); $documents = $this->findInDescendent($data, 'cancel_signatureResult', 'Folios', 'Folio'); - $this->documents = new CancelledDocuments(is_array($documents) ? $documents : []); + $this->documents = new CancelledDocuments($this->filterArrayOfStdClass($documents)); } public function documents(): CancelledDocuments diff --git a/src/Services/Cancel/CancelledDocument.php b/src/Services/Cancel/CancelledDocument.php index 94c5473..7faa07b 100644 --- a/src/Services/Cancel/CancelledDocument.php +++ b/src/Services/Cancel/CancelledDocument.php @@ -4,10 +4,13 @@ namespace PhpCfdi\Finkok\Services\Cancel; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use stdClass; class CancelledDocument { + use MethodsFilterVariablesTrait; + /** @var stdClass */ private $data; @@ -18,7 +21,7 @@ public function __construct(stdClass $raw) private function get(string $keyword): string { - return strval($this->data->{$keyword} ?? ''); + return $this->filterString($this->data->{$keyword} ?? ''); } public function uuid(): string diff --git a/src/Services/Cancel/CancelledDocuments.php b/src/Services/Cancel/CancelledDocuments.php index 07e9825..5afcf4d 100644 --- a/src/Services/Cancel/CancelledDocuments.php +++ b/src/Services/Cancel/CancelledDocuments.php @@ -4,14 +4,10 @@ namespace PhpCfdi\Finkok\Services\Cancel; -use ArrayIterator; use PhpCfdi\Finkok\Services\AbstractCollection; use stdClass; /** - * @method CancelledDocument get(int $index) - * @method CancelledDocument first() - * @method ArrayIterator|CancelledDocument[] getIterator() * @extends AbstractCollection */ class CancelledDocuments extends AbstractCollection diff --git a/src/Services/Cancel/GetPendingResult.php b/src/Services/Cancel/GetPendingResult.php index a1ea2a4..2fb8af0 100644 --- a/src/Services/Cancel/GetPendingResult.php +++ b/src/Services/Cancel/GetPendingResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Cancel; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class GetPendingResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var string[] */ private $uuids; @@ -16,10 +19,7 @@ public function __construct(stdClass $data) { parent::__construct($data, 'get_pendingResult'); $items = $this->findInDescendent($data, 'get_pendingResult', 'uuids', 'string') ?? []; - if (! is_array($items)) { - $items = []; - } - $this->uuids = $items; + $this->uuids = $this->filterArrayOfStrings($items); } /** @return string[] */ diff --git a/src/Services/Cancel/GetRelatedSignatureResult.php b/src/Services/Cancel/GetRelatedSignatureResult.php index 8a3abc9..b8f7220 100644 --- a/src/Services/Cancel/GetRelatedSignatureResult.php +++ b/src/Services/Cancel/GetRelatedSignatureResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Cancel; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class GetRelatedSignatureResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var RelatedItems */ private $parents; @@ -23,9 +26,9 @@ public function __construct(stdClass $data) $container = 'get_related_signatureResult'; parent::__construct($data, $container); $parents = $this->findInDescendent($data, $container, 'Padres', 'Padre'); - $this->parents = new RelatedItems(is_array($parents) ? $parents : []); + $this->parents = new RelatedItems($this->filterArrayOfStdClass($parents)); $children = $this->findInDescendent($data, $container, 'Hijos', 'Hijo'); - $this->children = new RelatedItems(is_array($children) ? $children : []); + $this->children = new RelatedItems($this->filterArrayOfStdClass($children)); $this->error = $this->get('error'); } diff --git a/src/Services/Cancel/RelatedItems.php b/src/Services/Cancel/RelatedItems.php index 5f0484b..2990837 100644 --- a/src/Services/Cancel/RelatedItems.php +++ b/src/Services/Cancel/RelatedItems.php @@ -4,24 +4,23 @@ namespace PhpCfdi\Finkok\Services\Cancel; -use ArrayIterator; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractCollection; use stdClass; /** - * @method RelatedItem get(int $index) - * @method RelatedItem first() - * @method ArrayIterator|RelatedItem[] getIterator() * @extends AbstractCollection */ class RelatedItems extends AbstractCollection { + use MethodsFilterVariablesTrait; + protected function createItemFromStdClass(stdClass $content): object { return new RelatedItem( - strval($content->{'uuid'} ?? ''), - strval($content->{'emisor'} ?? ''), - strval($content->{'receptor'} ?? '') + $this->filterString($content->{'uuid'} ?? ''), + $this->filterString($content->{'emisor'} ?? ''), + $this->filterString($content->{'receptor'} ?? '') ); } } diff --git a/src/Services/Manifest/GetContractsResult.php b/src/Services/Manifest/GetContractsResult.php index f910fe5..37e31b2 100644 --- a/src/Services/Manifest/GetContractsResult.php +++ b/src/Services/Manifest/GetContractsResult.php @@ -33,12 +33,12 @@ public function success(): bool public function contract(): string { - return base64_decode($this->get('contract'), true) ?: ''; + return (string) base64_decode($this->get('contract'), true); } public function privacy(): string { - return base64_decode($this->get('privacy'), true) ?: ''; + return (string) base64_decode($this->get('privacy'), true); } public function error(): string diff --git a/src/Services/Registration/Customer.php b/src/Services/Registration/Customer.php index 68524d3..dd29c23 100644 --- a/src/Services/Registration/Customer.php +++ b/src/Services/Registration/Customer.php @@ -4,10 +4,13 @@ namespace PhpCfdi\Finkok\Services\Registration; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use stdClass; class Customer { + use MethodsFilterVariablesTrait; + /** @var stdClass */ private $data; @@ -31,7 +34,7 @@ public function __construct(stdClass $raw) private function get(string $keyword): string { - return strval($this->data->{$keyword} ?? ''); + return $this->filterString($this->data->{$keyword} ?? ''); } public function status(): CustomerStatus diff --git a/src/Services/Registration/Customers.php b/src/Services/Registration/Customers.php index 3cc041e..750862c 100644 --- a/src/Services/Registration/Customers.php +++ b/src/Services/Registration/Customers.php @@ -4,15 +4,11 @@ namespace PhpCfdi\Finkok\Services\Registration; -use ArrayIterator; use LogicException; use PhpCfdi\Finkok\Services\AbstractCollection; use stdClass; /** - * @method Customer get(int $index) - * @method Customer first() - * @method ArrayIterator|Customer[] getIterator() * @extends AbstractCollection */ class Customers extends AbstractCollection diff --git a/src/Services/Registration/ObtainCustomersResult.php b/src/Services/Registration/ObtainCustomersResult.php index c98a22d..c97fd47 100644 --- a/src/Services/Registration/ObtainCustomersResult.php +++ b/src/Services/Registration/ObtainCustomersResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Registration; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; final class ObtainCustomersResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var Customers */ private $customers; @@ -16,7 +19,7 @@ public function __construct(stdClass $data) { parent::__construct($data, 'customersResult'); $customers = $this->findInDescendent($data, 'customersResult', 'users', 'ResellerUser'); - $this->customers = new Customers(is_array($customers) ? $customers : []); + $this->customers = new Customers($this->filterArrayOfStdClass($customers)); } public function message(): string diff --git a/src/Services/Registration/ObtainResult.php b/src/Services/Registration/ObtainResult.php index 5dd5b86..b551505 100644 --- a/src/Services/Registration/ObtainResult.php +++ b/src/Services/Registration/ObtainResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Registration; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class ObtainResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var Customers */ private $customers; @@ -16,7 +19,7 @@ public function __construct(stdClass $data) { parent::__construct($data, 'getResult'); $customers = $this->findInDescendent($data, 'getResult', 'users', 'ResellerUser'); - $this->customers = new Customers(is_array($customers) ? $customers : []); + $this->customers = new Customers($this->filterArrayOfStdClass($customers)); } public function message(): string diff --git a/src/Services/Stamping/StampingAlert.php b/src/Services/Stamping/StampingAlert.php index 54d895d..f25ed63 100644 --- a/src/Services/Stamping/StampingAlert.php +++ b/src/Services/Stamping/StampingAlert.php @@ -4,10 +4,13 @@ namespace PhpCfdi\Finkok\Services\Stamping; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use stdClass; class StampingAlert { + use MethodsFilterVariablesTrait; + /** @var stdClass */ private $data; @@ -18,7 +21,7 @@ public function __construct(stdClass $raw) private function get(string $keyword): string { - return strval($this->data->{$keyword} ?? ''); + return $this->filterString($this->data->{$keyword} ?? ''); } public function id(): string diff --git a/src/Services/Stamping/StampingAlerts.php b/src/Services/Stamping/StampingAlerts.php index ecc8298..38bebee 100644 --- a/src/Services/Stamping/StampingAlerts.php +++ b/src/Services/Stamping/StampingAlerts.php @@ -4,14 +4,10 @@ namespace PhpCfdi\Finkok\Services\Stamping; -use ArrayIterator; use PhpCfdi\Finkok\Services\AbstractCollection; use stdClass; /** - * @method StampingAlert get(int $index) - * @method StampingAlert first() - * @method ArrayIterator|StampingAlert[] getIterator() * @extends AbstractCollection */ class StampingAlerts extends AbstractCollection diff --git a/src/Services/Stamping/StampingResult.php b/src/Services/Stamping/StampingResult.php index 0f2e44e..e9c7ba6 100644 --- a/src/Services/Stamping/StampingResult.php +++ b/src/Services/Stamping/StampingResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Stamping; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class StampingResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var StampingAlerts */ private $alerts; @@ -16,7 +19,7 @@ public function __construct(string $container, stdClass $data) { parent::__construct($data, $container); $alerts = $this->findInDescendent($data, $container, 'Incidencias', 'Incidencia'); - $this->alerts = new StampingAlerts(is_array($alerts) ? $alerts : []); + $this->alerts = new StampingAlerts($this->filterArrayOfStdClass($alerts)); } public function xml(): string diff --git a/src/Services/Utilities/ReportCreditResult.php b/src/Services/Utilities/ReportCreditResult.php index aca150b..bc1d071 100644 --- a/src/Services/Utilities/ReportCreditResult.php +++ b/src/Services/Utilities/ReportCreditResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Utilities; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class ReportCreditResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var array */ private $items; @@ -17,14 +20,13 @@ public function __construct(stdClass $data) parent::__construct($data, 'report_creditResult'); $this->items = []; - $items = $this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit'); - if (! is_array($items)) { - $items = []; - } + $items = $this->filterArrayOfStdClass( + $this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit') + ); foreach ($items as $item) { $this->items[] = [ - 'credit' => strval($item->credit), - 'date' => strval($item->date), + 'credit' => $this->filterString($item->credit), + 'date' => $this->filterString($item->date), ]; } } diff --git a/src/Services/Utilities/ReportTotalResult.php b/src/Services/Utilities/ReportTotalResult.php index 9468d05..782c1d8 100644 --- a/src/Services/Utilities/ReportTotalResult.php +++ b/src/Services/Utilities/ReportTotalResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Utilities; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class ReportTotalResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var string */ private $rfc; @@ -24,8 +27,8 @@ public function __construct(stdClass $data) /** @var array{stdClass|null} $items */ $items = $this->findInDescendent($data, 'report_totalResult', 'result', 'ReportTotal') ?? []; $result = $items[0] ?? (object) []; - $this->rfc = $result->taxpayer_id ?? ''; - $this->total = strval($result->total ?? ''); + $this->rfc = $this->filterString($result->taxpayer_id ?? ''); + $this->total = $this->filterString($result->total ?? ''); $this->error = $this->get('error'); } diff --git a/src/Services/Utilities/ReportUuidResult.php b/src/Services/Utilities/ReportUuidResult.php index 6d71ff0..2952f3c 100644 --- a/src/Services/Utilities/ReportUuidResult.php +++ b/src/Services/Utilities/ReportUuidResult.php @@ -4,11 +4,14 @@ namespace PhpCfdi\Finkok\Services\Utilities; +use PhpCfdi\Finkok\Internal\MethodsFilterVariablesTrait; use PhpCfdi\Finkok\Services\AbstractResult; use stdClass; class ReportUuidResult extends AbstractResult { + use MethodsFilterVariablesTrait; + /** @var array */ private $items; @@ -17,14 +20,13 @@ public function __construct(stdClass $data) parent::__construct($data, 'report_uuidResult'); $this->items = []; - $items = $this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID'); - if (! is_array($items)) { - $items = []; - } + $items = $this->filterArrayOfStdClass( + $this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID') + ); foreach ($items as $item) { $this->items[] = [ - 'date' => strval($item->date), - 'uuid' => strval($item->uuid), + 'date' => $this->filterString($item->date), + 'uuid' => $this->filterString($item->uuid), ]; } } diff --git a/tests/Integration/Services/Cancel/GetPendingServiceTest.php b/tests/Integration/Services/Cancel/GetPendingServiceTest.php index a6a52d6..0d94b4e 100644 --- a/tests/Integration/Services/Cancel/GetPendingServiceTest.php +++ b/tests/Integration/Services/Cancel/GetPendingServiceTest.php @@ -15,13 +15,12 @@ public function testConsumeService(): void // Cannot check anything else than it did not return an error // It might be possible to create a test that ask for a cancellation that require authorization // but this is simply unpractical for *this* test suite because - // it takes around 16 minutes to have a CFDI with status "cancelable con autorizacion" + // it takes around 16 minutes to have a CFDI with status "cancelable con autorización" $settings = $this->createSettingsFromEnvironment(); $command = new GetPendingCommand('EKU9003173C9'); $service = new GetPendingService($settings); $result = $service->obtainPending($command); - $this->assertTrue(is_array($result->uuids())); $this->assertSame('', $result->error()); } } diff --git a/tests/Integration/Services/Manifest/GetContractsServiceTest.php b/tests/Integration/Services/Manifest/GetContractsServiceTest.php index a2ac662..17748c0 100644 --- a/tests/Integration/Services/Manifest/GetContractsServiceTest.php +++ b/tests/Integration/Services/Manifest/GetContractsServiceTest.php @@ -37,8 +37,8 @@ public function testObtainContracts(): void $privacy = $result->privacy(); $contract = $result->contract(); - $this->assertNotEmpty($privacy, 'Cannot decode privacy statement'); - $this->assertNotEmpty($contract, 'Cannot decode contract statement'); + $this->assertNotSame('', $privacy, 'Cannot decode privacy statement'); + $this->assertNotSame('', $contract, 'Cannot decode contract statement'); $this->assertStringContainsString($command->rfc(), $contract); $this->assertStringContainsString($command->name(), $contract); // on the new manifest with Quadrum it does not include email or address diff --git a/tests/Integration/Services/Registration/AssignServiceTest.php b/tests/Integration/Services/Registration/AssignServiceTest.php index 0c430a0..287223d 100644 --- a/tests/Integration/Services/Registration/AssignServiceTest.php +++ b/tests/Integration/Services/Registration/AssignServiceTest.php @@ -15,6 +15,7 @@ final class AssignServiceTest extends RegistrationIntegrationTestCase { protected function staticSettings(): FinkokSettings { + /** @var FinkokSettings|null $settings */ static $settings = null; if (null === $settings) { $settings = $this->createSettingsFromEnvironment(); diff --git a/tests/TestCase.php b/tests/TestCase.php index a1baeec..1808ef5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -75,6 +75,7 @@ public static function fileContent(string $path): string public static function getenv(string $key): string { - return $_ENV[$key] ?? ''; + $value = $_ENV[$key] ?? ''; + return (is_scalar($value)) ? strval($value) : ''; } } diff --git a/tests/Unit/FinkokTest.php b/tests/Unit/FinkokTest.php index dabe1f4..c23e0a5 100644 --- a/tests/Unit/FinkokTest.php +++ b/tests/Unit/FinkokTest.php @@ -29,10 +29,10 @@ public function testConstructor(): void public function testInvokingOneMappedMagicMethod(): void { - /** @var StampingResult $result */ + /** @var StampingResult&MockObject $result */ $result = $this->createMock(StampingResult::class); - /** @var StampingCommand $command */ + /** @var StampingCommand&MockObject $command */ $command = $this->createMock(StampingCommand::class); /** @var FinkokSettings&MockObject $settings */ @@ -110,9 +110,9 @@ public function exposedExecuteService(string $method, object $service, ?object $ public function testInvokingOneMappedMagicMethodWithDifferentName(): void { - /** @var GetContractsResult $result */ + /** @var GetContractsResult&MockObject $result */ $result = $this->createMock(GetContractsResult::class); - /** @var GetContractsCommand $command */ + /** @var GetContractsCommand&MockObject $command */ $command = $this->createMock(GetContractsCommand::class); /** @var GetContractsService&MockObject $service */ $service = $this->createMock(GetContractsService::class); diff --git a/tests/Unit/Helpers/DocumentSignerTest.php b/tests/Unit/Helpers/DocumentSignerTest.php index b8e511c..d328a11 100644 --- a/tests/Unit/Helpers/DocumentSignerTest.php +++ b/tests/Unit/Helpers/DocumentSignerTest.php @@ -10,6 +10,7 @@ use PhpCfdi\Credentials\Credential; use PhpCfdi\Finkok\Helpers\DocumentSigner; use PhpCfdi\Finkok\Tests\TestCase; +use PHPUnit\Framework\MockObject\MockObject; final class DocumentSignerTest extends TestCase { @@ -42,7 +43,7 @@ public function testSignDocumentUsingCredentialWithoutRootElement(): void $content = 'Lorem Ipsum'; $docSigner = new DocumentSigner($rfc, $date, $content); - /** @var Credential $credential */ + /** @var Credential&MockObject $credential */ $credential = $this->createMock(Credential::class); $documentWithoutRootElement = new DOMDocument(); $this->expectException(LogicException::class); diff --git a/tests/Unit/Helpers/JsonDecoderLoggerTest.php b/tests/Unit/Helpers/JsonDecoderLoggerTest.php index 0c8f631..cc7d57d 100644 --- a/tests/Unit/Helpers/JsonDecoderLoggerTest.php +++ b/tests/Unit/Helpers/JsonDecoderLoggerTest.php @@ -53,8 +53,7 @@ public function providerUseJsonValidateIfAvailable(): array /** @dataProvider providerUseJsonValidateIfAvailable */ public function testLogSendValidJsonMessageToLogger(bool $useJsonValidateIfAvailable): void { - /** @var string $jsonMessage */ - $jsonMessage = json_encode(['foo' => 'bar']); + $jsonMessage = (string) json_encode(['foo' => 'bar']); $textMessage = print_r(json_decode($jsonMessage), true); /** @var NullLogger&MockObject $logger */ $logger = $this->createMock(NullLogger::class); @@ -83,8 +82,7 @@ public function testLogSendInvalidJsonMessageToLogger(bool $useJsonValidateIfAva public function testLogSendTextMessageToLoggerAndJson(): void { - /** @var string $jsonMessage */ - $jsonMessage = json_encode(['foo' => 'bar']); + $jsonMessage = (string) json_encode(['foo' => 'bar']); $textMessage = print_r(json_decode($jsonMessage), true); /** @var NullLogger&MockObject $logger */ $logger = $this->createMock(NullLogger::class); diff --git a/tests/Unit/Services/Registration/CustomersTest.php b/tests/Unit/Services/Registration/CustomersTest.php index 5dd2b3d..f469e75 100644 --- a/tests/Unit/Services/Registration/CustomersTest.php +++ b/tests/Unit/Services/Registration/CustomersTest.php @@ -19,8 +19,8 @@ public function testCreateUsingNoItems(): void public function testFindByRfc(): void { - /** @var stdClass $data */ $data = json_decode($this->fileContentPath('registration-get-response.json')); + /** @phpstan-ignore-next-line */ $customers = new Customers($data->getResult->users->ResellerUser); $known = $customers->findByRfc('MAG041126GT8'); if (null === $known) { @@ -35,6 +35,7 @@ public function testGetByRfcUsingExistentRfc(): void $expectedRfc = 'MAG041126GT8'; /** @var stdClass $data */ $data = json_decode($this->fileContentPath('registration-get-response.json')); + /** @phpstan-ignore-next-line */ $customers = new Customers($data->getResult->users->ResellerUser); $this->assertSame($expectedRfc, $customers->getByRfc($expectedRfc)->rfc()); } @@ -43,6 +44,7 @@ public function testGetByRfcUsingNonExistentRfcThrowsException(): void { /** @var stdClass $data */ $data = json_decode($this->fileContentPath('registration-get-response.json')); + /** @phpstan-ignore-next-line */ $customers = new Customers($data->getResult->users->ResellerUser); $this->expectException(LogicException::class); diff --git a/tests/Unit/Services/Stamping/StampingAlertsTest.php b/tests/Unit/Services/Stamping/StampingAlertsTest.php index 7df5fbb..6b1465e 100644 --- a/tests/Unit/Services/Stamping/StampingAlertsTest.php +++ b/tests/Unit/Services/Stamping/StampingAlertsTest.php @@ -6,7 +6,6 @@ use PhpCfdi\Finkok\Services\Stamping\StampingAlerts; use PhpCfdi\Finkok\Tests\TestCase; -use stdClass; final class StampingAlertsTest extends TestCase { @@ -53,9 +52,9 @@ public function testHydrate(): void public function testGettingAnAlertByIndex(): void { - /** @var stdClass $data */ $data = json_decode($this->fileContentPath('stamp-response-with-alerts.json')); - $alerts = new StampingAlerts($data->{'stampResult'}->{'Incidencias'}->{'Incidencia'} ?? []); + /** @phpstan-ignore-next-line */ + $alerts = new StampingAlerts($data->stampResult->Incidencias->Incidencia ?? []); $this->assertSame('FAKE2', $alerts->get(1)->errorCode()); } From c918fdfd8a8b60f91f57b2e86fdb1a7a788c20c0 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Mon, 10 Mar 2025 13:38:56 -0600 Subject: [PATCH 03/23] Update development tools --- .phive/phars.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 38968b0..477c775 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -2,7 +2,7 @@ - - + + From a43ebf8e36bd7945de600c1cf55a6794b951f8a3 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Mon, 10 Mar 2025 13:39:29 -0600 Subject: [PATCH 04/23] Add getEnvBool function to load boolean values --- .../Integration/Services/Registration/AddServiceTest.php | 2 +- tests/TestCase.php | 8 +++++++- tests/stamp-precfdi-devenv.php | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Integration/Services/Registration/AddServiceTest.php b/tests/Integration/Services/Registration/AddServiceTest.php index 264570e..70a093e 100644 --- a/tests/Integration/Services/Registration/AddServiceTest.php +++ b/tests/Integration/Services/Registration/AddServiceTest.php @@ -55,7 +55,7 @@ public function testConsumeAddServiceWithRandomRfc(): void // This is why it takes so long to run. // To remove any RFC email soporte@finkok.com asking for it. - if (! $this->getenv('FINKOK_REGISTRATION_ADD_CREATE_RANDOM_RFC')) { + if (! $this->getenvBool('FINKOK_REGISTRATION_ADD_CREATE_RANDOM_RFC')) { $this->markTestSkipped('This test is skipped as will create a lot of garbage customers'); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 1808ef5..3c2dd61 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -25,7 +25,7 @@ public function createSettingsFromEnvironment(SoapFactory $soapFactory = null): $settings->changeSoapFactory($soapFactory); } - if ($this->getenv('FINKOK_LOG_CALLS')) { + if ($this->getenvBool('FINKOK_LOG_CALLS')) { $loggerOutputFile = sprintf( '%s/../build/tests/%s-%s-%s.txt', __DIR__, @@ -78,4 +78,10 @@ public static function getenv(string $key): string $value = $_ENV[$key] ?? ''; return (is_scalar($value)) ? strval($value) : ''; } + + public static function getenvBool(string $key): bool + { + $value = static::getenv($key); + return ! in_array($value, ['', '0', 'no', 'false']); + } } diff --git a/tests/stamp-precfdi-devenv.php b/tests/stamp-precfdi-devenv.php index 49a13f1..15011fe 100644 --- a/tests/stamp-precfdi-devenv.php +++ b/tests/stamp-precfdi-devenv.php @@ -30,7 +30,7 @@ public function __invoke(string $preCfdiPath): int $this->showHelp(); return 0; } - $debug = (bool) TestCase::getenv('FINKOK_LOG_CALLS'); + $debug = TestCase::getenvBool('FINKOK_LOG_CALLS'); try { if (! file_exists($preCfdiPath)) { throw new Exception("File $preCfdiPath does not exists"); From a431ff5bff5c1bc69a096580367ab089b453615e Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Mon, 10 Mar 2025 13:43:32 -0600 Subject: [PATCH 05/23] Randomize precfdi concept description --- tests/Factories/PreCfdiCreatorHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Factories/PreCfdiCreatorHelper.php b/tests/Factories/PreCfdiCreatorHelper.php index 0c6158f..e64980e 100644 --- a/tests/Factories/PreCfdiCreatorHelper.php +++ b/tests/Factories/PreCfdiCreatorHelper.php @@ -54,7 +54,7 @@ public function __construct( $this->keyPemFile = $keyPemFile; $this->passPhrase = $passPhrase; $this->invoiceDate = new DateTimeImmutable('now -5 minutes', new DateTimeZone('America/Mexico_City')); - $this->conceptoDescription = 'Portable tetris gamepad pro++ ⏻'; + $this->conceptoDescription = sprintf('Portable tetris gamepad pro++ ⏻ v1.%s', random_int(10, 99)); $this->conceptoAmount = round(random_int(1000, 4000) + random_int(0, 99) / 100, 2); } From 3e233a830b38a07fc5d0afc21c5c35713c08857d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Mon, 10 Mar 2025 13:51:06 -0600 Subject: [PATCH 06/23] Improve code readability --- src/Services/AbstractResult.php | 2 +- src/Services/Utilities/ReportCreditResult.php | 3 +-- src/Services/Utilities/ReportTotalCommand.php | 6 +----- src/Services/Utilities/ReportUuidResult.php | 3 +-- tests/Unit/Helpers/JsonDecoderLoggerTest.php | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Services/AbstractResult.php b/src/Services/AbstractResult.php index 257df7c..c51033a 100644 --- a/src/Services/AbstractResult.php +++ b/src/Services/AbstractResult.php @@ -42,7 +42,7 @@ public function rawData(): stdClass */ protected function findInDescendent($haystack, string ...$location) { - if (0 === count($location)) { + if ([] === $location) { return $haystack; } $search = array_shift($location); diff --git a/src/Services/Utilities/ReportCreditResult.php b/src/Services/Utilities/ReportCreditResult.php index bc1d071..560f514 100644 --- a/src/Services/Utilities/ReportCreditResult.php +++ b/src/Services/Utilities/ReportCreditResult.php @@ -13,12 +13,11 @@ class ReportCreditResult extends AbstractResult use MethodsFilterVariablesTrait; /** @var array */ - private $items; + private $items = []; public function __construct(stdClass $data) { parent::__construct($data, 'report_creditResult'); - $this->items = []; $items = $this->filterArrayOfStdClass( $this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit') diff --git a/src/Services/Utilities/ReportTotalCommand.php b/src/Services/Utilities/ReportTotalCommand.php index acb8649..b1c5a7b 100644 --- a/src/Services/Utilities/ReportTotalCommand.php +++ b/src/Services/Utilities/ReportTotalCommand.php @@ -109,11 +109,7 @@ public function endString(): string { $date = new DateTimeImmutable(sprintf('%04d-%02d-01', $this->endYear, $this->endMonth)); $today = $this->today(); - if ($this->endPeriod() === $today->format('Y-m')) { - $date = $today; - } else { - $date = $date->modify('+ 1 month'); - } + $date = $this->endPeriod() === $today->format('Y-m') ? $today : $date->modify('+ 1 month'); return sprintf('%sT00:00:00', $date->format('Y-m-d')); } diff --git a/src/Services/Utilities/ReportUuidResult.php b/src/Services/Utilities/ReportUuidResult.php index 2952f3c..e2d6f6c 100644 --- a/src/Services/Utilities/ReportUuidResult.php +++ b/src/Services/Utilities/ReportUuidResult.php @@ -13,12 +13,11 @@ class ReportUuidResult extends AbstractResult use MethodsFilterVariablesTrait; /** @var array */ - private $items; + private $items = []; public function __construct(stdClass $data) { parent::__construct($data, 'report_uuidResult'); - $this->items = []; $items = $this->filterArrayOfStdClass( $this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID') diff --git a/tests/Unit/Helpers/JsonDecoderLoggerTest.php b/tests/Unit/Helpers/JsonDecoderLoggerTest.php index cc7d57d..ea87c66 100644 --- a/tests/Unit/Helpers/JsonDecoderLoggerTest.php +++ b/tests/Unit/Helpers/JsonDecoderLoggerTest.php @@ -94,7 +94,7 @@ public function testLogSendTextMessageToLoggerAndJson(): void $logger->expects($matcher)->method('log')->with( 'debug', $this->callback( - function ($message) use ($matcher, $expectedParameters) { + function ($message) use ($matcher, $expectedParameters): bool { $this->assertSame($expectedParameters[$matcher->getInvocationCount() - 1], $message); return true; } From 978d60320c3a3a94a63477290084db29bf1b8cfe Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 7 Nov 2025 23:26:34 -0600 Subject: [PATCH 07/23] Fix composer-normalize check --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 818f3a2..a60a5ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,7 +28,7 @@ jobs: env: fail-fast: true - name: Composer normalize - run: composer-normalize + run: composer-normalize --dry-run phpcs: name: Code style (phpcs) From 676e82c96095ede997600b16e38fe4473fd6a563 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 7 Nov 2025 23:29:02 -0600 Subject: [PATCH 08/23] Fix phpcs code standard --- phpcs.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 299f73e..3a5a85a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -18,7 +18,6 @@ - From 899694717f4e52f455df935a87bcfe1e49b9fc8c Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 7 Nov 2025 23:28:45 -0600 Subject: [PATCH 09/23] Bump to PHP 7.4 --- .github/workflows/build.yml | 2 +- .php-cs-fixer.dist.php | 4 +-- composer.json | 2 +- src/Finkok.php | 3 +- src/FinkokEnvironment.php | 3 +- src/FinkokSettings.php | 12 +++---- src/Helpers/AcceptRejectSigner.php | 12 +++---- src/Helpers/CancelSigner.php | 6 ++-- src/Helpers/DocumentSigner.php | 9 ++---- src/Helpers/FileLogger.php | 3 +- src/Helpers/GetRelatedSigner.php | 9 ++---- src/Helpers/GetSatStatusExtractor.php | 2 +- src/Helpers/JsonDecoderLogger.php | 12 +++---- src/QuickFinkok.php | 7 ++--- src/Services/AbstractCollection.php | 2 +- src/Services/AbstractResult.php | 6 ++-- .../Cancel/AcceptRejectSignatureCommand.php | 3 +- .../Cancel/AcceptRejectSignatureResult.php | 6 ++-- .../Cancel/AcceptRejectSignatureService.php | 3 +- src/Services/Cancel/AcceptRejectUuidItem.php | 9 ++---- .../Cancel/CancelSignatureCommand.php | 6 ++-- src/Services/Cancel/CancelSignatureResult.php | 3 +- .../Cancel/CancelSignatureService.php | 3 +- src/Services/Cancel/CancelledDocument.php | 3 +- src/Services/Cancel/GetPendingCommand.php | 3 +- src/Services/Cancel/GetPendingResult.php | 2 +- src/Services/Cancel/GetPendingService.php | 3 +- src/Services/Cancel/GetReceiptCommand.php | 9 ++---- src/Services/Cancel/GetReceiptService.php | 3 +- .../Cancel/GetRelatedSignatureCommand.php | 3 +- .../Cancel/GetRelatedSignatureResult.php | 9 ++---- .../Cancel/GetRelatedSignatureService.php | 3 +- src/Services/Cancel/GetSatStatusCommand.php | 12 +++---- src/Services/Cancel/GetSatStatusService.php | 3 +- src/Services/Cancel/RelatedItem.php | 9 ++---- src/Services/Manifest/GetContractsCommand.php | 15 +++------ src/Services/Manifest/GetContractsService.php | 3 +- .../Manifest/GetSignedContractsCommand.php | 9 ++---- .../Manifest/GetSignedContractsResult.php | 12 +++---- .../Manifest/GetSignedContractsService.php | 3 +- .../Manifest/SignContractsCommand.php | 9 ++---- .../Manifest/SignContractsService.php | 3 +- src/Services/Registration/AddCommand.php | 15 +++------ src/Services/Registration/AddService.php | 3 +- src/Services/Registration/AssignCommand.php | 6 ++-- src/Services/Registration/AssignService.php | 3 +- src/Services/Registration/Customer.php | 9 ++---- src/Services/Registration/EditCommand.php | 15 +++------ src/Services/Registration/EditService.php | 3 +- src/Services/Registration/ObtainCommand.php | 3 +- .../Registration/ObtainCustomersCommand.php | 3 +- .../Registration/ObtainCustomersResult.php | 3 +- .../Registration/ObtainCustomersService.php | 3 +- src/Services/Registration/ObtainResult.php | 3 +- src/Services/Registration/ObtainService.php | 3 +- src/Services/Registration/PageInformation.php | 18 ++++------- src/Services/Registration/SwitchCommand.php | 6 ++-- src/Services/Registration/SwitchService.php | 3 +- .../Retentions/CancelSignatureService.php | 3 +- src/Services/Retentions/StampService.php | 3 +- src/Services/Retentions/StampedService.php | 3 +- src/Services/Stamping/QueryPendingCommand.php | 3 +- src/Services/Stamping/QueryPendingService.php | 3 +- src/Services/Stamping/QuickStampService.php | 3 +- src/Services/Stamping/StampService.php | 3 +- src/Services/Stamping/StampedService.php | 3 +- src/Services/Stamping/StampingAlert.php | 3 +- src/Services/Stamping/StampingCommand.php | 3 +- src/Services/Stamping/StampingResult.php | 3 +- src/Services/Utilities/DatetimeCommand.php | 3 +- src/Services/Utilities/DatetimeService.php | 3 +- src/Services/Utilities/DownloadXmlCommand.php | 9 ++---- src/Services/Utilities/DownloadXmlService.php | 3 +- .../Utilities/ReportCreditCommand.php | 3 +- src/Services/Utilities/ReportCreditResult.php | 2 +- .../Utilities/ReportCreditService.php | 3 +- src/Services/Utilities/ReportTotalCommand.php | 24 +++++--------- src/Services/Utilities/ReportTotalResult.php | 9 ++---- src/Services/Utilities/ReportTotalService.php | 3 +- src/Services/Utilities/ReportUuidCommand.php | 12 +++---- src/Services/Utilities/ReportUuidResult.php | 2 +- src/Services/Utilities/ReportUuidService.php | 3 +- src/SoapCaller.php | 8 ++--- src/SoapFactory.php | 3 +- tests/Factories/PreCfdiCreatorHelper.php | 31 +++++++------------ .../PreCfdiRetentionCreatorHelper.php | 27 ++++++---------- tests/Factories/RandomPreCfdiRetention.php | 10 +++--- tests/Fakes/FakeSoapCaller.php | 8 ++--- tests/Fakes/FakeSoapFactory.php | 16 ++++++---- tests/Integration/IntegrationTestCase.php | 6 ++-- .../Retentions/CancelSignatureServiceTest.php | 3 +- .../RetentionsUsingExistentRetentionTest.php | 9 ++---- tests/Unit/QuickFinkokTest.php | 3 +- tests/Unit/Services/AbstractResultTest.php | 6 ++-- .../Cancel/AcceptRejectUuidListTest.php | 3 +- .../Utilities/ReportTotalCommandTest.php | 3 +- tests/stamp-precfdi-devenv.php | 3 +- 97 files changed, 208 insertions(+), 385 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a60a5ca..3470db0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2b6cddb..7e02d37 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -15,8 +15,8 @@ ->setRules([ '@PSR12' => true, '@PSR12:risky' => true, - '@PHP71Migration:risky' => true, - '@PHP73Migration' => true, + '@PHP7x4Migration' => true, + '@PHP7x4Migration:risky' => true, // symfony 'class_attributes_separation' => true, 'whitespace_after_comma_in_array' => true, diff --git a/composer.json b/composer.json index da0ee6f..6a2fcb5 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "source": "https://github.com/phpcfdi/finkok" }, "require": { - "php": ">=7.3", + "php": ">=7.4", "ext-dom": "*", "ext-json": "*", "ext-openssl": "*", diff --git a/src/Finkok.php b/src/Finkok.php index c7069b8..879eed7 100644 --- a/src/Finkok.php +++ b/src/Finkok.php @@ -91,8 +91,7 @@ class Finkok ], ]; - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $factory) { diff --git a/src/FinkokEnvironment.php b/src/FinkokEnvironment.php index 4f4d5d3..3c83fbb 100644 --- a/src/FinkokEnvironment.php +++ b/src/FinkokEnvironment.php @@ -6,8 +6,7 @@ class FinkokEnvironment { - /** @var Definitions\Environment */ - private $environment; + private Definitions\Environment $environment; private function __construct(Definitions\Environment $environment) { diff --git a/src/FinkokSettings.php b/src/FinkokSettings.php index 04be1ec..e5cd228 100644 --- a/src/FinkokSettings.php +++ b/src/FinkokSettings.php @@ -12,17 +12,13 @@ */ class FinkokSettings { - /** @var string */ - private $username; + private string $username; - /** @var string */ - private $password; + private string $password; - /** @var FinkokEnvironment */ - private $environment; + private FinkokEnvironment $environment; - /** @var SoapFactory */ - private $soapFactory; + private SoapFactory $soapFactory; public function __construct(string $username, string $password, FinkokEnvironment $environment = null) { diff --git a/src/Helpers/AcceptRejectSigner.php b/src/Helpers/AcceptRejectSigner.php index 3faf115..848f2e1 100644 --- a/src/Helpers/AcceptRejectSigner.php +++ b/src/Helpers/AcceptRejectSigner.php @@ -15,17 +15,13 @@ class AcceptRejectSigner /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; - /** @var string */ - private $uuid; + private string $uuid; - /** @var CancelAnswer */ - private $answer; + private CancelAnswer $answer; - /** @var string */ - private $pacRfc; + private string $pacRfc; - /** @var DateTimeImmutable */ - private $dateTime; + private DateTimeImmutable $dateTime; /** * GetRelatedSigner constructor. diff --git a/src/Helpers/CancelSigner.php b/src/Helpers/CancelSigner.php index 4e5590f..4afcf09 100644 --- a/src/Helpers/CancelSigner.php +++ b/src/Helpers/CancelSigner.php @@ -12,11 +12,9 @@ class CancelSigner { - /** @var CancelDocuments*/ - private $documents; + private CancelDocuments $documents; - /** @var DateTimeImmutable */ - private $dateTime; + private DateTimeImmutable $dateTime; /** * CancelSigner constructor diff --git a/src/Helpers/DocumentSigner.php b/src/Helpers/DocumentSigner.php index 81d31fe..c351fa1 100644 --- a/src/Helpers/DocumentSigner.php +++ b/src/Helpers/DocumentSigner.php @@ -13,14 +13,11 @@ class DocumentSigner { - /** @var string */ - private $rfc; + private string $rfc; - /** @var DateTimeImmutable */ - private $date; + private DateTimeImmutable $date; - /** @var string */ - private $content; + private string $content; public function __construct(string $rfc, DateTimeImmutable $date, string $content) { diff --git a/src/Helpers/FileLogger.php b/src/Helpers/FileLogger.php index 5fb623d..2a435cb 100644 --- a/src/Helpers/FileLogger.php +++ b/src/Helpers/FileLogger.php @@ -9,8 +9,7 @@ final class FileLogger extends AbstractLogger implements LoggerInterface { - /** @var string */ - public $outputFile; + public string $outputFile; public function __construct(string $outputFile = 'php://stdout') { diff --git a/src/Helpers/GetRelatedSigner.php b/src/Helpers/GetRelatedSigner.php index aadf341..fcd420f 100644 --- a/src/Helpers/GetRelatedSigner.php +++ b/src/Helpers/GetRelatedSigner.php @@ -14,14 +14,11 @@ class GetRelatedSigner /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; - /** @var string */ - private $uuid; + private string $uuid; - /** @var RfcRole */ - private $role; + private RfcRole $role; - /** @var string */ - private $pacRfc; + private string $pacRfc; /** * GetRelatedSigner constructor. diff --git a/src/Helpers/GetSatStatusExtractor.php b/src/Helpers/GetSatStatusExtractor.php index 6996113..728f37c 100644 --- a/src/Helpers/GetSatStatusExtractor.php +++ b/src/Helpers/GetSatStatusExtractor.php @@ -20,7 +20,7 @@ class GetSatStatusExtractor { /** @var string[] */ - private $expressionData; + private array $expressionData; /** * GetSatStatusExtractor constructor. diff --git a/src/Helpers/JsonDecoderLogger.php b/src/Helpers/JsonDecoderLogger.php index 94995ce..cc75a97 100644 --- a/src/Helpers/JsonDecoderLogger.php +++ b/src/Helpers/JsonDecoderLogger.php @@ -20,17 +20,13 @@ */ final class JsonDecoderLogger extends AbstractLogger implements LoggerInterface { - /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; - /** @var bool */ - private $useJsonValidateIfAvailable = true; + private bool $useJsonValidateIfAvailable = true; - /** @var bool */ - private $alsoLogJsonMessage = false; + private bool $alsoLogJsonMessage = false; - /** @var bool */ - private $lastMessageWasJsonValid = false; + private bool $lastMessageWasJsonValid = false; public function __construct(LoggerInterface $logger) { diff --git a/src/QuickFinkok.php b/src/QuickFinkok.php index 575b695..9594c37 100644 --- a/src/QuickFinkok.php +++ b/src/QuickFinkok.php @@ -21,8 +21,7 @@ class QuickFinkok { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $factory) { @@ -470,7 +469,7 @@ public function customerSignAndSendContracts( ): Manifest\SignContractsResult { $rfc = $fiel->rfc(); $name = $fiel->legalName(); - $signedOn = $signedOn ?? new DateTimeImmutable(); + $signedOn ??= new DateTimeImmutable(); $documents = $this->customerGetContracts($rfc, $name, $address, $email, $snid); if (! $documents->success()) { return Manifest\SignContractsResult::createFromData( @@ -496,7 +495,7 @@ public function customerGetSignedContracts( string $rfc, SignedDocumentFormat $format = null ): Manifest\GetSignedContractsResult { - $format = $format ?? SignedDocumentFormat::xml(); + $format ??= SignedDocumentFormat::xml(); $command = new Manifest\GetSignedContractsCommand($snid, $rfc, $format); $service = new Manifest\GetSignedContractsService($this->settings()); return $service->getSignedContracts($command); diff --git a/src/Services/AbstractCollection.php b/src/Services/AbstractCollection.php index 6ee79bf..ec3d1f8 100644 --- a/src/Services/AbstractCollection.php +++ b/src/Services/AbstractCollection.php @@ -23,7 +23,7 @@ abstract class AbstractCollection implements Countable, IteratorAggregate abstract protected function createItemFromStdClass(stdClass $content): object; /** @var ArrayObject */ - protected $collection; + protected ArrayObject $collection; /** @param array $collection */ public function __construct(array $collection) diff --git a/src/Services/AbstractResult.php b/src/Services/AbstractResult.php index c51033a..1d4fe61 100644 --- a/src/Services/AbstractResult.php +++ b/src/Services/AbstractResult.php @@ -12,11 +12,9 @@ abstract class AbstractResult { use MethodsFilterVariablesTrait; - /** @var stdClass */ - protected $data; + protected stdClass $data; - /** @var stdClass */ - protected $root; + protected stdClass $root; public function __construct(stdClass $data, string ...$meanLocation) { diff --git a/src/Services/Cancel/AcceptRejectSignatureCommand.php b/src/Services/Cancel/AcceptRejectSignatureCommand.php index 2e3f019..9cd669f 100644 --- a/src/Services/Cancel/AcceptRejectSignatureCommand.php +++ b/src/Services/Cancel/AcceptRejectSignatureCommand.php @@ -6,8 +6,7 @@ class AcceptRejectSignatureCommand { - /** @var string */ - private $xml; + private string $xml; public function __construct(string $xml) { diff --git a/src/Services/Cancel/AcceptRejectSignatureResult.php b/src/Services/Cancel/AcceptRejectSignatureResult.php index 4fdfa1d..541129c 100644 --- a/src/Services/Cancel/AcceptRejectSignatureResult.php +++ b/src/Services/Cancel/AcceptRejectSignatureResult.php @@ -12,11 +12,9 @@ class AcceptRejectSignatureResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var AcceptRejectUuidList */ - private $uuids; + private AcceptRejectUuidList $uuids; - /** @var string */ - private $error; + private string $error; public function __construct(stdClass $data) { diff --git a/src/Services/Cancel/AcceptRejectSignatureService.php b/src/Services/Cancel/AcceptRejectSignatureService.php index 4f76c68..21a5ed5 100644 --- a/src/Services/Cancel/AcceptRejectSignatureService.php +++ b/src/Services/Cancel/AcceptRejectSignatureService.php @@ -9,8 +9,7 @@ class AcceptRejectSignatureService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/AcceptRejectUuidItem.php b/src/Services/Cancel/AcceptRejectUuidItem.php index bccb4ad..939b4fc 100644 --- a/src/Services/Cancel/AcceptRejectUuidItem.php +++ b/src/Services/Cancel/AcceptRejectUuidItem.php @@ -8,14 +8,11 @@ class AcceptRejectUuidItem { - /** @var string */ - private $uuid; + private string $uuid; - /** @var AcceptRejectUuidStatus */ - private $status; + private AcceptRejectUuidStatus $status; - /** @var CancelAnswer */ - private $answer; + private CancelAnswer $answer; public function __construct(string $uuid, AcceptRejectUuidStatus $status, CancelAnswer $answer) { diff --git a/src/Services/Cancel/CancelSignatureCommand.php b/src/Services/Cancel/CancelSignatureCommand.php index 1dc2943..455b371 100644 --- a/src/Services/Cancel/CancelSignatureCommand.php +++ b/src/Services/Cancel/CancelSignatureCommand.php @@ -8,11 +8,9 @@ class CancelSignatureCommand { - /** @var string */ - private $xml; + private string $xml; - /** @var CancelStorePending */ - private $storePending; + private CancelStorePending $storePending; /** * CancelSignatureCommand constructor. diff --git a/src/Services/Cancel/CancelSignatureResult.php b/src/Services/Cancel/CancelSignatureResult.php index e308b27..cdb0b06 100644 --- a/src/Services/Cancel/CancelSignatureResult.php +++ b/src/Services/Cancel/CancelSignatureResult.php @@ -12,8 +12,7 @@ class CancelSignatureResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var CancelledDocuments */ - private $documents; + private CancelledDocuments $documents; public function __construct(stdClass $data) { diff --git a/src/Services/Cancel/CancelSignatureService.php b/src/Services/Cancel/CancelSignatureService.php index 95c7517..28273fd 100644 --- a/src/Services/Cancel/CancelSignatureService.php +++ b/src/Services/Cancel/CancelSignatureService.php @@ -9,8 +9,7 @@ class CancelSignatureService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/CancelledDocument.php b/src/Services/Cancel/CancelledDocument.php index 7faa07b..8a7e558 100644 --- a/src/Services/Cancel/CancelledDocument.php +++ b/src/Services/Cancel/CancelledDocument.php @@ -11,8 +11,7 @@ class CancelledDocument { use MethodsFilterVariablesTrait; - /** @var stdClass */ - private $data; + private stdClass $data; public function __construct(stdClass $raw) { diff --git a/src/Services/Cancel/GetPendingCommand.php b/src/Services/Cancel/GetPendingCommand.php index 52c0973..4fe3e09 100644 --- a/src/Services/Cancel/GetPendingCommand.php +++ b/src/Services/Cancel/GetPendingCommand.php @@ -6,8 +6,7 @@ class GetPendingCommand { - /** @var string */ - private $rfc; + private string $rfc; public function __construct(string $rfc) { diff --git a/src/Services/Cancel/GetPendingResult.php b/src/Services/Cancel/GetPendingResult.php index 2fb8af0..92fb312 100644 --- a/src/Services/Cancel/GetPendingResult.php +++ b/src/Services/Cancel/GetPendingResult.php @@ -13,7 +13,7 @@ class GetPendingResult extends AbstractResult use MethodsFilterVariablesTrait; /** @var string[] */ - private $uuids; + private array $uuids; public function __construct(stdClass $data) { diff --git a/src/Services/Cancel/GetPendingService.php b/src/Services/Cancel/GetPendingService.php index 4cb05b7..7a82f2b 100644 --- a/src/Services/Cancel/GetPendingService.php +++ b/src/Services/Cancel/GetPendingService.php @@ -9,8 +9,7 @@ class GetPendingService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/GetReceiptCommand.php b/src/Services/Cancel/GetReceiptCommand.php index 6d9ddf7..a82e1ca 100644 --- a/src/Services/Cancel/GetReceiptCommand.php +++ b/src/Services/Cancel/GetReceiptCommand.php @@ -8,14 +8,11 @@ class GetReceiptCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $uuid; + private string $uuid; - /** @var ReceiptType */ - private $type; + private ReceiptType $type; public function __construct(string $rfc, string $uuid, ReceiptType $type) { diff --git a/src/Services/Cancel/GetReceiptService.php b/src/Services/Cancel/GetReceiptService.php index d0a7892..76be9ea 100644 --- a/src/Services/Cancel/GetReceiptService.php +++ b/src/Services/Cancel/GetReceiptService.php @@ -9,8 +9,7 @@ class GetReceiptService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/GetRelatedSignatureCommand.php b/src/Services/Cancel/GetRelatedSignatureCommand.php index c1e7cad..cfcb6ed 100644 --- a/src/Services/Cancel/GetRelatedSignatureCommand.php +++ b/src/Services/Cancel/GetRelatedSignatureCommand.php @@ -6,8 +6,7 @@ class GetRelatedSignatureCommand { - /** @var string */ - private $xml; + private string $xml; public function __construct(string $xml) { diff --git a/src/Services/Cancel/GetRelatedSignatureResult.php b/src/Services/Cancel/GetRelatedSignatureResult.php index b8f7220..8ac9db6 100644 --- a/src/Services/Cancel/GetRelatedSignatureResult.php +++ b/src/Services/Cancel/GetRelatedSignatureResult.php @@ -12,14 +12,11 @@ class GetRelatedSignatureResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var RelatedItems */ - private $parents; + private RelatedItems $parents; - /** @var RelatedItems */ - private $children; + private RelatedItems $children; - /** @var string */ - private $error; + private string $error; public function __construct(stdClass $data) { diff --git a/src/Services/Cancel/GetRelatedSignatureService.php b/src/Services/Cancel/GetRelatedSignatureService.php index 669a60c..aadf80a 100644 --- a/src/Services/Cancel/GetRelatedSignatureService.php +++ b/src/Services/Cancel/GetRelatedSignatureService.php @@ -9,8 +9,7 @@ class GetRelatedSignatureService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/GetSatStatusCommand.php b/src/Services/Cancel/GetSatStatusCommand.php index f7a5a84..b18767e 100644 --- a/src/Services/Cancel/GetSatStatusCommand.php +++ b/src/Services/Cancel/GetSatStatusCommand.php @@ -6,17 +6,13 @@ class GetSatStatusCommand { - /** @var string */ - private $rfcIssuer; + private string $rfcIssuer; - /** @var string */ - private $rfcRecipient; + private string $rfcRecipient; - /** @var string */ - private $uuid; + private string $uuid; - /** @var string */ - private $total; + private string $total; public function __construct(string $rfcIssuer, string $rfcRecipient, string $uuid, string $total) { diff --git a/src/Services/Cancel/GetSatStatusService.php b/src/Services/Cancel/GetSatStatusService.php index 7d1bea9..37b0236 100644 --- a/src/Services/Cancel/GetSatStatusService.php +++ b/src/Services/Cancel/GetSatStatusService.php @@ -9,8 +9,7 @@ class GetSatStatusService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Cancel/RelatedItem.php b/src/Services/Cancel/RelatedItem.php index 76d5791..dc57713 100644 --- a/src/Services/Cancel/RelatedItem.php +++ b/src/Services/Cancel/RelatedItem.php @@ -6,14 +6,11 @@ class RelatedItem { - /** @var string */ - private $uuid; + private string $uuid; - /** @var string */ - private $rfcEmitter; + private string $rfcEmitter; - /** @var string */ - private $rfcReceiver; + private string $rfcReceiver; public function __construct(string $uuid, string $rfcEmitter, string $rfcReceiver) { diff --git a/src/Services/Manifest/GetContractsCommand.php b/src/Services/Manifest/GetContractsCommand.php index 56e378d..064e07d 100644 --- a/src/Services/Manifest/GetContractsCommand.php +++ b/src/Services/Manifest/GetContractsCommand.php @@ -6,20 +6,15 @@ class GetContractsCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $name; + private string $name; - /** @var string */ - private $address; + private string $address; - /** @var string */ - private $email; + private string $email; - /** @var string */ - private $snid; + private string $snid; public function __construct(string $rfc, string $name, string $address, string $email, string $snid) { diff --git a/src/Services/Manifest/GetContractsService.php b/src/Services/Manifest/GetContractsService.php index 99772ea..daa332c 100644 --- a/src/Services/Manifest/GetContractsService.php +++ b/src/Services/Manifest/GetContractsService.php @@ -9,8 +9,7 @@ class GetContractsService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Manifest/GetSignedContractsCommand.php b/src/Services/Manifest/GetSignedContractsCommand.php index 565277f..2290cee 100644 --- a/src/Services/Manifest/GetSignedContractsCommand.php +++ b/src/Services/Manifest/GetSignedContractsCommand.php @@ -8,14 +8,11 @@ class GetSignedContractsCommand { - /** @var string */ - private $snid; + private string $snid; - /** @var string */ - private $rfc; + private string $rfc; - /** @var SignedDocumentFormat */ - private $format; + private SignedDocumentFormat $format; public function __construct(string $snid, string $rfc, SignedDocumentFormat $format) { diff --git a/src/Services/Manifest/GetSignedContractsResult.php b/src/Services/Manifest/GetSignedContractsResult.php index ea44f04..f34ba7f 100644 --- a/src/Services/Manifest/GetSignedContractsResult.php +++ b/src/Services/Manifest/GetSignedContractsResult.php @@ -9,17 +9,13 @@ class GetSignedContractsResult extends AbstractResult { - /** @var bool */ - private $success; + private bool $success; - /** @var string */ - private $contract; + private string $contract; - /** @var string */ - private $privacy; + private string $privacy; - /** @var string */ - private $error; + private string $error; public function __construct(stdClass $data, bool $isBase64) { diff --git a/src/Services/Manifest/GetSignedContractsService.php b/src/Services/Manifest/GetSignedContractsService.php index fcb8221..5bde2a7 100644 --- a/src/Services/Manifest/GetSignedContractsService.php +++ b/src/Services/Manifest/GetSignedContractsService.php @@ -9,8 +9,7 @@ class GetSignedContractsService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Manifest/SignContractsCommand.php b/src/Services/Manifest/SignContractsCommand.php index 8867cc7..b6e0591 100644 --- a/src/Services/Manifest/SignContractsCommand.php +++ b/src/Services/Manifest/SignContractsCommand.php @@ -6,14 +6,11 @@ class SignContractsCommand { - /** @var string */ - private $snid; + private string $snid; - /** @var string */ - private $privacy; + private string $privacy; - /** @var string */ - private $contract; + private string $contract; public function __construct(string $snid, string $privacy, string $contract) { diff --git a/src/Services/Manifest/SignContractsService.php b/src/Services/Manifest/SignContractsService.php index d2dc8bb..353534c 100644 --- a/src/Services/Manifest/SignContractsService.php +++ b/src/Services/Manifest/SignContractsService.php @@ -9,8 +9,7 @@ class SignContractsService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/AddCommand.php b/src/Services/Registration/AddCommand.php index 0d451b1..da0544e 100644 --- a/src/Services/Registration/AddCommand.php +++ b/src/Services/Registration/AddCommand.php @@ -6,20 +6,15 @@ class AddCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var CustomerType */ - private $type; + private CustomerType $type; - /** @var string */ - private $certificate; + private string $certificate; - /** @var string */ - private $privateKey; + private string $privateKey; - /** @var string */ - private $passPhrase; + private string $passPhrase; public function __construct( string $rfc, diff --git a/src/Services/Registration/AddService.php b/src/Services/Registration/AddService.php index aefa864..87da654 100644 --- a/src/Services/Registration/AddService.php +++ b/src/Services/Registration/AddService.php @@ -9,8 +9,7 @@ class AddService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/AssignCommand.php b/src/Services/Registration/AssignCommand.php index c810baf..8919936 100644 --- a/src/Services/Registration/AssignCommand.php +++ b/src/Services/Registration/AssignCommand.php @@ -6,11 +6,9 @@ class AssignCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var int */ - private $credit; + private int $credit; public function __construct(string $rfc, int $credit) { diff --git a/src/Services/Registration/AssignService.php b/src/Services/Registration/AssignService.php index 8b0e6ad..72757bb 100644 --- a/src/Services/Registration/AssignService.php +++ b/src/Services/Registration/AssignService.php @@ -9,8 +9,7 @@ class AssignService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/Customer.php b/src/Services/Registration/Customer.php index dd29c23..8c1dbcd 100644 --- a/src/Services/Registration/Customer.php +++ b/src/Services/Registration/Customer.php @@ -11,14 +11,11 @@ class Customer { use MethodsFilterVariablesTrait; - /** @var stdClass */ - private $data; + private stdClass $data; - /** @var CustomerStatus */ - private $status; + private CustomerStatus $status; - /** @var CustomerType */ - private $type; + private CustomerType $type; public function __construct(stdClass $raw) { diff --git a/src/Services/Registration/EditCommand.php b/src/Services/Registration/EditCommand.php index fd87317..ca002be 100644 --- a/src/Services/Registration/EditCommand.php +++ b/src/Services/Registration/EditCommand.php @@ -6,20 +6,15 @@ class EditCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var CustomerStatus */ - private $status; + private CustomerStatus $status; - /** @var string */ - private $certificate; + private string $certificate; - /** @var string */ - private $privateKey; + private string $privateKey; - /** @var string */ - private $passPhrase; + private string $passPhrase; public function __construct( string $rfc, diff --git a/src/Services/Registration/EditService.php b/src/Services/Registration/EditService.php index 1b438d0..ef54fe3 100644 --- a/src/Services/Registration/EditService.php +++ b/src/Services/Registration/EditService.php @@ -9,8 +9,7 @@ class EditService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/ObtainCommand.php b/src/Services/Registration/ObtainCommand.php index c5576c3..3ae3454 100644 --- a/src/Services/Registration/ObtainCommand.php +++ b/src/Services/Registration/ObtainCommand.php @@ -8,8 +8,7 @@ class ObtainCommand { - /** @var string */ - private $rfc; + private string $rfc; public function __construct(string $rfc) { diff --git a/src/Services/Registration/ObtainCustomersCommand.php b/src/Services/Registration/ObtainCustomersCommand.php index 9587a7c..0f542e0 100644 --- a/src/Services/Registration/ObtainCustomersCommand.php +++ b/src/Services/Registration/ObtainCustomersCommand.php @@ -6,8 +6,7 @@ class ObtainCustomersCommand { - /** @var int */ - private $page; + private int $page; public function __construct(int $page) { diff --git a/src/Services/Registration/ObtainCustomersResult.php b/src/Services/Registration/ObtainCustomersResult.php index c97fd47..48fe0d2 100644 --- a/src/Services/Registration/ObtainCustomersResult.php +++ b/src/Services/Registration/ObtainCustomersResult.php @@ -12,8 +12,7 @@ final class ObtainCustomersResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var Customers */ - private $customers; + private Customers $customers; public function __construct(stdClass $data) { diff --git a/src/Services/Registration/ObtainCustomersService.php b/src/Services/Registration/ObtainCustomersService.php index a700fd5..a93731c 100644 --- a/src/Services/Registration/ObtainCustomersService.php +++ b/src/Services/Registration/ObtainCustomersService.php @@ -9,8 +9,7 @@ class ObtainCustomersService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/ObtainResult.php b/src/Services/Registration/ObtainResult.php index b551505..b09e5a2 100644 --- a/src/Services/Registration/ObtainResult.php +++ b/src/Services/Registration/ObtainResult.php @@ -12,8 +12,7 @@ class ObtainResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var Customers */ - private $customers; + private Customers $customers; public function __construct(stdClass $data) { diff --git a/src/Services/Registration/ObtainService.php b/src/Services/Registration/ObtainService.php index c926f25..2acffc5 100644 --- a/src/Services/Registration/ObtainService.php +++ b/src/Services/Registration/ObtainService.php @@ -9,8 +9,7 @@ class ObtainService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Registration/PageInformation.php b/src/Services/Registration/PageInformation.php index 9c4cfb1..d4c587c 100644 --- a/src/Services/Registration/PageInformation.php +++ b/src/Services/Registration/PageInformation.php @@ -6,23 +6,17 @@ class PageInformation { - /** @var int */ - private $firstRecord; + private int $firstRecord; - /** @var int */ - private $lastRecord; + private int $lastRecord; - /** @var int */ - private $totalRecords; + private int $totalRecords; - /** @var int */ - private $currentPage; + private int $currentPage; - /** @var int */ - private $totalPages; + private int $totalPages; - /** @var int */ - private $pageLength; + private int $pageLength; public function __construct( int $firstRecord, diff --git a/src/Services/Registration/SwitchCommand.php b/src/Services/Registration/SwitchCommand.php index 1f3f8ce..0b2613d 100644 --- a/src/Services/Registration/SwitchCommand.php +++ b/src/Services/Registration/SwitchCommand.php @@ -6,11 +6,9 @@ class SwitchCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var CustomerType */ - private $customerType; + private CustomerType $customerType; public function __construct(string $rfc, CustomerType $customerType) { diff --git a/src/Services/Registration/SwitchService.php b/src/Services/Registration/SwitchService.php index c5c6bff..3eb7aed 100644 --- a/src/Services/Registration/SwitchService.php +++ b/src/Services/Registration/SwitchService.php @@ -9,8 +9,7 @@ class SwitchService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Retentions/CancelSignatureService.php b/src/Services/Retentions/CancelSignatureService.php index 27ec339..cdc1806 100644 --- a/src/Services/Retentions/CancelSignatureService.php +++ b/src/Services/Retentions/CancelSignatureService.php @@ -9,8 +9,7 @@ class CancelSignatureService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Retentions/StampService.php b/src/Services/Retentions/StampService.php index 799f58e..9cb52dc 100644 --- a/src/Services/Retentions/StampService.php +++ b/src/Services/Retentions/StampService.php @@ -9,8 +9,7 @@ class StampService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Retentions/StampedService.php b/src/Services/Retentions/StampedService.php index 9bb1fb7..95f6a95 100644 --- a/src/Services/Retentions/StampedService.php +++ b/src/Services/Retentions/StampedService.php @@ -9,8 +9,7 @@ class StampedService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Stamping/QueryPendingCommand.php b/src/Services/Stamping/QueryPendingCommand.php index 905f183..1ab30cd 100644 --- a/src/Services/Stamping/QueryPendingCommand.php +++ b/src/Services/Stamping/QueryPendingCommand.php @@ -6,8 +6,7 @@ class QueryPendingCommand { - /** @var string */ - private $uuid; + private string $uuid; public function __construct(string $uuid) { diff --git a/src/Services/Stamping/QueryPendingService.php b/src/Services/Stamping/QueryPendingService.php index 96c2cb0..a034895 100644 --- a/src/Services/Stamping/QueryPendingService.php +++ b/src/Services/Stamping/QueryPendingService.php @@ -9,8 +9,7 @@ class QueryPendingService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Stamping/QuickStampService.php b/src/Services/Stamping/QuickStampService.php index c685e14..0ff0406 100644 --- a/src/Services/Stamping/QuickStampService.php +++ b/src/Services/Stamping/QuickStampService.php @@ -9,8 +9,7 @@ class QuickStampService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Stamping/StampService.php b/src/Services/Stamping/StampService.php index 555168a..dce51b5 100644 --- a/src/Services/Stamping/StampService.php +++ b/src/Services/Stamping/StampService.php @@ -9,8 +9,7 @@ class StampService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Stamping/StampedService.php b/src/Services/Stamping/StampedService.php index f3746ee..84d4f13 100644 --- a/src/Services/Stamping/StampedService.php +++ b/src/Services/Stamping/StampedService.php @@ -9,8 +9,7 @@ class StampedService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Stamping/StampingAlert.php b/src/Services/Stamping/StampingAlert.php index f25ed63..54a7d24 100644 --- a/src/Services/Stamping/StampingAlert.php +++ b/src/Services/Stamping/StampingAlert.php @@ -11,8 +11,7 @@ class StampingAlert { use MethodsFilterVariablesTrait; - /** @var stdClass */ - private $data; + private stdClass $data; public function __construct(stdClass $raw) { diff --git a/src/Services/Stamping/StampingCommand.php b/src/Services/Stamping/StampingCommand.php index bfa636c..1ac1443 100644 --- a/src/Services/Stamping/StampingCommand.php +++ b/src/Services/Stamping/StampingCommand.php @@ -6,8 +6,7 @@ class StampingCommand { - /** @var string */ - private $xml; + private string $xml; public function __construct(string $xml) { diff --git a/src/Services/Stamping/StampingResult.php b/src/Services/Stamping/StampingResult.php index e9c7ba6..490319b 100644 --- a/src/Services/Stamping/StampingResult.php +++ b/src/Services/Stamping/StampingResult.php @@ -12,8 +12,7 @@ class StampingResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var StampingAlerts */ - private $alerts; + private StampingAlerts $alerts; public function __construct(string $container, stdClass $data) { diff --git a/src/Services/Utilities/DatetimeCommand.php b/src/Services/Utilities/DatetimeCommand.php index 85f33ae..5c10b55 100644 --- a/src/Services/Utilities/DatetimeCommand.php +++ b/src/Services/Utilities/DatetimeCommand.php @@ -6,8 +6,7 @@ class DatetimeCommand { - /** @var string */ - private $postalCode; + private string $postalCode; public function __construct(string $postalCode) { diff --git a/src/Services/Utilities/DatetimeService.php b/src/Services/Utilities/DatetimeService.php index 3353094..81f83cf 100644 --- a/src/Services/Utilities/DatetimeService.php +++ b/src/Services/Utilities/DatetimeService.php @@ -9,8 +9,7 @@ class DatetimeService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Utilities/DownloadXmlCommand.php b/src/Services/Utilities/DownloadXmlCommand.php index 7177fe7..4e86a07 100644 --- a/src/Services/Utilities/DownloadXmlCommand.php +++ b/src/Services/Utilities/DownloadXmlCommand.php @@ -6,14 +6,11 @@ class DownloadXmlCommand { - /** @var string */ - private $uuid; + private string $uuid; - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $type; + private string $type; public function __construct(string $uuid, string $rfc, string $type) { diff --git a/src/Services/Utilities/DownloadXmlService.php b/src/Services/Utilities/DownloadXmlService.php index 3a4196a..845de2b 100644 --- a/src/Services/Utilities/DownloadXmlService.php +++ b/src/Services/Utilities/DownloadXmlService.php @@ -9,8 +9,7 @@ class DownloadXmlService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Utilities/ReportCreditCommand.php b/src/Services/Utilities/ReportCreditCommand.php index 2f115f8..63f32e6 100644 --- a/src/Services/Utilities/ReportCreditCommand.php +++ b/src/Services/Utilities/ReportCreditCommand.php @@ -6,8 +6,7 @@ class ReportCreditCommand { - /** @var string */ - private $rfc; + private string $rfc; public function __construct(string $rfc) { diff --git a/src/Services/Utilities/ReportCreditResult.php b/src/Services/Utilities/ReportCreditResult.php index 560f514..f204db8 100644 --- a/src/Services/Utilities/ReportCreditResult.php +++ b/src/Services/Utilities/ReportCreditResult.php @@ -13,7 +13,7 @@ class ReportCreditResult extends AbstractResult use MethodsFilterVariablesTrait; /** @var array */ - private $items = []; + private array $items = []; public function __construct(stdClass $data) { diff --git a/src/Services/Utilities/ReportCreditService.php b/src/Services/Utilities/ReportCreditService.php index 1c54fdf..7024c58 100644 --- a/src/Services/Utilities/ReportCreditService.php +++ b/src/Services/Utilities/ReportCreditService.php @@ -9,8 +9,7 @@ class ReportCreditService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Utilities/ReportTotalCommand.php b/src/Services/Utilities/ReportTotalCommand.php index b1c5a7b..c3faa60 100644 --- a/src/Services/Utilities/ReportTotalCommand.php +++ b/src/Services/Utilities/ReportTotalCommand.php @@ -9,29 +9,21 @@ class ReportTotalCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $type; + private string $type; - /** @var int */ - private $startYear; + private int $startYear; - /** @var int */ - private $startMonth; + private int $startMonth; - /** @var int */ - private $endYear; + private int $endYear; - /** @var int */ - private $endMonth; + private int $endMonth; - /** @var string */ - private $startPeriod; + private string $startPeriod; - /** @var string */ - private $endPeriod; + private string $endPeriod; public function __construct( string $rfc, diff --git a/src/Services/Utilities/ReportTotalResult.php b/src/Services/Utilities/ReportTotalResult.php index 782c1d8..3524dd3 100644 --- a/src/Services/Utilities/ReportTotalResult.php +++ b/src/Services/Utilities/ReportTotalResult.php @@ -12,14 +12,11 @@ class ReportTotalResult extends AbstractResult { use MethodsFilterVariablesTrait; - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $total; + private string $total; - /** @var string */ - private $error; + private string $error; public function __construct(stdClass $data) { diff --git a/src/Services/Utilities/ReportTotalService.php b/src/Services/Utilities/ReportTotalService.php index d04bef4..30a0cbb 100644 --- a/src/Services/Utilities/ReportTotalService.php +++ b/src/Services/Utilities/ReportTotalService.php @@ -9,8 +9,7 @@ class ReportTotalService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/Services/Utilities/ReportUuidCommand.php b/src/Services/Utilities/ReportUuidCommand.php index 9c68be1..77199eb 100644 --- a/src/Services/Utilities/ReportUuidCommand.php +++ b/src/Services/Utilities/ReportUuidCommand.php @@ -9,17 +9,13 @@ class ReportUuidCommand { - /** @var string */ - private $rfc; + private string $rfc; - /** @var string */ - private $type; + private string $type; - /** @var DateTimeImmutable */ - private $since; + private DateTimeImmutable $since; - /** @var DateTimeImmutable */ - private $until; + private DateTimeImmutable $until; public function __construct(string $rfc, string $type, DateTimeImmutable $since, DateTimeImmutable $until) { diff --git a/src/Services/Utilities/ReportUuidResult.php b/src/Services/Utilities/ReportUuidResult.php index e2d6f6c..b824f47 100644 --- a/src/Services/Utilities/ReportUuidResult.php +++ b/src/Services/Utilities/ReportUuidResult.php @@ -13,7 +13,7 @@ class ReportUuidResult extends AbstractResult use MethodsFilterVariablesTrait; /** @var array */ - private $items = []; + private array $items = []; public function __construct(stdClass $data) { diff --git a/src/Services/Utilities/ReportUuidService.php b/src/Services/Utilities/ReportUuidService.php index cc4afbb..8efdb6c 100644 --- a/src/Services/Utilities/ReportUuidService.php +++ b/src/Services/Utilities/ReportUuidService.php @@ -9,8 +9,7 @@ class ReportUuidService { - /** @var FinkokSettings */ - private $settings; + private FinkokSettings $settings; public function __construct(FinkokSettings $settings) { diff --git a/src/SoapCaller.php b/src/SoapCaller.php index 4d2353d..4ae4be0 100644 --- a/src/SoapCaller.php +++ b/src/SoapCaller.php @@ -15,14 +15,12 @@ class SoapCaller implements LoggerAwareInterface { - /** @var SoapClient */ - private $soapClient; + private SoapClient $soapClient; /** @var array */ - private $extraParameters; + private array $extraParameters; - /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** * @param SoapClient $soapClient diff --git a/src/SoapFactory.php b/src/SoapFactory.php index 384c1c1..9339cce 100644 --- a/src/SoapFactory.php +++ b/src/SoapFactory.php @@ -11,8 +11,7 @@ class SoapFactory implements LoggerAwareInterface { - /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; public function __construct(LoggerInterface $logger = null) { diff --git a/tests/Factories/PreCfdiCreatorHelper.php b/tests/Factories/PreCfdiCreatorHelper.php index e64980e..9fd1098 100644 --- a/tests/Factories/PreCfdiCreatorHelper.php +++ b/tests/Factories/PreCfdiCreatorHelper.php @@ -12,35 +12,26 @@ final class PreCfdiCreatorHelper { - /** @var DateTimeImmutable */ - private $invoiceDate; + private DateTimeImmutable $invoiceDate; - /** @var string */ - private $conceptoDescription; + private string $conceptoDescription; - /** @var float */ - private $conceptoAmount; + private float $conceptoAmount; - /** @var string */ - private $emisorRfc; + private string $emisorRfc; - /** @var string */ - private $emisorName; + private string $emisorName; - /** @var string */ - private $cerFile; + private string $cerFile; - /** @var string */ - private $keyPemFile; + private string $keyPemFile; - /** @var string */ - private $passPhrase; + private string $passPhrase; - /** @var string */ - private $relation = ''; + private string $relation = ''; /** @var string[] */ - private $relatedUuids = []; + private array $relatedUuids = []; public function __construct( string $cerFile, @@ -143,7 +134,7 @@ public function create(): string 'LugarExpedicion' => '86000', 'Exportacion' => '01', // No aplica ]); - if ('' !== $this->relation && count($this->relatedUuids) > 0) { + if ('' !== $this->relation && [] !== $this->relatedUuids) { $relacionados = $comprobante->addCfdiRelacionados(['TipoRelacion' => $this->relation]); foreach ($this->relatedUuids as $relatedUuid) { $relacionados->addCfdiRelacionado(['UUID' => $relatedUuid]); diff --git a/tests/Factories/PreCfdiRetentionCreatorHelper.php b/tests/Factories/PreCfdiRetentionCreatorHelper.php index 2504c49..ba6b235 100644 --- a/tests/Factories/PreCfdiRetentionCreatorHelper.php +++ b/tests/Factories/PreCfdiRetentionCreatorHelper.php @@ -13,32 +13,23 @@ final class PreCfdiRetentionCreatorHelper { - /** @var Certificado */ - private $certificate; + private Certificado $certificate; - /** @var DateTimeImmutable */ - private $invoiceDate; + private DateTimeImmutable $invoiceDate; - /** @var string */ - private $cveReten; + private string $cveReten; - /** @var string */ - private $emisorRfc; + private string $emisorRfc; - /** @var string */ - private $emisorName; + private string $emisorName; - /** @var string */ - private $keyPemFile; + private string $keyPemFile; - /** @var string */ - private $passPhrase; + private string $passPhrase; - /** @var string */ - private $emisorLocation; + private string $emisorLocation; - /** @var string */ - private $emisorRegimen; + private string $emisorRegimen; public function __construct( string $cerFile, diff --git a/tests/Factories/RandomPreCfdiRetention.php b/tests/Factories/RandomPreCfdiRetention.php index c01dc35..e82cf95 100644 --- a/tests/Factories/RandomPreCfdiRetention.php +++ b/tests/Factories/RandomPreCfdiRetention.php @@ -68,12 +68,10 @@ public function createValid(): string 'You must fix your RET since its is not valid (%d errors):%s%s', count($assets->errors()), PHP_EOL, - implode(PHP_EOL, array_map(function (Assert $assert): string { - return rtrim( - sprintf('%s - %s: %s', $assert->getCode(), $assert->getTitle(), $assert->getExplanation()), - ' :' - ); - }, $assets->errors())) + implode(PHP_EOL, array_map(fn (Assert $assert): string => rtrim( + sprintf('%s - %s: %s', $assert->getCode(), $assert->getTitle(), $assert->getExplanation()), + ' :' + ), $assets->errors())) )); } diff --git a/tests/Fakes/FakeSoapCaller.php b/tests/Fakes/FakeSoapCaller.php index 538f38d..fd0c68d 100644 --- a/tests/Fakes/FakeSoapCaller.php +++ b/tests/Fakes/FakeSoapCaller.php @@ -9,14 +9,12 @@ final class FakeSoapCaller extends SoapCaller { - /** @var stdClass */ - public $preparedResult; + public stdClass $preparedResult; - /** @var string */ - public $latestCallMethodName = ''; + public string $latestCallMethodName = ''; /** @var array */ - public $latestCallParameters = []; + public array $latestCallParameters = []; /** @noinspection PhpMissingParentCallCommonInspection */ public function call(string $methodName, array $parameters): stdClass diff --git a/tests/Fakes/FakeSoapFactory.php b/tests/Fakes/FakeSoapFactory.php index 35a79b9..b691a3f 100644 --- a/tests/Fakes/FakeSoapFactory.php +++ b/tests/Fakes/FakeSoapFactory.php @@ -6,19 +6,23 @@ use PhpCfdi\Finkok\SoapCaller; use PhpCfdi\Finkok\SoapFactory; +use Psr\Log\LoggerInterface; use SoapClient; use stdClass; final class FakeSoapFactory extends SoapFactory { - /** @var FakeSoapCaller */ - public $latestSoapCaller; + public FakeSoapCaller $latestSoapCaller; - /** @var string */ - public $latestWsdlLocation; + public string $latestWsdlLocation; - /** @var stdClass */ - public $preparedResult; + public stdClass $preparedResult; + + public function __construct(LoggerInterface $logger = null) + { + parent::__construct($logger); + $this->preparedResult = (object) []; + } /** @noinspection PhpMissingParentCallCommonInspection */ public function createSoapClient(string $wsdlLocation): SoapClient diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index f01c2d4..8daa68a 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -23,11 +23,9 @@ abstract class IntegrationTestCase extends TestCase { - /** @var StampingResult|null */ - protected static $staticCurrentStampingResult; + protected static ?StampingResult $staticCurrentStampingResult = null; - /** @var StampingCommand|null */ - protected static $staticCurrentStampingCommand; + protected static ?StampingCommand $staticCurrentStampingCommand = null; public function newStampingCommand(): StampingCommand { diff --git a/tests/Integration/Services/Retentions/CancelSignatureServiceTest.php b/tests/Integration/Services/Retentions/CancelSignatureServiceTest.php index a7b1ff9..6531a6b 100644 --- a/tests/Integration/Services/Retentions/CancelSignatureServiceTest.php +++ b/tests/Integration/Services/Retentions/CancelSignatureServiceTest.php @@ -13,8 +13,7 @@ */ final class CancelSignatureServiceTest extends RetentionsTestCase { - /** @var QuickFinkok */ - private $quickFinkok; + private QuickFinkok $quickFinkok; protected function setUp(): void { diff --git a/tests/Integration/Services/Retentions/RetentionsUsingExistentRetentionTest.php b/tests/Integration/Services/Retentions/RetentionsUsingExistentRetentionTest.php index bacc326..ee0c3ff 100644 --- a/tests/Integration/Services/Retentions/RetentionsUsingExistentRetentionTest.php +++ b/tests/Integration/Services/Retentions/RetentionsUsingExistentRetentionTest.php @@ -13,14 +13,11 @@ */ final class RetentionsUsingExistentRetentionTest extends RetentionsTestCase { - /** @var QuickFinkok */ - private $quickFinkok; + private QuickFinkok $quickFinkok; - /** @var string|null */ - protected static $staticCurrentStampPrecfdi; + protected static ?string $staticCurrentStampPrecfdi = null; - /** @var StampResult|null */ - protected static $staticCurrentStampResult; + protected static ?StampResult $staticCurrentStampResult = null; protected function currentRetentionsPreCfdi(): string { diff --git a/tests/Unit/QuickFinkokTest.php b/tests/Unit/QuickFinkokTest.php index 7ac25bd..61a7719 100644 --- a/tests/Unit/QuickFinkokTest.php +++ b/tests/Unit/QuickFinkokTest.php @@ -23,8 +23,7 @@ /** @covers \PhpCfdi\Finkok\QuickFinkok */ final class QuickFinkokTest extends TestCase { - /** @var FakeSoapFactory */ - private $soapFactory; + private FakeSoapFactory $soapFactory; private function createdPreparedQuickFinkok(stdClass $rawData): QuickFinkok { diff --git a/tests/Unit/Services/AbstractResultTest.php b/tests/Unit/Services/AbstractResultTest.php index 1a1fbc2..fae4573 100644 --- a/tests/Unit/Services/AbstractResultTest.php +++ b/tests/Unit/Services/AbstractResultTest.php @@ -10,11 +10,9 @@ final class AbstractResultTest extends TestCase { - /** @var stdClass */ - private $data; + private stdClass $data; - /** @var TestingResult */ - private $result; + private TestingResult $result; protected function setUp(): void { diff --git a/tests/Unit/Services/Cancel/AcceptRejectUuidListTest.php b/tests/Unit/Services/Cancel/AcceptRejectUuidListTest.php index bf1bbc3..65b08f6 100644 --- a/tests/Unit/Services/Cancel/AcceptRejectUuidListTest.php +++ b/tests/Unit/Services/Cancel/AcceptRejectUuidListTest.php @@ -11,8 +11,7 @@ final class AcceptRejectUuidListTest extends TestCase { - /** @var AcceptRejectUuidList */ - private $list; + private AcceptRejectUuidList $list; protected function setUp(): void { diff --git a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php index 3343f53..001260d 100644 --- a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php +++ b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php @@ -143,8 +143,7 @@ public function testCreateWithStartPeriodInPastAndEndPeriodInFuture(): void $this->expectException(LogicException::class); $this->expectExceptionMessage('Cannot combine multiple past months with current/future months'); new class ($today, 'x-rfc', 'I', 2019, 1, $year, $month) extends ReportTotalCommand { - /** @var DateTimeImmutable */ - private $today; + private DateTimeImmutable $today; public function __construct( DateTimeImmutable $today, diff --git a/tests/stamp-precfdi-devenv.php b/tests/stamp-precfdi-devenv.php index 15011fe..d382fb1 100644 --- a/tests/stamp-precfdi-devenv.php +++ b/tests/stamp-precfdi-devenv.php @@ -16,8 +16,7 @@ require_once __DIR__ . '/bootstrap.php'; exit(call_user_func(new class ($argv[0] ?? '') { - /** @var string */ - private $command; + private string $command; public function __construct(string $command) { From aa6173cf18f452a06dc81e0fc56cd4de86dbe4c4 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:21:01 -0600 Subject: [PATCH 10/23] Bump to PHP 8.0 --- .github/workflows/build.yml | 2 +- .php-cs-fixer.dist.php | 4 +-- composer.json | 4 +-- src/Finkok.php | 19 ++++++------ src/FinkokEnvironment.php | 5 +--- src/FinkokSettings.php | 2 +- src/Helpers/AcceptRejectSigner.php | 10 ++----- src/Helpers/CancelSigner.php | 5 +--- src/Helpers/DocumentSigner.php | 11 +------ src/Helpers/FileLogger.php | 5 +--- src/Helpers/GetRelatedSigner.php | 5 +--- src/Helpers/JsonDecoderLogger.php | 9 ++---- src/QuickFinkok.php | 9 ++---- src/Services/AbstractResult.php | 7 ++--- .../Cancel/AcceptRejectSignatureCommand.php | 5 +--- .../Cancel/AcceptRejectSignatureService.php | 5 +--- src/Services/Cancel/AcceptRejectUuidItem.php | 16 ++++------ .../Cancel/CancelSignatureCommand.php | 5 +--- .../Cancel/CancelSignatureService.php | 5 +--- src/Services/Cancel/CancelledDocument.php | 5 +--- src/Services/Cancel/GetPendingCommand.php | 5 +--- src/Services/Cancel/GetPendingService.php | 5 +--- src/Services/Cancel/GetReceiptCommand.php | 11 +------ src/Services/Cancel/GetReceiptService.php | 5 +--- .../Cancel/GetRelatedSignatureCommand.php | 5 +--- .../Cancel/GetRelatedSignatureService.php | 5 +--- src/Services/Cancel/GetSatStatusCommand.php | 20 ++++--------- src/Services/Cancel/GetSatStatusService.php | 5 +--- src/Services/Cancel/RelatedItem.php | 11 +------ src/Services/Manifest/GetContractsCommand.php | 24 +++++---------- src/Services/Manifest/GetContractsService.php | 5 +--- .../Manifest/GetSignedContractsCommand.php | 11 +------ .../Manifest/GetSignedContractsService.php | 5 +--- .../Manifest/SignContractsCommand.php | 11 +------ .../Manifest/SignContractsService.php | 5 +--- src/Services/Registration/AddCommand.php | 20 +++---------- src/Services/Registration/AddService.php | 5 +--- src/Services/Registration/AssignCommand.php | 8 +---- src/Services/Registration/AssignService.php | 5 +--- src/Services/Registration/Customer.php | 5 +--- src/Services/Registration/EditCommand.php | 25 ++++------------ src/Services/Registration/EditService.php | 5 +--- .../Registration/ObtainCustomersCommand.php | 5 +--- .../Registration/ObtainCustomersService.php | 5 +--- src/Services/Registration/ObtainService.php | 5 +--- src/Services/Registration/PageInformation.php | 30 ++++--------------- src/Services/Registration/SwitchCommand.php | 8 +---- src/Services/Registration/SwitchService.php | 5 +--- .../Retentions/CancelSignatureService.php | 5 +--- src/Services/Retentions/StampService.php | 5 +--- src/Services/Retentions/StampedService.php | 5 +--- src/Services/Stamping/QueryPendingCommand.php | 5 +--- src/Services/Stamping/QueryPendingService.php | 5 +--- src/Services/Stamping/QuickStampService.php | 5 +--- src/Services/Stamping/StampService.php | 5 +--- src/Services/Stamping/StampedService.php | 5 +--- src/Services/Stamping/StampingAlert.php | 5 +--- src/Services/Stamping/StampingCommand.php | 5 +--- src/Services/Utilities/DatetimeCommand.php | 5 +--- src/Services/Utilities/DatetimeService.php | 5 +--- src/Services/Utilities/DownloadXmlCommand.php | 11 +------ src/Services/Utilities/DownloadXmlService.php | 7 ++--- .../Utilities/ReportCreditCommand.php | 5 +--- .../Utilities/ReportCreditService.php | 5 +--- src/Services/Utilities/ReportTotalCommand.php | 11 ++----- src/Services/Utilities/ReportTotalService.php | 5 +--- src/Services/Utilities/ReportUuidCommand.php | 22 +++++--------- src/Services/Utilities/ReportUuidService.php | 5 +--- src/SoapCaller.php | 17 ++++------- src/SoapFactory.php | 2 +- tests/Factories/PreCfdiCreatorHelper.php | 17 +++-------- .../PreCfdiRetentionCreatorHelper.php | 30 ++++--------------- tests/Fakes/FakeSoapFactory.php | 2 +- .../Cancel/GetRelatedSignatureServiceTest.php | 4 +-- tests/TestCase.php | 2 +- tests/Unit/FinkokTest.php | 6 ++-- tests/Unit/Helpers/AcceptRejectSignerTest.php | 2 +- tests/Unit/Helpers/GetRelatedSignerTest.php | 2 +- tests/Unit/Helpers/JsonDecoderLoggerTest.php | 12 ++++---- .../Utilities/ReportTotalCommandTest.php | 5 +--- tests/stamp-precfdi-devenv.php | 7 ++--- 81 files changed, 155 insertions(+), 486 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3470db0..8c5144c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] + php-version: ['8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7e02d37..945e40b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -15,8 +15,8 @@ ->setRules([ '@PSR12' => true, '@PSR12:risky' => true, - '@PHP7x4Migration' => true, - '@PHP7x4Migration:risky' => true, + '@PHP8x0Migration' => true, + '@PHP8x0Migration:risky' => true, // symfony 'class_attributes_separation' => true, 'whitespace_after_comma_in_array' => true, diff --git a/composer.json b/composer.json index 6a2fcb5..e07f2e2 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "source": "https://github.com/phpcfdi/finkok" }, "require": { - "php": ">=7.4", + "php": ">=8.0", "ext-dom": "*", "ext-json": "*", "ext-openssl": "*", @@ -36,7 +36,7 @@ }, "require-dev": { "ext-fileinfo": "*", - "eclipxe/cfdiutils": "^2.23.2", + "eclipxe/cfdiutils": "^3.0.1", "phpcfdi/rfc": "^1.1", "phpunit/phpunit": "^9.5.10", "symfony/dotenv": "^5.1 || ^6.0 || ^7.0" diff --git a/src/Finkok.php b/src/Finkok.php index 879eed7..4ca51a3 100644 --- a/src/Finkok.php +++ b/src/Finkok.php @@ -91,11 +91,8 @@ class Finkok ], ]; - private FinkokSettings $settings; - - public function __construct(FinkokSettings $factory) + public function __construct(private FinkokSettings $settings) { - $this->settings = $factory; } public function settings(): FinkokSettings @@ -123,17 +120,21 @@ public function __call(string $name, array $arguments) * @param mixed $command * @return object|null */ - protected function checkCommand(string $method, $command): ?object + protected function checkCommand(string $method, mixed $command): ?object { $expected = static::SERVICES_MAP[$method][1]; if ('' === $expected) { return null; } if (! is_object($command) || ! is_a($command, $expected)) { - $type = (is_object($command)) ? get_class($command) : gettype($command); - throw new InvalidArgumentException( - sprintf('Call %s::%s expect %s but received %s', static::class, $method, $expected, $type) + $message = sprintf( + 'Call %s::%s expect %s but received %s', + static::class, + $method, + $expected, + get_debug_type($command), ); + throw new InvalidArgumentException($message); } return $command; } @@ -159,7 +160,7 @@ protected function executeService(string $method, object $service, ?object $comm $method = static::SERVICES_MAP[$method][2] ?? $method; if (! is_callable([$service, $method])) { throw new BadMethodCallException( - sprintf('The service %s does not have a method %s', get_class($service), $method) + sprintf('The service %s does not have a method %s', $service::class, $method) ); } return $service->{$method}($command); diff --git a/src/FinkokEnvironment.php b/src/FinkokEnvironment.php index 3c83fbb..c1abfb4 100644 --- a/src/FinkokEnvironment.php +++ b/src/FinkokEnvironment.php @@ -6,11 +6,8 @@ class FinkokEnvironment { - private Definitions\Environment $environment; - - private function __construct(Definitions\Environment $environment) + private function __construct(private Definitions\Environment $environment) { - $this->environment = $environment; } public static function makeDevelopment(): self diff --git a/src/FinkokSettings.php b/src/FinkokSettings.php index e5cd228..a8328ca 100644 --- a/src/FinkokSettings.php +++ b/src/FinkokSettings.php @@ -20,7 +20,7 @@ class FinkokSettings private SoapFactory $soapFactory; - public function __construct(string $username, string $password, FinkokEnvironment $environment = null) + public function __construct(string $username, string $password, ?FinkokEnvironment $environment = null) { if ('' === $username) { throw new InvalidArgumentException('Invalid username'); diff --git a/src/Helpers/AcceptRejectSigner.php b/src/Helpers/AcceptRejectSigner.php index 848f2e1..c27a44f 100644 --- a/src/Helpers/AcceptRejectSigner.php +++ b/src/Helpers/AcceptRejectSigner.php @@ -15,10 +15,6 @@ class AcceptRejectSigner /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; - private string $uuid; - - private CancelAnswer $answer; - private string $pacRfc; private DateTimeImmutable $dateTime; @@ -32,13 +28,11 @@ class AcceptRejectSigner * @param string $pacRfc If empty or omitted then uses DEFAULT_PACRFC */ public function __construct( - string $uuid, - CancelAnswer $answer, + private string $uuid, + private CancelAnswer $answer, ?DateTimeImmutable $dateTime = null, string $pacRfc = self::DEFAULT_PACRFC ) { - $this->uuid = $uuid; - $this->answer = $answer; $this->dateTime = $dateTime ?? new DateTimeImmutable(); $this->pacRfc = $pacRfc ?: static::DEFAULT_PACRFC; } diff --git a/src/Helpers/CancelSigner.php b/src/Helpers/CancelSigner.php index 4afcf09..dee84d8 100644 --- a/src/Helpers/CancelSigner.php +++ b/src/Helpers/CancelSigner.php @@ -12,8 +12,6 @@ class CancelSigner { - private CancelDocuments $documents; - private DateTimeImmutable $dateTime; /** @@ -22,9 +20,8 @@ class CancelSigner * @param CancelDocuments $documents * @param DateTimeImmutable|null $dateTime If null or ommited then use current time and time zone */ - public function __construct(CancelDocuments $documents, ?DateTimeImmutable $dateTime = null) + public function __construct(private CancelDocuments $documents, ?DateTimeImmutable $dateTime = null) { - $this->documents = $documents; $this->dateTime = $dateTime ?? new DateTimeImmutable(); } diff --git a/src/Helpers/DocumentSigner.php b/src/Helpers/DocumentSigner.php index c351fa1..dc5ab1f 100644 --- a/src/Helpers/DocumentSigner.php +++ b/src/Helpers/DocumentSigner.php @@ -13,17 +13,8 @@ class DocumentSigner { - private string $rfc; - - private DateTimeImmutable $date; - - private string $content; - - public function __construct(string $rfc, DateTimeImmutable $date, string $content) + public function __construct(private string $rfc, private DateTimeImmutable $date, private string $content) { - $this->rfc = $rfc; - $this->date = $date; - $this->content = $content; } public function rfc(): string diff --git a/src/Helpers/FileLogger.php b/src/Helpers/FileLogger.php index 2a435cb..ebfb8c9 100644 --- a/src/Helpers/FileLogger.php +++ b/src/Helpers/FileLogger.php @@ -9,11 +9,8 @@ final class FileLogger extends AbstractLogger implements LoggerInterface { - public string $outputFile; - - public function __construct(string $outputFile = 'php://stdout') + public function __construct(public string $outputFile = 'php://stdout') { - $this->outputFile = $outputFile; } /** diff --git a/src/Helpers/GetRelatedSigner.php b/src/Helpers/GetRelatedSigner.php index fcd420f..670542f 100644 --- a/src/Helpers/GetRelatedSigner.php +++ b/src/Helpers/GetRelatedSigner.php @@ -14,8 +14,6 @@ class GetRelatedSigner /** @var string */ public const DEFAULT_PACRFC = 'CVD110412TF6'; - private string $uuid; - private RfcRole $role; private string $pacRfc; @@ -27,9 +25,8 @@ class GetRelatedSigner * @param RfcRole|null $role If null or omitted then uses issuer role * @param string $pacRfc If empty or omitted then uses DEFAULT_PACRFC */ - public function __construct(string $uuid, RfcRole $role = null, string $pacRfc = self::DEFAULT_PACRFC) + public function __construct(private string $uuid, ?RfcRole $role = null, string $pacRfc = self::DEFAULT_PACRFC) { - $this->uuid = $uuid; $this->role = $role ?? RfcRole::issuer(); $this->pacRfc = $pacRfc ?: static::DEFAULT_PACRFC; } diff --git a/src/Helpers/JsonDecoderLogger.php b/src/Helpers/JsonDecoderLogger.php index cc75a97..7588e81 100644 --- a/src/Helpers/JsonDecoderLogger.php +++ b/src/Helpers/JsonDecoderLogger.php @@ -20,17 +20,14 @@ */ final class JsonDecoderLogger extends AbstractLogger implements LoggerInterface { - private LoggerInterface $logger; - private bool $useJsonValidateIfAvailable = true; private bool $alsoLogJsonMessage = false; private bool $lastMessageWasJsonValid = false; - public function __construct(LoggerInterface $logger) + public function __construct(private LoggerInterface $logger) { - $this->logger = $logger; } /** @@ -39,7 +36,7 @@ public function __construct(LoggerInterface $logger) * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el espado previo. * @return bool El estado previo */ - public function setUseJsonValidateIfAvailable(bool $value = null): bool + public function setUseJsonValidateIfAvailable(?bool $value = null): bool { $previous = $this->useJsonValidateIfAvailable; if (null !== $value) { @@ -54,7 +51,7 @@ public function setUseJsonValidateIfAvailable(bool $value = null): bool * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el espado previo. * @return bool El estado previo */ - public function setAlsoLogJsonMessage(bool $value = null): bool + public function setAlsoLogJsonMessage(?bool $value = null): bool { $previous = $this->alsoLogJsonMessage; if (null !== $value) { diff --git a/src/QuickFinkok.php b/src/QuickFinkok.php index 9594c37..bc4a77b 100644 --- a/src/QuickFinkok.php +++ b/src/QuickFinkok.php @@ -21,11 +21,8 @@ class QuickFinkok { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $factory) + public function __construct(private FinkokSettings $settings) { - $this->settings = $factory; } /** @@ -186,7 +183,7 @@ public function satStatusXml(string $xmlCfdi): Cancel\GetSatStatusResult public function obtainRelated( Credential $credential, string $uuid, - RfcRole $role = null + ?RfcRole $role = null ): Cancel\GetRelatedSignatureResult { $signer = new Helpers\GetRelatedSigner($uuid, $role); $signedRequest = $signer->sign($credential); @@ -493,7 +490,7 @@ public function customerSignAndSendContracts( public function customerGetSignedContracts( string $snid, string $rfc, - SignedDocumentFormat $format = null + ?SignedDocumentFormat $format = null ): Manifest\GetSignedContractsResult { $format ??= SignedDocumentFormat::xml(); $command = new Manifest\GetSignedContractsCommand($snid, $rfc, $format); diff --git a/src/Services/AbstractResult.php b/src/Services/AbstractResult.php index 1d4fe61..3785115 100644 --- a/src/Services/AbstractResult.php +++ b/src/Services/AbstractResult.php @@ -12,14 +12,11 @@ abstract class AbstractResult { use MethodsFilterVariablesTrait; - protected stdClass $data; - protected stdClass $root; - public function __construct(stdClass $data, string ...$meanLocation) + public function __construct(protected stdClass $data, string ...$meanLocation) { - $this->data = $data; - $root = $this->findInDescendent($data, ...$meanLocation); + $root = $this->findInDescendent($this->data, ...$meanLocation); if (! $root instanceof stdClass) { throw new InvalidArgumentException( sprintf('Unable to find mean object at /%s', implode('/', $meanLocation)) diff --git a/src/Services/Cancel/AcceptRejectSignatureCommand.php b/src/Services/Cancel/AcceptRejectSignatureCommand.php index 9cd669f..74cf770 100644 --- a/src/Services/Cancel/AcceptRejectSignatureCommand.php +++ b/src/Services/Cancel/AcceptRejectSignatureCommand.php @@ -6,11 +6,8 @@ class AcceptRejectSignatureCommand { - private string $xml; - - public function __construct(string $xml) + public function __construct(private string $xml) { - $this->xml = $xml; } public function xml(): string diff --git a/src/Services/Cancel/AcceptRejectSignatureService.php b/src/Services/Cancel/AcceptRejectSignatureService.php index 21a5ed5..5688ade 100644 --- a/src/Services/Cancel/AcceptRejectSignatureService.php +++ b/src/Services/Cancel/AcceptRejectSignatureService.php @@ -9,11 +9,8 @@ class AcceptRejectSignatureService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/AcceptRejectUuidItem.php b/src/Services/Cancel/AcceptRejectUuidItem.php index 939b4fc..b19b381 100644 --- a/src/Services/Cancel/AcceptRejectUuidItem.php +++ b/src/Services/Cancel/AcceptRejectUuidItem.php @@ -8,17 +8,11 @@ class AcceptRejectUuidItem { - private string $uuid; - - private AcceptRejectUuidStatus $status; - - private CancelAnswer $answer; - - public function __construct(string $uuid, AcceptRejectUuidStatus $status, CancelAnswer $answer) - { - $this->uuid = $uuid; - $this->status = $status; - $this->answer = $answer; + public function __construct( + private string $uuid, + private AcceptRejectUuidStatus $status, + private CancelAnswer $answer, + ) { } public function uuid(): string diff --git a/src/Services/Cancel/CancelSignatureCommand.php b/src/Services/Cancel/CancelSignatureCommand.php index 455b371..e4b34bd 100644 --- a/src/Services/Cancel/CancelSignatureCommand.php +++ b/src/Services/Cancel/CancelSignatureCommand.php @@ -8,8 +8,6 @@ class CancelSignatureCommand { - private string $xml; - private CancelStorePending $storePending; /** @@ -18,9 +16,8 @@ class CancelSignatureCommand * @param string $xml The signed xml * @param CancelStorePending|null $storePending Defaults to CancelStorePending::no() */ - public function __construct(string $xml, CancelStorePending $storePending = null) + public function __construct(private string $xml, ?CancelStorePending $storePending = null) { - $this->xml = $xml; $this->storePending = $storePending ?? CancelStorePending::no(); } diff --git a/src/Services/Cancel/CancelSignatureService.php b/src/Services/Cancel/CancelSignatureService.php index 28273fd..e10587c 100644 --- a/src/Services/Cancel/CancelSignatureService.php +++ b/src/Services/Cancel/CancelSignatureService.php @@ -9,11 +9,8 @@ class CancelSignatureService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/CancelledDocument.php b/src/Services/Cancel/CancelledDocument.php index 8a7e558..503d8fe 100644 --- a/src/Services/Cancel/CancelledDocument.php +++ b/src/Services/Cancel/CancelledDocument.php @@ -11,11 +11,8 @@ class CancelledDocument { use MethodsFilterVariablesTrait; - private stdClass $data; - - public function __construct(stdClass $raw) + public function __construct(private stdClass $data) { - $this->data = $raw; } private function get(string $keyword): string diff --git a/src/Services/Cancel/GetPendingCommand.php b/src/Services/Cancel/GetPendingCommand.php index 4fe3e09..05ea65a 100644 --- a/src/Services/Cancel/GetPendingCommand.php +++ b/src/Services/Cancel/GetPendingCommand.php @@ -6,11 +6,8 @@ class GetPendingCommand { - private string $rfc; - - public function __construct(string $rfc) + public function __construct(private string $rfc) { - $this->rfc = $rfc; } public function rfc(): string diff --git a/src/Services/Cancel/GetPendingService.php b/src/Services/Cancel/GetPendingService.php index 7a82f2b..74e8465 100644 --- a/src/Services/Cancel/GetPendingService.php +++ b/src/Services/Cancel/GetPendingService.php @@ -9,11 +9,8 @@ class GetPendingService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/GetReceiptCommand.php b/src/Services/Cancel/GetReceiptCommand.php index a82e1ca..38084e2 100644 --- a/src/Services/Cancel/GetReceiptCommand.php +++ b/src/Services/Cancel/GetReceiptCommand.php @@ -8,17 +8,8 @@ class GetReceiptCommand { - private string $rfc; - - private string $uuid; - - private ReceiptType $type; - - public function __construct(string $rfc, string $uuid, ReceiptType $type) + public function __construct(private string $rfc, private string $uuid, private ReceiptType $type) { - $this->rfc = $rfc; - $this->uuid = $uuid; - $this->type = $type; } public function uuid(): string diff --git a/src/Services/Cancel/GetReceiptService.php b/src/Services/Cancel/GetReceiptService.php index 76be9ea..acaaada 100644 --- a/src/Services/Cancel/GetReceiptService.php +++ b/src/Services/Cancel/GetReceiptService.php @@ -9,11 +9,8 @@ class GetReceiptService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/GetRelatedSignatureCommand.php b/src/Services/Cancel/GetRelatedSignatureCommand.php index cfcb6ed..e55bedc 100644 --- a/src/Services/Cancel/GetRelatedSignatureCommand.php +++ b/src/Services/Cancel/GetRelatedSignatureCommand.php @@ -6,11 +6,8 @@ class GetRelatedSignatureCommand { - private string $xml; - - public function __construct(string $xml) + public function __construct(private string $xml) { - $this->xml = $xml; } public function xml(): string diff --git a/src/Services/Cancel/GetRelatedSignatureService.php b/src/Services/Cancel/GetRelatedSignatureService.php index aadf80a..6b1978a 100644 --- a/src/Services/Cancel/GetRelatedSignatureService.php +++ b/src/Services/Cancel/GetRelatedSignatureService.php @@ -9,11 +9,8 @@ class GetRelatedSignatureService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/GetSatStatusCommand.php b/src/Services/Cancel/GetSatStatusCommand.php index b18767e..14fa989 100644 --- a/src/Services/Cancel/GetSatStatusCommand.php +++ b/src/Services/Cancel/GetSatStatusCommand.php @@ -6,20 +6,12 @@ class GetSatStatusCommand { - private string $rfcIssuer; - - private string $rfcRecipient; - - private string $uuid; - - private string $total; - - public function __construct(string $rfcIssuer, string $rfcRecipient, string $uuid, string $total) - { - $this->rfcIssuer = $rfcIssuer; - $this->rfcRecipient = $rfcRecipient; - $this->uuid = $uuid; - $this->total = $total; + public function __construct( + private string $rfcIssuer, + private string $rfcRecipient, + private string $uuid, + private string $total, + ) { } public function rfcIssuer(): string diff --git a/src/Services/Cancel/GetSatStatusService.php b/src/Services/Cancel/GetSatStatusService.php index 37b0236..7acb7b7 100644 --- a/src/Services/Cancel/GetSatStatusService.php +++ b/src/Services/Cancel/GetSatStatusService.php @@ -9,11 +9,8 @@ class GetSatStatusService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Cancel/RelatedItem.php b/src/Services/Cancel/RelatedItem.php index dc57713..9304398 100644 --- a/src/Services/Cancel/RelatedItem.php +++ b/src/Services/Cancel/RelatedItem.php @@ -6,17 +6,8 @@ class RelatedItem { - private string $uuid; - - private string $rfcEmitter; - - private string $rfcReceiver; - - public function __construct(string $uuid, string $rfcEmitter, string $rfcReceiver) + public function __construct(private string $uuid, private string $rfcEmitter, private string $rfcReceiver) { - $this->uuid = $uuid; - $this->rfcEmitter = $rfcEmitter; - $this->rfcReceiver = $rfcReceiver; } public function uuid(): string diff --git a/src/Services/Manifest/GetContractsCommand.php b/src/Services/Manifest/GetContractsCommand.php index 064e07d..545616e 100644 --- a/src/Services/Manifest/GetContractsCommand.php +++ b/src/Services/Manifest/GetContractsCommand.php @@ -6,23 +6,13 @@ class GetContractsCommand { - private string $rfc; - - private string $name; - - private string $address; - - private string $email; - - private string $snid; - - public function __construct(string $rfc, string $name, string $address, string $email, string $snid) - { - $this->rfc = $rfc; - $this->name = $name; - $this->address = $address; - $this->email = $email; - $this->snid = $snid; + public function __construct( + private string $rfc, + private string $name, + private string $address, + private string $email, + private string $snid + ) { } public function rfc(): string diff --git a/src/Services/Manifest/GetContractsService.php b/src/Services/Manifest/GetContractsService.php index daa332c..2360c79 100644 --- a/src/Services/Manifest/GetContractsService.php +++ b/src/Services/Manifest/GetContractsService.php @@ -9,11 +9,8 @@ class GetContractsService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Manifest/GetSignedContractsCommand.php b/src/Services/Manifest/GetSignedContractsCommand.php index 2290cee..99edebb 100644 --- a/src/Services/Manifest/GetSignedContractsCommand.php +++ b/src/Services/Manifest/GetSignedContractsCommand.php @@ -8,17 +8,8 @@ class GetSignedContractsCommand { - private string $snid; - - private string $rfc; - - private SignedDocumentFormat $format; - - public function __construct(string $snid, string $rfc, SignedDocumentFormat $format) + public function __construct(private string $snid, private string $rfc, private SignedDocumentFormat $format) { - $this->snid = $snid; - $this->rfc = $rfc; - $this->format = $format; } public function snid(): string diff --git a/src/Services/Manifest/GetSignedContractsService.php b/src/Services/Manifest/GetSignedContractsService.php index 5bde2a7..dbf0245 100644 --- a/src/Services/Manifest/GetSignedContractsService.php +++ b/src/Services/Manifest/GetSignedContractsService.php @@ -9,11 +9,8 @@ class GetSignedContractsService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Manifest/SignContractsCommand.php b/src/Services/Manifest/SignContractsCommand.php index b6e0591..8a2c559 100644 --- a/src/Services/Manifest/SignContractsCommand.php +++ b/src/Services/Manifest/SignContractsCommand.php @@ -6,17 +6,8 @@ class SignContractsCommand { - private string $snid; - - private string $privacy; - - private string $contract; - - public function __construct(string $snid, string $privacy, string $contract) + public function __construct(private string $snid, private string $privacy, private string $contract) { - $this->snid = $snid; - $this->privacy = $privacy; - $this->contract = $contract; } public function snid(): string diff --git a/src/Services/Manifest/SignContractsService.php b/src/Services/Manifest/SignContractsService.php index 353534c..56b094b 100644 --- a/src/Services/Manifest/SignContractsService.php +++ b/src/Services/Manifest/SignContractsService.php @@ -9,11 +9,8 @@ class SignContractsService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/AddCommand.php b/src/Services/Registration/AddCommand.php index da0544e..199e585 100644 --- a/src/Services/Registration/AddCommand.php +++ b/src/Services/Registration/AddCommand.php @@ -6,28 +6,16 @@ class AddCommand { - private string $rfc; - private CustomerType $type; - private string $certificate; - - private string $privateKey; - - private string $passPhrase; - public function __construct( - string $rfc, + private string $rfc, ?CustomerType $type = null, - string $certificate = '', - string $privateKey = '', - string $passPhrase = '' + private string $certificate = '', + private string $privateKey = '', + private string $passPhrase = '' ) { - $this->rfc = $rfc; $this->type = $type ?? CustomerType::ondemand(); - $this->certificate = $certificate; - $this->privateKey = $privateKey; - $this->passPhrase = $passPhrase; } public function rfc(): string diff --git a/src/Services/Registration/AddService.php b/src/Services/Registration/AddService.php index 87da654..3252077 100644 --- a/src/Services/Registration/AddService.php +++ b/src/Services/Registration/AddService.php @@ -9,11 +9,8 @@ class AddService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/AssignCommand.php b/src/Services/Registration/AssignCommand.php index 8919936..286f60d 100644 --- a/src/Services/Registration/AssignCommand.php +++ b/src/Services/Registration/AssignCommand.php @@ -6,14 +6,8 @@ class AssignCommand { - private string $rfc; - - private int $credit; - - public function __construct(string $rfc, int $credit) + public function __construct(private string $rfc, private int $credit) { - $this->rfc = $rfc; - $this->credit = $credit; } public function rfc(): string diff --git a/src/Services/Registration/AssignService.php b/src/Services/Registration/AssignService.php index 72757bb..6f0885a 100644 --- a/src/Services/Registration/AssignService.php +++ b/src/Services/Registration/AssignService.php @@ -9,11 +9,8 @@ class AssignService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/Customer.php b/src/Services/Registration/Customer.php index 8c1dbcd..51cc473 100644 --- a/src/Services/Registration/Customer.php +++ b/src/Services/Registration/Customer.php @@ -11,15 +11,12 @@ class Customer { use MethodsFilterVariablesTrait; - private stdClass $data; - private CustomerStatus $status; private CustomerType $type; - public function __construct(stdClass $raw) + public function __construct(private stdClass $data) { - $this->data = $raw; $rawStatus = $this->get('status'); if (in_array($rawStatus, CustomerStatus::toArray())) { $this->status = new CustomerStatus($rawStatus); diff --git a/src/Services/Registration/EditCommand.php b/src/Services/Registration/EditCommand.php index ca002be..d3344f2 100644 --- a/src/Services/Registration/EditCommand.php +++ b/src/Services/Registration/EditCommand.php @@ -6,28 +6,13 @@ class EditCommand { - private string $rfc; - - private CustomerStatus $status; - - private string $certificate; - - private string $privateKey; - - private string $passPhrase; - public function __construct( - string $rfc, - CustomerStatus $status, - string $certificate = '', - string $privateKey = '', - string $passPhrase = '' + private string $rfc, + private CustomerStatus $status, + private string $certificate = '', + private string $privateKey = '', + private string $passPhrase = '', ) { - $this->rfc = $rfc; - $this->status = $status; - $this->certificate = $certificate; - $this->privateKey = $privateKey; - $this->passPhrase = $passPhrase; } public function rfc(): string diff --git a/src/Services/Registration/EditService.php b/src/Services/Registration/EditService.php index ef54fe3..db92193 100644 --- a/src/Services/Registration/EditService.php +++ b/src/Services/Registration/EditService.php @@ -9,11 +9,8 @@ class EditService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/ObtainCustomersCommand.php b/src/Services/Registration/ObtainCustomersCommand.php index 0f542e0..36442f2 100644 --- a/src/Services/Registration/ObtainCustomersCommand.php +++ b/src/Services/Registration/ObtainCustomersCommand.php @@ -6,11 +6,8 @@ class ObtainCustomersCommand { - private int $page; - - public function __construct(int $page) + public function __construct(private int $page) { - $this->page = $page; } public function page(): int diff --git a/src/Services/Registration/ObtainCustomersService.php b/src/Services/Registration/ObtainCustomersService.php index a93731c..c0eec5c 100644 --- a/src/Services/Registration/ObtainCustomersService.php +++ b/src/Services/Registration/ObtainCustomersService.php @@ -9,11 +9,8 @@ class ObtainCustomersService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/ObtainService.php b/src/Services/Registration/ObtainService.php index 2acffc5..d132740 100644 --- a/src/Services/Registration/ObtainService.php +++ b/src/Services/Registration/ObtainService.php @@ -9,11 +9,8 @@ class ObtainService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Registration/PageInformation.php b/src/Services/Registration/PageInformation.php index d4c587c..acad73a 100644 --- a/src/Services/Registration/PageInformation.php +++ b/src/Services/Registration/PageInformation.php @@ -6,32 +6,14 @@ class PageInformation { - private int $firstRecord; - - private int $lastRecord; - - private int $totalRecords; - - private int $currentPage; - - private int $totalPages; - - private int $pageLength; - public function __construct( - int $firstRecord, - int $lastRecord, - int $totalRecords, - int $currentPage, - int $totalPages, - int $pageLength + private int $firstRecord, + private int $lastRecord, + private int $totalRecords, + private int $currentPage, + private int $totalPages, + private int $pageLength, ) { - $this->firstRecord = $firstRecord; - $this->lastRecord = $lastRecord; - $this->totalRecords = $totalRecords; - $this->currentPage = $currentPage; - $this->totalPages = $totalPages; - $this->pageLength = $pageLength; } public static function empty(): self diff --git a/src/Services/Registration/SwitchCommand.php b/src/Services/Registration/SwitchCommand.php index 0b2613d..25e99e4 100644 --- a/src/Services/Registration/SwitchCommand.php +++ b/src/Services/Registration/SwitchCommand.php @@ -6,14 +6,8 @@ class SwitchCommand { - private string $rfc; - - private CustomerType $customerType; - - public function __construct(string $rfc, CustomerType $customerType) + public function __construct(private string $rfc, private CustomerType $customerType) { - $this->rfc = $rfc; - $this->customerType = $customerType; } public function rfc(): string diff --git a/src/Services/Registration/SwitchService.php b/src/Services/Registration/SwitchService.php index 3eb7aed..acb46cf 100644 --- a/src/Services/Registration/SwitchService.php +++ b/src/Services/Registration/SwitchService.php @@ -9,11 +9,8 @@ class SwitchService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Retentions/CancelSignatureService.php b/src/Services/Retentions/CancelSignatureService.php index cdc1806..6002cd3 100644 --- a/src/Services/Retentions/CancelSignatureService.php +++ b/src/Services/Retentions/CancelSignatureService.php @@ -9,11 +9,8 @@ class CancelSignatureService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Retentions/StampService.php b/src/Services/Retentions/StampService.php index 9cb52dc..cd2130f 100644 --- a/src/Services/Retentions/StampService.php +++ b/src/Services/Retentions/StampService.php @@ -9,11 +9,8 @@ class StampService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Retentions/StampedService.php b/src/Services/Retentions/StampedService.php index 95f6a95..bbc622d 100644 --- a/src/Services/Retentions/StampedService.php +++ b/src/Services/Retentions/StampedService.php @@ -9,11 +9,8 @@ class StampedService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Stamping/QueryPendingCommand.php b/src/Services/Stamping/QueryPendingCommand.php index 1ab30cd..c4d58bf 100644 --- a/src/Services/Stamping/QueryPendingCommand.php +++ b/src/Services/Stamping/QueryPendingCommand.php @@ -6,11 +6,8 @@ class QueryPendingCommand { - private string $uuid; - - public function __construct(string $uuid) + public function __construct(private string $uuid) { - $this->uuid = $uuid; } public function uuid(): string diff --git a/src/Services/Stamping/QueryPendingService.php b/src/Services/Stamping/QueryPendingService.php index a034895..1b5e823 100644 --- a/src/Services/Stamping/QueryPendingService.php +++ b/src/Services/Stamping/QueryPendingService.php @@ -9,11 +9,8 @@ class QueryPendingService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Stamping/QuickStampService.php b/src/Services/Stamping/QuickStampService.php index 0ff0406..dc4e598 100644 --- a/src/Services/Stamping/QuickStampService.php +++ b/src/Services/Stamping/QuickStampService.php @@ -9,11 +9,8 @@ class QuickStampService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Stamping/StampService.php b/src/Services/Stamping/StampService.php index dce51b5..1fd8d4d 100644 --- a/src/Services/Stamping/StampService.php +++ b/src/Services/Stamping/StampService.php @@ -9,11 +9,8 @@ class StampService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Stamping/StampedService.php b/src/Services/Stamping/StampedService.php index 84d4f13..75b7008 100644 --- a/src/Services/Stamping/StampedService.php +++ b/src/Services/Stamping/StampedService.php @@ -9,11 +9,8 @@ class StampedService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Stamping/StampingAlert.php b/src/Services/Stamping/StampingAlert.php index 54a7d24..1e897ae 100644 --- a/src/Services/Stamping/StampingAlert.php +++ b/src/Services/Stamping/StampingAlert.php @@ -11,11 +11,8 @@ class StampingAlert { use MethodsFilterVariablesTrait; - private stdClass $data; - - public function __construct(stdClass $raw) + public function __construct(private stdClass $data) { - $this->data = $raw; } private function get(string $keyword): string diff --git a/src/Services/Stamping/StampingCommand.php b/src/Services/Stamping/StampingCommand.php index 1ac1443..f5e8083 100644 --- a/src/Services/Stamping/StampingCommand.php +++ b/src/Services/Stamping/StampingCommand.php @@ -6,11 +6,8 @@ class StampingCommand { - private string $xml; - - public function __construct(string $xml) + public function __construct(private string $xml) { - $this->xml = $xml; } public function xml(): string diff --git a/src/Services/Utilities/DatetimeCommand.php b/src/Services/Utilities/DatetimeCommand.php index 5c10b55..9a0ab27 100644 --- a/src/Services/Utilities/DatetimeCommand.php +++ b/src/Services/Utilities/DatetimeCommand.php @@ -6,11 +6,8 @@ class DatetimeCommand { - private string $postalCode; - - public function __construct(string $postalCode) + public function __construct(private string $postalCode) { - $this->postalCode = $postalCode; } public function postalCode(): string diff --git a/src/Services/Utilities/DatetimeService.php b/src/Services/Utilities/DatetimeService.php index 81f83cf..4259da5 100644 --- a/src/Services/Utilities/DatetimeService.php +++ b/src/Services/Utilities/DatetimeService.php @@ -9,11 +9,8 @@ class DatetimeService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Utilities/DownloadXmlCommand.php b/src/Services/Utilities/DownloadXmlCommand.php index 4e86a07..5c5e051 100644 --- a/src/Services/Utilities/DownloadXmlCommand.php +++ b/src/Services/Utilities/DownloadXmlCommand.php @@ -6,17 +6,8 @@ class DownloadXmlCommand { - private string $uuid; - - private string $rfc; - - private string $type; - - public function __construct(string $uuid, string $rfc, string $type) + public function __construct(private string $uuid, private string $rfc, private string $type) { - $this->uuid = $uuid; - $this->rfc = $rfc; - $this->type = $type; } public function uuid(): string diff --git a/src/Services/Utilities/DownloadXmlService.php b/src/Services/Utilities/DownloadXmlService.php index 845de2b..4a8e727 100644 --- a/src/Services/Utilities/DownloadXmlService.php +++ b/src/Services/Utilities/DownloadXmlService.php @@ -9,11 +9,8 @@ class DownloadXmlService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings @@ -32,7 +29,7 @@ public function downloadXml(DownloadXmlCommand $command): DownloadXmlResult ]); $result = new DownloadXmlResult($rawResponse); // Finkok sometimes returns the path to the file instead of content (Ticket #18950) - if ('.xml' === substr($result->xml(), -4)) { + if (str_ends_with($result->xml(), '.xml')) { usleep(200000); // 0.2 seconds continue; } diff --git a/src/Services/Utilities/ReportCreditCommand.php b/src/Services/Utilities/ReportCreditCommand.php index 63f32e6..63bb8d0 100644 --- a/src/Services/Utilities/ReportCreditCommand.php +++ b/src/Services/Utilities/ReportCreditCommand.php @@ -6,11 +6,8 @@ class ReportCreditCommand { - private string $rfc; - - public function __construct(string $rfc) + public function __construct(private string $rfc) { - $this->rfc = $rfc; } public function rfc(): string diff --git a/src/Services/Utilities/ReportCreditService.php b/src/Services/Utilities/ReportCreditService.php index 7024c58..cd5c764 100644 --- a/src/Services/Utilities/ReportCreditService.php +++ b/src/Services/Utilities/ReportCreditService.php @@ -9,11 +9,8 @@ class ReportCreditService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Utilities/ReportTotalCommand.php b/src/Services/Utilities/ReportTotalCommand.php index c3faa60..1326d12 100644 --- a/src/Services/Utilities/ReportTotalCommand.php +++ b/src/Services/Utilities/ReportTotalCommand.php @@ -9,10 +9,6 @@ class ReportTotalCommand { - private string $rfc; - - private string $type; - private int $startYear; private int $startMonth; @@ -26,8 +22,8 @@ class ReportTotalCommand private string $endPeriod; public function __construct( - string $rfc, - string $type, + private string $rfc, + private string $type, int $startYear, int $startMonth, int $endYear = 0, @@ -38,9 +34,6 @@ public function __construct( $today = $this->today(); $currentYear = intval($today->format('Y')); $currentPeriod = sprintf('%04d-%02d', $currentYear, intval($today->format('m'))); - - $this->rfc = $rfc; - $this->type = $type; $this->startYear = $startYear; $this->startMonth = $startMonth; $this->endYear = $endYear; diff --git a/src/Services/Utilities/ReportTotalService.php b/src/Services/Utilities/ReportTotalService.php index 30a0cbb..5813411 100644 --- a/src/Services/Utilities/ReportTotalService.php +++ b/src/Services/Utilities/ReportTotalService.php @@ -9,11 +9,8 @@ class ReportTotalService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/Services/Utilities/ReportUuidCommand.php b/src/Services/Utilities/ReportUuidCommand.php index 77199eb..2b2baa1 100644 --- a/src/Services/Utilities/ReportUuidCommand.php +++ b/src/Services/Utilities/ReportUuidCommand.php @@ -9,23 +9,15 @@ class ReportUuidCommand { - private string $rfc; - - private string $type; - - private DateTimeImmutable $since; - - private DateTimeImmutable $until; - - public function __construct(string $rfc, string $type, DateTimeImmutable $since, DateTimeImmutable $until) - { - if ($since > $until) { + public function __construct( + private string $rfc, + private string $type, + private DateTimeImmutable $since, + private DateTimeImmutable $until, + ) { + if ($this->since > $this->until) { throw new LogicException('Since date is greater than until date'); } - $this->rfc = $rfc; - $this->type = $type; - $this->since = $since; - $this->until = $until; } public function rfc(): string diff --git a/src/Services/Utilities/ReportUuidService.php b/src/Services/Utilities/ReportUuidService.php index 8efdb6c..3be5fd0 100644 --- a/src/Services/Utilities/ReportUuidService.php +++ b/src/Services/Utilities/ReportUuidService.php @@ -9,11 +9,8 @@ class ReportUuidService { - private FinkokSettings $settings; - - public function __construct(FinkokSettings $settings) + public function __construct(private FinkokSettings $settings) { - $this->settings = $settings; } public function settings(): FinkokSettings diff --git a/src/SoapCaller.php b/src/SoapCaller.php index 4ae4be0..7a967f9 100644 --- a/src/SoapCaller.php +++ b/src/SoapCaller.php @@ -15,22 +15,17 @@ class SoapCaller implements LoggerAwareInterface { - private SoapClient $soapClient; - - /** @var array */ - private array $extraParameters; - private LoggerInterface $logger; /** - * @param SoapClient $soapClient * @param array $extraParameters */ - public function __construct(SoapClient $soapClient, array $extraParameters = []) - { - $this->soapClient = $soapClient; - $this->extraParameters = $extraParameters; - $this->logger = new NullLogger(); + public function __construct( + private SoapClient $soapClient, + private array $extraParameters = [], + ?LoggerInterface $logger = null + ) { + $this->logger = $logger ?? new NullLogger(); } private function soapClient(): SoapClient diff --git a/src/SoapFactory.php b/src/SoapFactory.php index 9339cce..92db0fe 100644 --- a/src/SoapFactory.php +++ b/src/SoapFactory.php @@ -13,7 +13,7 @@ class SoapFactory implements LoggerAwareInterface { private LoggerInterface $logger; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { $this->logger = $logger ?? new NullLogger(); } diff --git a/tests/Factories/PreCfdiCreatorHelper.php b/tests/Factories/PreCfdiCreatorHelper.php index 9fd1098..5856d32 100644 --- a/tests/Factories/PreCfdiCreatorHelper.php +++ b/tests/Factories/PreCfdiCreatorHelper.php @@ -22,28 +22,19 @@ final class PreCfdiCreatorHelper private string $emisorName; - private string $cerFile; - - private string $keyPemFile; - - private string $passPhrase; - private string $relation = ''; /** @var string[] */ private array $relatedUuids = []; public function __construct( - string $cerFile, - string $keyPemFile, - string $passPhrase + private string $cerFile, + private string $keyPemFile, + private string $passPhrase ) { - $certificate = new Certificado($cerFile); + $certificate = new Certificado($this->cerFile); $this->emisorRfc = $certificate->getRfc(); $this->emisorName = $certificate->getName(); - $this->cerFile = $cerFile; - $this->keyPemFile = $keyPemFile; - $this->passPhrase = $passPhrase; $this->invoiceDate = new DateTimeImmutable('now -5 minutes', new DateTimeZone('America/Mexico_City')); $this->conceptoDescription = sprintf('Portable tetris gamepad pro++ ⏻ v1.%s', random_int(10, 99)); $this->conceptoAmount = round(random_int(1000, 4000) + random_int(0, 99) / 100, 2); diff --git a/tests/Factories/PreCfdiRetentionCreatorHelper.php b/tests/Factories/PreCfdiRetentionCreatorHelper.php index ba6b235..609dc94 100644 --- a/tests/Factories/PreCfdiRetentionCreatorHelper.php +++ b/tests/Factories/PreCfdiRetentionCreatorHelper.php @@ -19,35 +19,17 @@ final class PreCfdiRetentionCreatorHelper private string $cveReten; - private string $emisorRfc; - - private string $emisorName; - - private string $keyPemFile; - - private string $passPhrase; - - private string $emisorLocation; - - private string $emisorRegimen; - public function __construct( string $cerFile, - string $keyPemFile, - string $passPhrase, - string $emisorRfc, - string $emisorName, - string $emisorLocation, - string $emisorRegimen + private string $keyPemFile, + private string $passPhrase, + private string $emisorRfc, + private string $emisorName, + private string $emisorLocation, + private string $emisorRegimen ) { $this->certificate = new Certificado($cerFile); - $this->emisorRfc = $emisorRfc; - $this->emisorName = $emisorName; - $this->keyPemFile = $keyPemFile; - $this->passPhrase = $passPhrase; $this->invoiceDate = new DateTimeImmutable('now -5 minutes', new DateTimeZone('America/Mexico_City')); - $this->emisorLocation = $emisorLocation; - $this->emisorRegimen = $emisorRegimen; } public function getInvoiceDate(): DateTimeImmutable diff --git a/tests/Fakes/FakeSoapFactory.php b/tests/Fakes/FakeSoapFactory.php index b691a3f..ee9d3bc 100644 --- a/tests/Fakes/FakeSoapFactory.php +++ b/tests/Fakes/FakeSoapFactory.php @@ -18,7 +18,7 @@ final class FakeSoapFactory extends SoapFactory public stdClass $preparedResult; - public function __construct(LoggerInterface $logger = null) + public function __construct(?LoggerInterface $logger = null) { parent::__construct($logger); $this->preparedResult = (object) []; diff --git a/tests/Integration/Services/Cancel/GetRelatedSignatureServiceTest.php b/tests/Integration/Services/Cancel/GetRelatedSignatureServiceTest.php index 03aeda8..bf1e64d 100644 --- a/tests/Integration/Services/Cancel/GetRelatedSignatureServiceTest.php +++ b/tests/Integration/Services/Cancel/GetRelatedSignatureServiceTest.php @@ -74,8 +74,8 @@ public function testConsumeServiceWithRelated(): void // Testing only: in the wild it is expected to ask for related several seconds after the CFDI were created if ( '' !== $result->error() - && '2001' !== substr($result->error(), 0, 4) - && false === strpos($result->error(), '305') + && ! str_starts_with($result->error(), '2001') + && ! str_contains($result->error(), '305') && ! preg_match('/UUID: \S+ No Encontrado/', $result->error()) ) { break; diff --git a/tests/TestCase.php b/tests/TestCase.php index 3c2dd61..bae2653 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,7 +14,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { - public function createSettingsFromEnvironment(SoapFactory $soapFactory = null): FinkokSettings + public function createSettingsFromEnvironment(?SoapFactory $soapFactory = null): FinkokSettings { $settings = new FinkokSettings( $this->getenv('FINKOK_USERNAME') ?: 'username-non-set', diff --git a/tests/Unit/FinkokTest.php b/tests/Unit/FinkokTest.php index c23e0a5..b58bb54 100644 --- a/tests/Unit/FinkokTest.php +++ b/tests/Unit/FinkokTest.php @@ -60,7 +60,7 @@ public function testBadMethodCall(): void $finkok = new Finkok($settings); $this->expectException(BadMethodCallException::class); $this->expectExceptionMessage('Helper invalid-method is not registered'); - $finkok->{'invalid-method'}(); + $finkok->{'invalid-method'}(); /** @phpstan-ignore-line method.notFound */ } public function testMagicCallWithInvalidParameter(): void @@ -74,9 +74,9 @@ public function testMagicCallWithInvalidParameter(): void $this->expectExceptionMessage( 'Call PhpCfdi\Finkok\Finkok::getContracts' . ' expect PhpCfdi\Finkok\Services\Manifest\GetContractsCommand' - . ' but received ' . get_class($command) + . ' but received ' . $command::class ); - $finkok->{'getContracts'}($command); + $finkok->{'getContracts'}($command); /** @phpstan-ignore-line argument.type */ } public function testExecuteServiceWithCallNameDifferentFromServiceMethodName(): void diff --git a/tests/Unit/Helpers/AcceptRejectSignerTest.php b/tests/Unit/Helpers/AcceptRejectSignerTest.php index 1103878..16efdae 100644 --- a/tests/Unit/Helpers/AcceptRejectSignerTest.php +++ b/tests/Unit/Helpers/AcceptRejectSignerTest.php @@ -21,7 +21,7 @@ public function testCreateAndSign(): void $this->assertSame($uuid, $signer->uuid()); $this->assertSame($answer, $signer->answer()); $this->assertSame($date, $signer->dateTime()); - $this->assertSame($signer::DEFAULT_PACRFC, $signer->pacRfc()); + $this->assertSame(AcceptRejectSigner::DEFAULT_PACRFC, $signer->pacRfc()); $signed = $signer->sign($this->createCsdCredential()); diff --git a/tests/Unit/Helpers/GetRelatedSignerTest.php b/tests/Unit/Helpers/GetRelatedSignerTest.php index b998784..b69ae71 100644 --- a/tests/Unit/Helpers/GetRelatedSignerTest.php +++ b/tests/Unit/Helpers/GetRelatedSignerTest.php @@ -18,7 +18,7 @@ public function testCreateAndSign(): void $signer = new GetRelatedSigner($uuid, $role); $this->assertSame($uuid, $signer->uuid()); $this->assertSame($role, $signer->role()); - $this->assertSame($signer::DEFAULT_PACRFC, $signer->pacRfc()); + $this->assertSame(GetRelatedSigner::DEFAULT_PACRFC, $signer->pacRfc()); $signed = $signer->sign($this->createCsdCredential()); diff --git a/tests/Unit/Helpers/JsonDecoderLoggerTest.php b/tests/Unit/Helpers/JsonDecoderLoggerTest.php index ea87c66..8ef2a18 100644 --- a/tests/Unit/Helpers/JsonDecoderLoggerTest.php +++ b/tests/Unit/Helpers/JsonDecoderLoggerTest.php @@ -14,25 +14,25 @@ final class JsonDecoderLoggerTest extends TestCase public function testSetAlsoLogJsonMessage(): void { $decoder = new JsonDecoderLogger(new NullLogger()); - $this->assertSame(false, $decoder->setAlsoLogJsonMessage(null)); + $this->assertSame(false, $decoder->setAlsoLogJsonMessage()); $this->assertSame(false, $decoder->setAlsoLogJsonMessage(true)); $this->assertSame(true, $decoder->setAlsoLogJsonMessage(true)); - $this->assertSame(true, $decoder->setAlsoLogJsonMessage(null)); + $this->assertSame(true, $decoder->setAlsoLogJsonMessage()); $this->assertSame(true, $decoder->setAlsoLogJsonMessage(false)); $this->assertSame(false, $decoder->setAlsoLogJsonMessage(false)); - $this->assertSame(false, $decoder->setAlsoLogJsonMessage(null)); + $this->assertSame(false, $decoder->setAlsoLogJsonMessage()); } public function testSetUseJsonValidateIfAvailable(): void { $decoder = new JsonDecoderLogger(new NullLogger()); - $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable(null)); + $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable()); $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable(false)); $this->assertSame(false, $decoder->setUseJsonValidateIfAvailable(false)); - $this->assertSame(false, $decoder->setUseJsonValidateIfAvailable(null)); + $this->assertSame(false, $decoder->setUseJsonValidateIfAvailable()); $this->assertSame(false, $decoder->setUseJsonValidateIfAvailable(true)); $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable(true)); - $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable(null)); + $this->assertSame(true, $decoder->setUseJsonValidateIfAvailable()); } public function testLastMessageWasJsonValidReturnFalseWithoutCall(): void diff --git a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php index 001260d..96f37f2 100644 --- a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php +++ b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php @@ -143,10 +143,8 @@ public function testCreateWithStartPeriodInPastAndEndPeriodInFuture(): void $this->expectException(LogicException::class); $this->expectExceptionMessage('Cannot combine multiple past months with current/future months'); new class ($today, 'x-rfc', 'I', 2019, 1, $year, $month) extends ReportTotalCommand { - private DateTimeImmutable $today; - public function __construct( - DateTimeImmutable $today, + private DateTimeImmutable $today, string $rfc, string $type, int $startYear, @@ -154,7 +152,6 @@ public function __construct( int $endYear = 0, int $endMonth = 0 ) { - $this->today = $today; parent::__construct($rfc, $type, $startYear, $startMonth, $endYear, $endMonth); } diff --git a/tests/stamp-precfdi-devenv.php b/tests/stamp-precfdi-devenv.php index d382fb1..7ef447f 100644 --- a/tests/stamp-precfdi-devenv.php +++ b/tests/stamp-precfdi-devenv.php @@ -16,11 +16,8 @@ require_once __DIR__ . '/bootstrap.php'; exit(call_user_func(new class ($argv[0] ?? '') { - private string $command; - - public function __construct(string $command) + public function __construct(private string $command) { - $this->command = $command; } public function __invoke(string $preCfdiPath): int @@ -63,7 +60,7 @@ public function __invoke(string $preCfdiPath): int } catch (Throwable $exception) { file_put_contents( 'php://stderr', - sprintf("%s: %s\n", get_class($exception), $exception->getMessage()), + sprintf("%s: %s\n", $exception::class, $exception->getMessage()), FILE_APPEND ); return (int) $exception->getCode() ?: 1; From 52e671c4b14b5c95cf41e755ee5eb1c4d268de92 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:37:24 -0600 Subject: [PATCH 11/23] Update code standards --- .php-cs-fixer.dist.php | 3 ++- src/FinkokSettings.php | 2 +- src/Helpers/AcceptRejectSigner.php | 2 +- src/QuickFinkok.php | 18 +++++++++--------- src/Services/Manifest/GetContractsCommand.php | 2 +- src/Services/Registration/AddCommand.php | 2 +- src/Services/Utilities/ReportTotalCommand.php | 2 +- src/SoapCaller.php | 2 +- tests/Factories/PreCfdiCreatorHelper.php | 2 +- .../PreCfdiRetentionCreatorHelper.php | 2 +- tests/Integration/IntegrationTestCase.php | 4 ++-- .../AcceptRejectSignatureServiceTest.php | 2 +- .../Manifest/SignContractsServiceTest.php | 2 +- .../Utilities/ReportTotalCommandTest.php | 2 +- 14 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 945e40b..a4c2f5f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -18,12 +18,13 @@ '@PHP8x0Migration' => true, '@PHP8x0Migration:risky' => true, // symfony + 'array_indentation' => true, 'class_attributes_separation' => true, 'whitespace_after_comma_in_array' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, 'type_declaration_spaces' => true, - 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays']], + 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'match', 'parameters']], 'no_blank_lines_after_phpdoc' => true, 'object_operator_without_whitespace' => true, 'binary_operator_spaces' => true, diff --git a/src/FinkokSettings.php b/src/FinkokSettings.php index a8328ca..78e9fe3 100644 --- a/src/FinkokSettings.php +++ b/src/FinkokSettings.php @@ -70,7 +70,7 @@ public function soapFactory(): SoapFactory public function createCallerForService( Services $service, string $usernameKey = 'username', - string $passwordKey = 'password' + string $passwordKey = 'password', ): SoapCaller { $wsdlLocation = $this->environment()->endpoint($service); $credentials = array_merge( diff --git a/src/Helpers/AcceptRejectSigner.php b/src/Helpers/AcceptRejectSigner.php index c27a44f..6096a15 100644 --- a/src/Helpers/AcceptRejectSigner.php +++ b/src/Helpers/AcceptRejectSigner.php @@ -31,7 +31,7 @@ public function __construct( private string $uuid, private CancelAnswer $answer, ?DateTimeImmutable $dateTime = null, - string $pacRfc = self::DEFAULT_PACRFC + string $pacRfc = self::DEFAULT_PACRFC, ) { $this->dateTime = $dateTime ?? new DateTimeImmutable(); $this->pacRfc = $pacRfc ?: static::DEFAULT_PACRFC; diff --git a/src/QuickFinkok.php b/src/QuickFinkok.php index bc4a77b..062234f 100644 --- a/src/QuickFinkok.php +++ b/src/QuickFinkok.php @@ -148,7 +148,7 @@ public function satStatus( string $rfcIssuer, string $rfcRecipient, string $uuid, - string $total + string $total, ): Cancel\GetSatStatusResult { $command = new Cancel\GetSatStatusCommand($rfcIssuer, $rfcRecipient, $uuid, $total); $service = new Cancel\GetSatStatusService($this->settings()); @@ -183,7 +183,7 @@ public function satStatusXml(string $xmlCfdi): Cancel\GetSatStatusResult public function obtainRelated( Credential $credential, string $uuid, - ?RfcRole $role = null + ?RfcRole $role = null, ): Cancel\GetRelatedSignatureResult { $signer = new Helpers\GetRelatedSigner($uuid, $role); $signedRequest = $signer->sign($credential); @@ -221,7 +221,7 @@ public function obtainPendingToCancel(string $rfc): Cancel\GetPendingResult public function answerAcceptRejectCancellation( Credential $credential, string $uuid, - CancelAnswer $answer + CancelAnswer $answer, ): Cancel\AcceptRejectSignatureResult { $signer = new Helpers\AcceptRejectSigner($uuid, $answer); $signedRequest = $signer->sign($credential); @@ -271,7 +271,7 @@ public function serversDateTime(string $postalCode = ''): Utilities\DatetimeResu public function reportUuids( string $rfc, DateTimeImmutable $since, - DateTimeImmutable $until + DateTimeImmutable $until, ): Utilities\ReportUuidResult { $command = new Utilities\ReportUuidCommand($rfc, 'I', $since, $until); $service = new Utilities\ReportUuidService($this->settings()); @@ -308,7 +308,7 @@ public function reportTotals( int $startYear, int $startMonth, int $endYear = 0, - int $endMonth = 0 + int $endMonth = 0, ): Utilities\ReportTotalResult { $command = new Utilities\ReportTotalCommand($rfc, 'I', $startYear, $startMonth, $endYear, $endMonth); $service = new Utilities\ReportTotalService($this->settings()); @@ -421,7 +421,7 @@ public function customerGetContracts( string $name, string $address, string $email, - string $snid + string $snid, ): Manifest\GetContractsResult { $command = new Manifest\GetContractsCommand($rfc, $name, $address, $email, $snid); $service = new Manifest\GetContractsService($this->settings()); @@ -440,7 +440,7 @@ public function customerGetContracts( public function customerSendContracts( string $snid, string $signedPrivacy, - string $signedContract + string $signedContract, ): Manifest\SignContractsResult { $command = new Manifest\SignContractsCommand($snid, $signedPrivacy, $signedContract); $service = new Manifest\SignContractsService($this->settings()); @@ -462,7 +462,7 @@ public function customerSignAndSendContracts( string $snid, string $address, string $email, - ?DateTimeImmutable $signedOn = null + ?DateTimeImmutable $signedOn = null, ): Manifest\SignContractsResult { $rfc = $fiel->rfc(); $name = $fiel->legalName(); @@ -490,7 +490,7 @@ public function customerSignAndSendContracts( public function customerGetSignedContracts( string $snid, string $rfc, - ?SignedDocumentFormat $format = null + ?SignedDocumentFormat $format = null, ): Manifest\GetSignedContractsResult { $format ??= SignedDocumentFormat::xml(); $command = new Manifest\GetSignedContractsCommand($snid, $rfc, $format); diff --git a/src/Services/Manifest/GetContractsCommand.php b/src/Services/Manifest/GetContractsCommand.php index 545616e..f360541 100644 --- a/src/Services/Manifest/GetContractsCommand.php +++ b/src/Services/Manifest/GetContractsCommand.php @@ -11,7 +11,7 @@ public function __construct( private string $name, private string $address, private string $email, - private string $snid + private string $snid, ) { } diff --git a/src/Services/Registration/AddCommand.php b/src/Services/Registration/AddCommand.php index 199e585..45d7d04 100644 --- a/src/Services/Registration/AddCommand.php +++ b/src/Services/Registration/AddCommand.php @@ -13,7 +13,7 @@ public function __construct( ?CustomerType $type = null, private string $certificate = '', private string $privateKey = '', - private string $passPhrase = '' + private string $passPhrase = '', ) { $this->type = $type ?? CustomerType::ondemand(); } diff --git a/src/Services/Utilities/ReportTotalCommand.php b/src/Services/Utilities/ReportTotalCommand.php index 1326d12..ecc7471 100644 --- a/src/Services/Utilities/ReportTotalCommand.php +++ b/src/Services/Utilities/ReportTotalCommand.php @@ -27,7 +27,7 @@ public function __construct( int $startYear, int $startMonth, int $endYear = 0, - int $endMonth = 0 + int $endMonth = 0, ) { $endYear = $endYear ?: $startYear; $endMonth = $endMonth ?: $startMonth; diff --git a/src/SoapCaller.php b/src/SoapCaller.php index 7a967f9..2c88727 100644 --- a/src/SoapCaller.php +++ b/src/SoapCaller.php @@ -23,7 +23,7 @@ class SoapCaller implements LoggerAwareInterface public function __construct( private SoapClient $soapClient, private array $extraParameters = [], - ?LoggerInterface $logger = null + ?LoggerInterface $logger = null, ) { $this->logger = $logger ?? new NullLogger(); } diff --git a/tests/Factories/PreCfdiCreatorHelper.php b/tests/Factories/PreCfdiCreatorHelper.php index 5856d32..7e0e3d6 100644 --- a/tests/Factories/PreCfdiCreatorHelper.php +++ b/tests/Factories/PreCfdiCreatorHelper.php @@ -30,7 +30,7 @@ final class PreCfdiCreatorHelper public function __construct( private string $cerFile, private string $keyPemFile, - private string $passPhrase + private string $passPhrase, ) { $certificate = new Certificado($this->cerFile); $this->emisorRfc = $certificate->getRfc(); diff --git a/tests/Factories/PreCfdiRetentionCreatorHelper.php b/tests/Factories/PreCfdiRetentionCreatorHelper.php index 609dc94..253b861 100644 --- a/tests/Factories/PreCfdiRetentionCreatorHelper.php +++ b/tests/Factories/PreCfdiRetentionCreatorHelper.php @@ -26,7 +26,7 @@ public function __construct( private string $emisorRfc, private string $emisorName, private string $emisorLocation, - private string $emisorRegimen + private string $emisorRegimen, ) { $this->certificate = new Certificado($cerFile); $this->invoiceDate = new DateTimeImmutable('now -5 minutes', new DateTimeZone('America/Mexico_City')); diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index 8daa68a..47d6f04 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -79,7 +79,7 @@ public function createGetSatStatusCommandFromCfdiContents(string $xmlContents): protected function createCancelSignatureCommandFromDocument( CancelDocument $document, - ?DateTimeImmutable $dateTime = null + ?DateTimeImmutable $dateTime = null, ): CancelSignatureCommand { $credential = $this->createCsdCredential(); $signer = new CancelSigner(new CancelDocuments($document), $dateTime); @@ -89,7 +89,7 @@ protected function createCancelSignatureCommandFromDocument( protected function checkCanGetSatStatusOrFail( string $cfdiContents, string $exceptionMessage = '', - int $waitSeconds = 120 + int $waitSeconds = 120, ): GetSatStatusResult { $service = new GetSatStatusService($this->createSettingsFromEnvironment()); $command = $this->createGetSatStatusCommandFromCfdiContents($cfdiContents); diff --git a/tests/Integration/Services/Cancel/AcceptRejectSignatureServiceTest.php b/tests/Integration/Services/Cancel/AcceptRejectSignatureServiceTest.php index 8a7026c..56ffb03 100644 --- a/tests/Integration/Services/Cancel/AcceptRejectSignatureServiceTest.php +++ b/tests/Integration/Services/Cancel/AcceptRejectSignatureServiceTest.php @@ -20,7 +20,7 @@ protected function createService(): AcceptRejectSignatureService protected function createAcceptRejectSignatureCommand( string $uuid, - CancelAnswer $answer + CancelAnswer $answer, ): AcceptRejectSignatureCommand { $signer = new AcceptRejectSigner($uuid, $answer); $xml = $signer->sign($this->createCsdCredential()); diff --git a/tests/Integration/Services/Manifest/SignContractsServiceTest.php b/tests/Integration/Services/Manifest/SignContractsServiceTest.php index f9a96d7..eb44a25 100644 --- a/tests/Integration/Services/Manifest/SignContractsServiceTest.php +++ b/tests/Integration/Services/Manifest/SignContractsServiceTest.php @@ -19,7 +19,7 @@ private function consumeSignContracts( string $rfc, string $certificateFile, string $privateKeyFile, - string $passPhrase + string $passPhrase, ): SignContractsResult { $settings = $this->createSettingsFromEnvironment(); diff --git a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php index 96f37f2..31f150a 100644 --- a/tests/Unit/Services/Utilities/ReportTotalCommandTest.php +++ b/tests/Unit/Services/Utilities/ReportTotalCommandTest.php @@ -150,7 +150,7 @@ public function __construct( int $startYear, int $startMonth, int $endYear = 0, - int $endMonth = 0 + int $endMonth = 0, ) { parent::__construct($rfc, $type, $startYear, $startMonth, $endYear, $endMonth); } From dad9172e02192a506d510dacd3990732dede05a0 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:41:25 -0600 Subject: [PATCH 12/23] Bump to PHP 8.1 & all dependencies --- .github/workflows/build.yml | 2 +- .php-cs-fixer.dist.php | 2 +- composer.json | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c5144c..e55e440 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-version: ['8.0', '8.1', '8.2', '8.3'] + php-version: ['8.1', '8.2', '8.3'] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a4c2f5f..7d1c30e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -15,7 +15,7 @@ ->setRules([ '@PSR12' => true, '@PSR12:risky' => true, - '@PHP8x0Migration' => true, + '@PHP8x1Migration' => true, '@PHP8x0Migration:risky' => true, // symfony 'array_indentation' => true, diff --git a/composer.json b/composer.json index e07f2e2..d9cef42 100644 --- a/composer.json +++ b/composer.json @@ -21,25 +21,26 @@ "source": "https://github.com/phpcfdi/finkok" }, "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-dom": "*", "ext-json": "*", "ext-openssl": "*", "ext-soap": "*", - "eclipxe/enum": "^0.2.0", - "eclipxe/micro-catalog": "^0.1.0", - "phpcfdi/cfdi-expresiones": "^3.2", - "phpcfdi/credentials": "^1.0.1", - "phpcfdi/xml-cancelacion": "^2.0.2", - "psr/log": "^1.1 || ^2.0 || ^3.0", - "robrichards/xmlseclibs": "^3.0.4" + "eclipxe/enum": "^0.2.7", + "eclipxe/micro-catalog": "^0.1.4", + "phpcfdi/cfdi-expresiones": "^3.3.0", + "phpcfdi/credentials": "^1.3.0", + "phpcfdi/xml-cancelacion": "^2.0.5", + "psr/log": "^3.0", + "robrichards/xmlseclibs": "^3.1.3" }, "require-dev": { "ext-fileinfo": "*", "eclipxe/cfdiutils": "^3.0.1", - "phpcfdi/rfc": "^1.1", + "phpcfdi/rfc": "^1.2", "phpunit/phpunit": "^9.5.10", - "symfony/dotenv": "^5.1 || ^6.0 || ^7.0" + "rector/rector": "^2.2", + "symfony/dotenv": "^6.0 || ^7.0" }, "prefer-stable": true, "autoload": { From 199dbd4ff50b8bbca3c38367ed1e765c84806e31 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:41:38 -0600 Subject: [PATCH 13/23] Update development tools --- .phive/phars.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 477c775..89ef54c 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,8 +1,8 @@ - - - - - + + + + + From e5d1e559700d7c753f5f379f65a4fd0588aaef0a Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:42:02 -0600 Subject: [PATCH 14/23] Add PHP 8.4 to test matrix --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e55e440..2ce8d5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-version: ['8.1', '8.2', '8.3'] + php-version: ['8.1', '8.2', '8.3', '8.4'] steps: - name: Checkout uses: actions/checkout@v4 From 1ead7c253f90f1e33146659c00268f6dc502e7c1 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 11:43:08 -0600 Subject: [PATCH 15/23] Run all jobs on PHP 8.4 --- .github/workflows/build.yml | 8 ++++---- .github/workflows/functional-tests.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ce8d5c..1c5e275 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none tools: composer-normalize env: @@ -39,7 +39,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none tools: cs2pr, phpcs env: @@ -56,7 +56,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none tools: cs2pr, php-cs-fixer env: @@ -73,7 +73,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' coverage: none tools: composer:v2, phpstan extensions: soap diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index e2b9b25..f4aa42d 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -25,7 +25,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' extensions: soap coverage: xdebug tools: composer:v2 From 09db92c48df06f21bd0e6faa9494ce26304ed13b Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 12:03:07 -0600 Subject: [PATCH 16/23] Bump to PHPUnit ^10.5 --- .github/workflows/build.yml | 2 +- .github/workflows/functional-tests.yml | 2 +- CONTRIBUTING.md | 2 +- composer.json | 6 +++--- docs/PruebasDeIntegracion.md | 4 ++-- phpunit.xml.dist | 18 ++++++++---------- .../Manifest/GetSignedContractsServiceTest.php | 4 ++-- tests/TestCase.php | 2 +- tests/Unit/FinkokEnvironmentTest.php | 2 ++ tests/Unit/Helpers/JsonDecoderLoggerTest.php | 4 ++-- .../Retentions/CancelSignatureServiceTest.php | 1 + 11 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c5e275..096776c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,4 +123,4 @@ jobs: - name: Install project dependencies run: composer upgrade --no-interaction --no-progress --prefer-dist - name: Tests (phpunit) - run: vendor/bin/phpunit tests/Unit/ --testdox --verbose + run: vendor/bin/phpunit tests/Unit/ --testdox diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index f4aa42d..a22de31 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -59,7 +59,7 @@ jobs: ENV_GPG_SECRET: ${{ secrets.ENV_GPG_SECRET }} - name: Run integration tests with code coverage - run: vendor/bin/phpunit --testdox --verbose --exclude-group large --coverage-clover=build/coverage-clover.xml + run: vendor/bin/phpunit --testdox --exclude-group large --coverage-clover=build/coverage-clover.xml - name: Upload code coverage to scrutinizer uses: sudo-bot/action-scrutinizer@latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 416cfcc..303263a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ Lee y configura tu proyecto de acuerdo a la guía de configuración del [entorno Una vez correctamente configurado, ejecuta las pruebas de integración: ```shell -vendor/bin/phpunit tests/Integration --testdox --verbose +vendor/bin/phpunit tests/Integration --testdox ``` ## Ejecutar GitHub Actions localmente diff --git a/composer.json b/composer.json index d9cef42..d620be5 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "ext-fileinfo": "*", "eclipxe/cfdiutils": "^3.0.1", "phpcfdi/rfc": "^1.2", - "phpunit/phpunit": "^9.5.10", + "phpunit/phpunit": "^10.5", "rector/rector": "^2.2", "symfony/dotenv": "^6.0 || ^7.0" }, @@ -71,7 +71,7 @@ "@php tools/phpcs --colors -sp" ], "dev:coverage": [ - "@php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit --verbose --coverage-html build/coverage/html/" + "@php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit --coverage-html build/coverage/html/" ], "dev:fix-style": [ "@php tools/composer-normalize normalize", @@ -79,7 +79,7 @@ "@php tools/phpcbf --colors -sp" ], "dev:test": [ - "@php vendor/bin/phpunit --testdox --verbose --stop-on-failure tests/Unit", + "@php vendor/bin/phpunit --testdox --stop-on-failure tests/Unit", "@php tools/phpstan analyse --no-progress --verbose" ] }, diff --git a/docs/PruebasDeIntegracion.md b/docs/PruebasDeIntegracion.md index 034896d..9a2329d 100644 --- a/docs/PruebasDeIntegracion.md +++ b/docs/PruebasDeIntegracion.md @@ -30,7 +30,7 @@ entornos de ejecución. Puedes usar el archivo `test/.env-example` como base. Una vez que lo configures te recomiendo ejecutar el test inocuo de `datetime`. ```text -php vendor/bin/phpunit --verbose --testdox tests/Integration/Services/Utilities/DatetimeServiceTest.php +php vendor/bin/phpunit --testdox tests/Integration/Services/Utilities/DatetimeServiceTest.php Services/Utilities/DatetimeServiceTest.php PHPUnit 9.5.3 by Sebastian Bergmann and contributors. @@ -50,7 +50,7 @@ Time: 00:01.843, Memory: 6.00 MB Las pruebas de integración no están incluidas en el comando `composer dev:test`. Hay que correrlas a mano ejecutando: ```shell -vendor/bin/phpunit tests/Integration --testdox --verbose +vendor/bin/phpunit tests/Integration --testdox ``` Lee la [guía de contribuciones](../CONTRIBUTING.md) para más información. diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7429818..dacbb1d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,22 @@ + displayDetailsOnAllIssues="true" + colors="true" + > - ./tests/ + tests - + - ./src/ + src - + diff --git a/tests/Integration/Services/Manifest/GetSignedContractsServiceTest.php b/tests/Integration/Services/Manifest/GetSignedContractsServiceTest.php index e9d234d..f0da96d 100644 --- a/tests/Integration/Services/Manifest/GetSignedContractsServiceTest.php +++ b/tests/Integration/Services/Manifest/GetSignedContractsServiceTest.php @@ -17,8 +17,8 @@ private function createService(): GetSignedContractsService return new GetSignedContractsService($settings); } - /** @return array */ - public function providerGetSignedContracts(): array + /** @return array */ + public static function providerGetSignedContracts(): array { return [ 'xml' => [SignedDocumentFormat::xml(), 'text/xml'], diff --git a/tests/TestCase.php b/tests/TestCase.php index bae2653..08f66e5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -30,7 +30,7 @@ public function createSettingsFromEnvironment(?SoapFactory $soapFactory = null): '%s/../build/tests/%s-%s-%s.txt', __DIR__, (new DateTimeImmutable())->format('YmdHis.u'), - $this->getName(), + $this->name(), uniqid() ); $logger = new JsonDecoderLogger(new FileLogger($loggerOutputFile)); diff --git a/tests/Unit/FinkokEnvironmentTest.php b/tests/Unit/FinkokEnvironmentTest.php index ad77f55..41d4718 100644 --- a/tests/Unit/FinkokEnvironmentTest.php +++ b/tests/Unit/FinkokEnvironmentTest.php @@ -30,10 +30,12 @@ public function testEndpointOverridesWhenServiceIsManifest(): void $environment = FinkokEnvironment::makeDevelopment(); $cancel = $environment->endpoint(Services::cancel()); + /** @phpstan-ignore argument.type (Parameter #1 expects non-empty-string) */ $this->assertStringStartsWith($environment->server(), $cancel); $this->assertStringNotContainsString('//', substr($cancel, 8)); $manifest = $environment->endpoint(Services::manifest()); + /** @phpstan-ignore argument.type (Parameter #1 expects non-empty-string) */ $this->assertStringStartsWith(EnvironmentManifest::development()->value(), $manifest); $this->assertStringNotContainsString('//', substr($manifest, 8)); } diff --git a/tests/Unit/Helpers/JsonDecoderLoggerTest.php b/tests/Unit/Helpers/JsonDecoderLoggerTest.php index 8ef2a18..2bf7ba4 100644 --- a/tests/Unit/Helpers/JsonDecoderLoggerTest.php +++ b/tests/Unit/Helpers/JsonDecoderLoggerTest.php @@ -42,7 +42,7 @@ public function testLastMessageWasJsonValidReturnFalseWithoutCall(): void } /** @return array */ - public function providerUseJsonValidateIfAvailable(): array + public static function providerUseJsonValidateIfAvailable(): array { return [ 'use json_validate' => [true], @@ -95,7 +95,7 @@ public function testLogSendTextMessageToLoggerAndJson(): void 'debug', $this->callback( function ($message) use ($matcher, $expectedParameters): bool { - $this->assertSame($expectedParameters[$matcher->getInvocationCount() - 1], $message); + $this->assertSame($expectedParameters[$matcher->numberOfInvocations() - 1], $message); return true; } ), diff --git a/tests/Unit/Services/Retentions/CancelSignatureServiceTest.php b/tests/Unit/Services/Retentions/CancelSignatureServiceTest.php index e9963bc..7fe6c9e 100644 --- a/tests/Unit/Services/Retentions/CancelSignatureServiceTest.php +++ b/tests/Unit/Services/Retentions/CancelSignatureServiceTest.php @@ -35,6 +35,7 @@ public function testServiceUsingPreparedResult(): void $this->assertSame('x-seguimiento-cancelacion', $result->tracing()); $caller = $soapFactory->latestSoapCaller; + /** @phpstan-ignore argument.type (Parameter #1 expects non-empty-string) */ $this->assertStringEndsWith(Services::retentions()->value(), $soapFactory->latestWsdlLocation); $this->assertSame('cancel_signature', $caller->latestCallMethodName); $this->assertArrayHasKey('xml', $caller->latestCallParameters); From 7bfc43610c0104b468abe30c60cdbc41260ab9a3 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 12:08:40 -0600 Subject: [PATCH 17/23] Remove ScrutinizerCI, thanks! --- .gitattributes | 1 - .github/workflows/functional-tests.yml | 9 --------- .scrutinizer.yml | 19 ------------------- README.md | 6 +----- docs/PruebasDeIntegracionContinua.md | 5 ----- 5 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.gitattributes b/.gitattributes index d1943ad..08e0a0b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,7 +18,6 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php-cs-fixer.dist.php export-ignore -/.scrutinizer.yml export-ignore /phpcs.xml.dist export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index a22de31..01ec58f 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -8,7 +8,6 @@ on: # Actions # shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action -# sudo-bot/action-scrutinizer@latest https://github.com/marketplace/actions/action-scrutinizer jobs: functional-tests: @@ -19,8 +18,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 # required for sudo-bot/action-scrutinizer - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -60,9 +57,3 @@ jobs: - name: Run integration tests with code coverage run: vendor/bin/phpunit --testdox --exclude-group large --coverage-clover=build/coverage-clover.xml - - - name: Upload code coverage to scrutinizer - uses: sudo-bot/action-scrutinizer@latest - with: - cli-args: "--format=php-clover build/coverage-clover.xml" - continue-on-error: true diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 4b9271e..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,19 +0,0 @@ -filter: - excluded_paths: - - 'tests/' - - 'vendor/' - - 'tools/' - -# see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/ -build: - dependencies: - override: - - composer update --no-interaction --no-dev - nodes: - php: - tests: - override: - - php-scrutinizer-run --enable-security-analysis - -tools: - external_code_coverage: true diff --git a/README.md b/README.md index 91dfc13..a3298a5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Latest Version][badge-release]][release] [![Software License][badge-license]][license] [![Build Status][badge-build]][build] -[![Scrutinizer][badge-quality]][quality] [![Coverage Status][badge-coverage]][coverage] [![Total Downloads][badge-downloads]][downloads] @@ -295,6 +294,7 @@ sin temor a romper tu aplicación. |------------------------|-------------------------------|----------------------| | 0.1.0 | 7.2, 7.3 y 7.4 | 2019-03-29 | | 0.3.0 | 7.3, 7.4, 8.0, 8.1, 8.2 y 8.3 | 2021-03-18 | +| 0.6.0 | 8.1, 8.2, 8.3 y 8.4 | 2025-11-08 | ## Contribuciones @@ -314,14 +314,10 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor [release]: https://github.com/phpcfdi/finkok/releases [license]: https://github.com/phpcfdi/finkok/blob/main/LICENSE [build]: https://github.com/phpcfdi/finkok/actions/workflows/build.yml?query=branch:main -[quality]: https://scrutinizer-ci.com/g/phpcfdi/finkok/ -[coverage]: https://scrutinizer-ci.com/g/phpcfdi/finkok/code-structure/main/code-coverage/src [downloads]: https://packagist.org/packages/phpcfdi/finkok [badge-source]: https://img.shields.io/badge/source-phpcfdi/finkok-blue?style=flat-square [badge-release]: https://img.shields.io/github/release/phpcfdi/finkok?style=flat-square [badge-license]: https://img.shields.io/github/license/phpcfdi/finkok?style=flat-square [badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/finkok/build.yml?branch=main&style=flat-square -[badge-quality]: https://img.shields.io/scrutinizer/g/phpcfdi/finkok/main?style=flat-square -[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/phpcfdi/finkok/main?style=flat-square [badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/finkok?style=flat-square diff --git a/docs/PruebasDeIntegracionContinua.md b/docs/PruebasDeIntegracionContinua.md index 8f255a7..10cccfc 100644 --- a/docs/PruebasDeIntegracionContinua.md +++ b/docs/PruebasDeIntegracionContinua.md @@ -47,8 +47,3 @@ comando. Esta operación es la que se ejecuta en `functional-test.yml` usando el ```shell gpg --quiet --batch --yes --decrypt --output - tests/.env-testing.enc ``` - -### Cobertura de código - -Las pruebas de funcionales son las que establecen la mayor cobertura de código, entonces, en su ejecución -se genera el archivo de cobertura y se publica en Scrutinizer. From 5018fd3bfef4afe3e6771508931b72ab43766f31 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 14:21:30 -0600 Subject: [PATCH 18/23] Update license year to 2025 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 79ffed7..5b8acbe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 - 2024 PhpCfdi https://www.phpcfdi.com/ +Copyright (c) 2019 - 2025 PhpCfdi https://www.phpcfdi.com/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From b1ee7a17bfd379d252e063031834840ded6be50d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 14:21:45 -0600 Subject: [PATCH 19/23] Integrate with SonarQube Cloud --- .gitattributes | 1 + .github/workflows/sonarqube-cloud.yml | 72 +++++++++++++++++++++++++++ docs/PruebasDeIntegracion.md | 15 +++--- docs/PruebasDeIntegracionContinua.md | 23 ++++++--- sonar-project.properties | 10 ++++ 5 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/sonarqube-cloud.yml create mode 100644 sonar-project.properties diff --git a/.gitattributes b/.gitattributes index 08e0a0b..3162563 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,6 +21,7 @@ /phpcs.xml.dist export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore +sonar-project.properties export-ignore # Do not count these files on github code language /tests/_files/** linguist-detectable=false diff --git a/.github/workflows/sonarqube-cloud.yml b/.github/workflows/sonarqube-cloud.yml new file mode 100644 index 0000000..bf60b9d --- /dev/null +++ b/.github/workflows/sonarqube-cloud.yml @@ -0,0 +1,72 @@ +name: "SonarQube Cloud" +on: + # secrets are not passed to workflows that are triggered by a pull request from a fork. + # see https://docs.github.com/en/actions/reference/encrypted-secrets + workflow_dispatch: + push: + branches: [ "main" ] + +# Actions +# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action +# SonarSource/sonarqube-scan-action@v6 https://github.com/marketplace/actions/official-sonarqube-scan + +jobs: + + sonarqube-cloud: + name: SonarCloud Scan and Report + runs-on: "ubuntu-latest" + steps: + - name: Check SONAR_TOKEN secret + run: | + if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then + echo "::warning ::SONAR_TOKEN non set" + exit 1 + fi + - name: Check ENV_GPG_SECRET secret + run: | + if [ -z "${{ secrets.ENV_GPG_SECRET }}" ]; then + echo "::warning ::ENV_GPG_SECRET non set" + exit 1 + fi + - name: Checkout + uses: actions/checkout@v4 + - name: Unshallow clone to provide blame information + run: git fetch --unshallow + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: soap + coverage: xdebug + tools: composer:v2 + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install project dependencies + run: composer upgrade --no-interaction --no-progress --prefer-dist + - name: Install SAT XML resources + shell: bash + run: | + git clone --depth 1 https://github.com/phpcfdi/resources-sat-xml resources-sat-xml-cloned + mv resources-sat-xml-cloned/resources vendor/eclipxe/cfdiutils/build/resources + rm -r -f resources-sat-xml-cloned + - name: Set up environment file + run: gpg --quiet --batch --yes --decrypt --passphrase="$ENV_GPG_SECRET" --output tests/.env tests/.env-testing.enc + env: + ENV_GPG_SECRET: ${{ secrets.ENV_GPG_SECRET }} + - name: Create code coverage + run: vendor/bin/phpunit --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml + - name: Prepare SonarCloud Code Coverage Files + run: | + sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/junit.xml > build/sonar-junit.xml + sed 's#'$GITHUB_WORKSPACE'#/github/workspace#g' build/coverage/clover.xml > build/sonar-coverage.xml + - name: SonarCloud Scan + uses: SonarSource/sonarqube-scan-action@v6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/docs/PruebasDeIntegracion.md b/docs/PruebasDeIntegracion.md index 9a2329d..d1c29ef 100644 --- a/docs/PruebasDeIntegracion.md +++ b/docs/PruebasDeIntegracion.md @@ -14,7 +14,7 @@ Los datos se encuentran en `tests/_files/certs/`: - `EKU9003173C9.key` Archivo de llave privada (formato DER) - `EKU9003173C9.password.bin` Archivo con el password del certificado -Esta información es pública, por lo tanto no hay problema en publicarla aquí. +Esta información es pública, por lo tanto, no hay problema en publicarla aquí. Recuerda registrar este RFC en tu panel de Si no lo haces verás errores como estos: @@ -31,18 +31,17 @@ Una vez que lo configures te recomiendo ejecutar el test inocuo de `datetime`. ```text php vendor/bin/phpunit --testdox tests/Integration/Services/Utilities/DatetimeServiceTest.php -Services/Utilities/DatetimeServiceTest.php -PHPUnit 9.5.3 by Sebastian Bergmann and contributors. +PHPUnit 10.5.58 by Sebastian Bergmann and contributors. -Runtime: PHP 8.0.3 +Runtime: PHP 8.4.14 Configuration: /home/eclipxe/work/PhpCfdi/finkok/phpunit.xml.dist Datetime Service (PhpCfdi\Finkok\Tests\Integration\Services\Utilities\DatetimeService) - ✔ Two well known different postal codes 1173 ms - ✔ Consume date time service 355 ms - ✔ Consume date time service using invalid username password 314 ms + ✔ Two well known different postal codes + ✔ Consume date time service + ✔ Consume date time service using invalid username password -Time: 00:01.843, Memory: 6.00 MB +OK (3 tests, 8 assertions) ``` ## Ejecución de pruebas diff --git a/docs/PruebasDeIntegracionContinua.md b/docs/PruebasDeIntegracionContinua.md index 10cccfc..b1a56ca 100644 --- a/docs/PruebasDeIntegracionContinua.md +++ b/docs/PruebasDeIntegracionContinua.md @@ -3,18 +3,19 @@ Se ha configurado este proyecto para correr las pruebas de integración contínua utilizando la plataforma de GitHub Actions. -Hay dos trabajos de ejecución que ejecutan al hacer un push o un pull request sobre la rama principal: +El flujo de trabajo `build.yml` se ejecuta en cada ocasión que se hace *push* o *pull request* sobre la rama principal +y solo realiza las pruebas generales. -- Prueba general de contrucción `build.yml`. -- Pruebas funcionales `functional-test.yml`. +El flujo de trabajo `sonarqube-cloud.yml` se ejecuta en cada ocasión que se hace *push* sobre la rama principal +y realiza pruebas extendidas que usan credenciales encriptadas de Finkok. ## Pruebas generales Las pruebas generales que se ejecutan tienen que ver con el estilo de código, pruebas unitarias (no funcionales), -y anásis estático de código. Estas pruebas son las que están vinculadas con el estado de la contrucción -en el *badge* *build*. +y análisis estático de código. Estas pruebas son las que están vinculadas con el estado de la construcción +en la insignia *build*. -Adicionalmente, se ejecutan estas pruebas todos los domingos a las 16:00 horas. +Adicionalmente, se ejecutan estas pruebas todos los domingos a las 16:00 horas (GMT-0). ## Pruebas funcionales @@ -23,7 +24,6 @@ marcadas con la etiqueta `@group large`. Este tipo de pruebas hace contacto con la plataforma de pruebas de Finkok, por lo que es necesario contar con una cuenta y configurar correctamente el archivo de configuración de entorno `.env`. -Lee el archivo de [Pruebas de Integracion](PruebasDeIntegracion.md) para más información. ### Protección de los datos de configuración de entorno @@ -47,3 +47,12 @@ comando. Esta operación es la que se ejecuta en `functional-test.yml` usando el ```shell gpg --quiet --batch --yes --decrypt --output - tests/.env-testing.enc ``` + +## Cobertura de código reportada + +Se está utilizando la plataforma SonarQube Cloud para análisis de código y para mostrar la cobertura de código. +Para su ejecución es necesario que el repositorio esté configurado junto con el secreto `secrets.SONAR_TOKEN`. + +Se ejecutan las pruebas funcionales tal como fueron descritas anteriormente, +pero no se excluyen las pruebas marcadas con la etiqueta `@group large` + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..d60f74e --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,10 @@ +sonar.organization=phpcfdi +sonar.projectKey=phpcfdi_finkok +sonar.sourceEncoding=UTF-8 +sonar.language=php +sonar.sources=src +sonar.tests=tests +sonar.test.exclusions=tests/_files/**/* +sonar.working.directory=build/.scannerwork +sonar.php.tests.reportPath=build/sonar-junit.xml +sonar.php.coverage.reportPaths=build/sonar-coverage.xml \ No newline at end of file From bec30b7c839f4f32ae181827039636b6d21ad322 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 14:28:09 -0600 Subject: [PATCH 20/23] Use PhpCfdi standard badges (include SonarQube Cloud) --- README.md | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a3298a5..1ce58df 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,20 @@ # phpcfdi/finkok [![Source Code][badge-source]][source] +[![Packagist PHP Version Support][badge-php-version]][php-version] +[![Discord][badge-discord]][discord] [![Latest Version][badge-release]][release] [![Software License][badge-license]][license] [![Build Status][badge-build]][build] -[![Coverage Status][badge-coverage]][coverage] +[![Reliability][badge-reliability]][reliability] +[![Maintainability][badge-maintainability]][maintainability] +[![Code Coverage][badge-coverage]][coverage] +[![Violations][badge-violations]][violations] [![Total Downloads][badge-downloads]][downloads] > Librería para conectar con la API de servicios de FINKOK (México) -:us: The documentation of this project is in spanish as this is the natural language for intented audience. +:us: The documentation of this project is in spanish as this is the natural language for intended audience. ## Acerca de phpcfdi/finkok @@ -311,13 +316,25 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor [todo]: https://github.com/phpcfdi/finkok/blob/main/docs/TODO.md [source]: https://github.com/phpcfdi/finkok +[php-version]: https://packagist.org/packages/phpcfdi/finkok +[discord]: https://discord.gg/aFGYXvX [release]: https://github.com/phpcfdi/finkok/releases [license]: https://github.com/phpcfdi/finkok/blob/main/LICENSE [build]: https://github.com/phpcfdi/finkok/actions/workflows/build.yml?query=branch:main +[reliability]:https://sonarcloud.io/component_measures?id=phpcfdi_finkok&metric=Reliability +[maintainability]: https://sonarcloud.io/component_measures?id=phpcfdi_finkok&metric=Maintainability +[coverage]: https://sonarcloud.io/component_measures?id=phpcfdi_finkok&metric=Coverage +[violations]: https://sonarcloud.io/project/issues?id=phpcfdi_finkok&resolved=false [downloads]: https://packagist.org/packages/phpcfdi/finkok -[badge-source]: https://img.shields.io/badge/source-phpcfdi/finkok-blue?style=flat-square -[badge-release]: https://img.shields.io/github/release/phpcfdi/finkok?style=flat-square -[badge-license]: https://img.shields.io/github/license/phpcfdi/finkok?style=flat-square -[badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/finkok/build.yml?branch=main&style=flat-square -[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/finkok?style=flat-square +[badge-source]: https://img.shields.io/badge/source-phpcfdi/finkok-blue?logo=github +[badge-discord]: https://img.shields.io/discord/459860554090283019?logo=discord +[badge-php-version]: https://img.shields.io/packagist/php-v/phpcfdi/finkok?logo=php +[badge-release]: https://img.shields.io/github/release/phpcfdi/finkok?logo=git +[badge-license]: https://img.shields.io/github/license/phpcfdi/finkok?logo=open-source-initiative +[badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/finkok/build.yml?branch=main&logo=github-actions +[badge-reliability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_finkok&metric=reliability_rating +[badge-maintainability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_finkok&metric=sqale_rating +[badge-coverage]: https://img.shields.io/sonar/coverage/phpcfdi_finkok/main?logo=sonarqubecloud&server=https%3A%2F%2Fsonarcloud.io +[badge-violations]: https://img.shields.io/sonar/violations/phpcfdi_finkok/main?format=long&logo=sonarqubecloud&server=https%3A%2F%2Fsonarcloud.io +[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/finkok?logo=packagist From e1395b07a966c3419e95276a1a181857ad0fe916 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 14:30:13 -0600 Subject: [PATCH 21/23] Remove functional-test workflow --- .github/workflows/functional-tests.yml | 59 -------------------------- CONTRIBUTING.md | 1 - docs/PruebasDeIntegracionContinua.md | 2 +- 3 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 .github/workflows/functional-tests.yml diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml deleted file mode 100644 index 01ec58f..0000000 --- a/.github/workflows/functional-tests.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: functional-tests -on: - # secrets are not passed to workflows that are triggered by a pull request from a fork. - # see https://docs.github.com/en/actions/reference/encrypted-secrets - workflow_dispatch: - push: - branches: [ 'main' ] - -# Actions -# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action - -jobs: - functional-tests: - name: Functional tests - runs-on: "ubuntu-latest" - - steps: - - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - extensions: soap - coverage: xdebug - tools: composer:v2 - env: - fail-fast: true - - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install project dependencies - run: composer upgrade --no-interaction --no-progress --prefer-dist - - - name: Install SAT XML resources - shell: bash - run: | - git clone --depth 1 https://github.com/phpcfdi/resources-sat-xml resources-sat-xml-cloned - mv resources-sat-xml-cloned/resources vendor/eclipxe/cfdiutils/build/resources - rm -r -f resources-sat-xml-cloned - - - name: Set up environment file - run: gpg --quiet --batch --yes --decrypt --passphrase="$ENV_GPG_SECRET" --output tests/.env tests/.env-testing.enc - env: - ENV_GPG_SECRET: ${{ secrets.ENV_GPG_SECRET }} - - - name: Run integration tests with code coverage - run: vendor/bin/phpunit --testdox --exclude-group large --coverage-clover=build/coverage-clover.xml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 303263a..56238dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,6 @@ puedes ejecutar el siguiente comando: ```shell act -P ubuntu-latest=shivammathur/node:latest -W .github/workflows/build.yml -act -P ubuntu-latest=shivammathur/node:latest -W .github/workflows/functional-tests.yml -s ENV_GPG_SECRET=********** ``` diff --git a/docs/PruebasDeIntegracionContinua.md b/docs/PruebasDeIntegracionContinua.md index b1a56ca..9440557 100644 --- a/docs/PruebasDeIntegracionContinua.md +++ b/docs/PruebasDeIntegracionContinua.md @@ -42,7 +42,7 @@ gpg --no-symkey-cache --symmetric --cipher-algo AES256 --output tests/.env-testi ``` Para desencriptar el archivo de configuración `tests/.env-testing.enc -> tests/.env` se puede usar el siguiente -comando. Esta operación es la que se ejecuta en `functional-test.yml` usando el secreto `secrets.ENV_GPG_SECRET`. +comando. Esta operación es la que se ejecuta en `sonarqube-cloud.yml` usando el secreto `secrets.ENV_GPG_SECRET`. ```shell gpg --quiet --batch --yes --decrypt --output - tests/.env-testing.enc From 22058aaf46ab6b24ced24ba718196297f4e77de1 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 14:53:36 -0600 Subject: [PATCH 22/23] Improve code based on PHPStom inspections --- src/Finkok.php | 2 +- src/FinkokSettings.php | 4 ++-- src/Helpers/CancelSigner.php | 2 +- src/Helpers/FileLogger.php | 4 ++-- src/Helpers/GetSatStatusExtractor.php | 2 +- src/Helpers/JsonDecoderLogger.php | 14 ++++++------- src/Internal/MethodsFilterVariablesTrait.php | 20 +++++-------------- src/QuickFinkok.php | 4 ++-- src/Services/AbstractResult.php | 7 ++++--- src/Services/Manifest/GetContractsService.php | 2 +- .../Manifest/GetSignedContractsService.php | 2 +- .../Manifest/SignContractsService.php | 2 +- 12 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/Finkok.php b/src/Finkok.php index 4ca51a3..991a723 100644 --- a/src/Finkok.php +++ b/src/Finkok.php @@ -155,7 +155,7 @@ protected function createService(string $method): object * @param object|null $command * @return mixed */ - protected function executeService(string $method, object $service, ?object $command) + protected function executeService(string $method, object $service, ?object $command): mixed { $method = static::SERVICES_MAP[$method][2] ?? $method; if (! is_callable([$service, $method])) { diff --git a/src/FinkokSettings.php b/src/FinkokSettings.php index 78e9fe3..b736ac6 100644 --- a/src/FinkokSettings.php +++ b/src/FinkokSettings.php @@ -63,8 +63,8 @@ public function soapFactory(): SoapFactory * This method created a configured SoapCaller with wsdlLocation and default options * * @param Services $service - * @param string $usernameKey defaults to username, if empty then it will be ommited - * @param string $passwordKey defaults to password, if empty then it will be ommited + * @param string $usernameKey defaults to username, if empty then it will be omitted + * @param string $passwordKey defaults to password, if empty then it will be omitted * @return SoapCaller */ public function createCallerForService( diff --git a/src/Helpers/CancelSigner.php b/src/Helpers/CancelSigner.php index dee84d8..9f2595b 100644 --- a/src/Helpers/CancelSigner.php +++ b/src/Helpers/CancelSigner.php @@ -18,7 +18,7 @@ class CancelSigner * CancelSigner constructor * * @param CancelDocuments $documents - * @param DateTimeImmutable|null $dateTime If null or ommited then use current time and time zone + * @param DateTimeImmutable|null $dateTime If null or omitted then use current time and time zone */ public function __construct(private CancelDocuments $documents, ?DateTimeImmutable $dateTime = null) { diff --git a/src/Helpers/FileLogger.php b/src/Helpers/FileLogger.php index ebfb8c9..026c6b4 100644 --- a/src/Helpers/FileLogger.php +++ b/src/Helpers/FileLogger.php @@ -6,6 +6,7 @@ use Psr\Log\AbstractLogger; use Psr\Log\LoggerInterface; +use Stringable; final class FileLogger extends AbstractLogger implements LoggerInterface { @@ -15,10 +16,9 @@ public function __construct(public string $outputFile = 'php://stdout') /** * @inheritDoc - * @param string|\Stringable $message * @param mixed[] $context */ - public function log($level, $message, array $context = []): void + public function log($level, string|Stringable $message, array $context = []): void { file_put_contents($this->outputFile, $message . PHP_EOL, FILE_APPEND); } diff --git a/src/Helpers/GetSatStatusExtractor.php b/src/Helpers/GetSatStatusExtractor.php index 728f37c..091ce52 100644 --- a/src/Helpers/GetSatStatusExtractor.php +++ b/src/Helpers/GetSatStatusExtractor.php @@ -14,7 +14,7 @@ use RuntimeException; /** - * Based on a XML string or a XML Document it can extract the appropiate values to build a GetSatStatusCommand object + * Based on an XML string or an XML Document it can extract the appropriate values to build a GetSatStatusCommand object * It is using the CFDI QR expressions */ class GetSatStatusExtractor diff --git a/src/Helpers/JsonDecoderLogger.php b/src/Helpers/JsonDecoderLogger.php index 7588e81..929aba2 100644 --- a/src/Helpers/JsonDecoderLogger.php +++ b/src/Helpers/JsonDecoderLogger.php @@ -6,6 +6,7 @@ use Psr\Log\AbstractLogger; use Psr\Log\LoggerInterface; +use Stringable; /** * Esta clase es un adaptador para convertir un mensaje de registro (log) que está @@ -33,7 +34,7 @@ public function __construct(private LoggerInterface $logger) /** * Define si se utilizará la función \json_validate en caso de estar disponible. * - * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el espado previo. + * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el estado previo. * @return bool El estado previo */ public function setUseJsonValidateIfAvailable(?bool $value = null): bool @@ -48,7 +49,7 @@ public function setUseJsonValidateIfAvailable(?bool $value = null): bool /** * Define si también se mandará el mensaje JSON al Logger. * - * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el espado previo. + * @param bool|null $value El nuevo estado, si se establece NULL entonces solo devuelve el estado previo. * @return bool El estado previo */ public function setAlsoLogJsonMessage(?bool $value = null): bool @@ -67,10 +68,9 @@ public function lastMessageWasJsonValid(): bool /** * @inheritDoc - * @param string|\Stringable $message * @param mixed[] $context */ - public function log($level, $message, array $context = []): void + public function log($level, string|Stringable $message, array $context = []): void { $this->logger->log($level, $this->jsonDecode($message), $context); if ($this->lastMessageWasJsonValid && $this->alsoLogJsonMessage) { @@ -78,8 +78,7 @@ public function log($level, $message, array $context = []): void } } - /** @param string|\Stringable $string */ - private function jsonDecode($string): string + private function jsonDecode(string|Stringable $string): string { $this->lastMessageWasJsonValid = false; $string = strval($string); @@ -104,8 +103,7 @@ private function jsonDecode($string): string return $string; } - /** @param mixed $var */ - private function varDump($var): string + private function varDump(mixed $var): string { return print_r($var, true); } diff --git a/src/Internal/MethodsFilterVariablesTrait.php b/src/Internal/MethodsFilterVariablesTrait.php index c25209d..f580134 100644 --- a/src/Internal/MethodsFilterVariablesTrait.php +++ b/src/Internal/MethodsFilterVariablesTrait.php @@ -8,11 +8,8 @@ trait MethodsFilterVariablesTrait { - /** - * @param mixed $variable - * @return array - */ - private function filterArrayOfStdClass($variable): array + /** @return array */ + private function filterArrayOfStdClass(mixed $variable): array { if (! is_array($variable)) { return []; @@ -27,11 +24,8 @@ private function filterArrayOfStdClass($variable): array return $result; } - /** - * @param mixed $variable - * @return array - */ - private function filterArrayOfStrings($variable): array + /** @return array */ + private function filterArrayOfStrings(mixed $variable): array { if (! is_array($variable)) { return []; @@ -46,11 +40,7 @@ private function filterArrayOfStrings($variable): array return $result; } - /** - * @param mixed $variable - * @return string - */ - private function filterString($variable): string + private function filterString(mixed $variable): string { if (! is_scalar($variable)) { return ''; diff --git a/src/QuickFinkok.php b/src/QuickFinkok.php index 062234f..fc6a56b 100644 --- a/src/QuickFinkok.php +++ b/src/QuickFinkok.php @@ -114,7 +114,7 @@ public function stampQueryPending(string $uuid): Stamping\QueryPendingResult } /** - * Este método es el encargado de cancelar uno o varios CFDI emitidos por medio de los web services de Finkok + * Este método es el encargado de cancelar uno o varios CFDI emitidos por medio de los webservices de Finkok * Durante el proceso no se envía ningún CSD a Finkok y la solicitud firmada es creada usando los datos del CSD * * @param Credential $credential @@ -540,7 +540,7 @@ public function retentionStamped(string $preCfdi): Retentions\StampedResult } /** - * Este método es el encargado de cancelar un CFDI de retenciones emitido por medio de los web services de Finkok + * Este método es el encargado de cancelar un CFDI de retenciones emitido por medio de los webservices de Finkok * Durante el proceso no se envía ningún CSD a Finkok y la solicitud firmada es creada usando los datos del CSD * * @param Credential $credential diff --git a/src/Services/AbstractResult.php b/src/Services/AbstractResult.php index 3785115..09ee981 100644 --- a/src/Services/AbstractResult.php +++ b/src/Services/AbstractResult.php @@ -31,11 +31,12 @@ public function rawData(): stdClass } /** - * @param stdClass|array|mixed $haystack + * @template T + * @param T $haystack * @param string ...$location - * @return mixed + * @return T|null */ - protected function findInDescendent($haystack, string ...$location) + protected function findInDescendent(mixed $haystack, string ...$location): mixed { if ([] === $location) { return $haystack; diff --git a/src/Services/Manifest/GetContractsService.php b/src/Services/Manifest/GetContractsService.php index 2360c79..50d6d13 100644 --- a/src/Services/Manifest/GetContractsService.php +++ b/src/Services/Manifest/GetContractsService.php @@ -20,7 +20,7 @@ public function settings(): FinkokSettings public function obtainContracts(GetContractsCommand $command): GetContractsResult { - // this empty string are for ommiting sending username and password + // this empty string are for omitting sending username and password $soapCaller = $this->settings()->createCallerForService(Services::manifest(), '', ''); $rawResponse = $soapCaller->call('get_contracts_snid', [ 'snid' => $command->snid(), diff --git a/src/Services/Manifest/GetSignedContractsService.php b/src/Services/Manifest/GetSignedContractsService.php index dbf0245..d6fc413 100644 --- a/src/Services/Manifest/GetSignedContractsService.php +++ b/src/Services/Manifest/GetSignedContractsService.php @@ -20,7 +20,7 @@ public function settings(): FinkokSettings public function getSignedContracts(GetSignedContractsCommand $command): GetSignedContractsResult { - // this empty string are for ommiting sending username and password + // this empty string are for omitting sending username and password $soapCaller = $this->settings()->createCallerForService(Services::manifest(), '', ''); $rawResponse = $soapCaller->call('get_documents', [ 'snid' => $command->snid(), diff --git a/src/Services/Manifest/SignContractsService.php b/src/Services/Manifest/SignContractsService.php index 56b094b..dbbedcb 100644 --- a/src/Services/Manifest/SignContractsService.php +++ b/src/Services/Manifest/SignContractsService.php @@ -20,7 +20,7 @@ public function settings(): FinkokSettings public function sendSignedContracts(SignContractsCommand $command): SignContractsResult { - // this empty string are for ommiting sending username and password + // this empty string are for omitting sending username and password $soapCaller = $this->settings()->createCallerForService(Services::manifest(), '', ''); $rawResponse = $soapCaller->call('sign_contract', [ 'snid' => $command->snid(), From d4969df549509d8d775970396933bc0564428a23 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Sat, 8 Nov 2025 15:10:08 -0600 Subject: [PATCH 23/23] Prepare version 0.6.0 --- docs/CHANGELOG.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 79308de..6902433 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,36 @@ Nos apegamos a [SEMVER](SEMVER.md), revisa la información para entender mejor e Estos cambios se aplican y se publican, pero aún no son parte de una versión liberada. +## Versión 0.6.0 2025-11-08 + +Esta versión tiene cambios importantes dado que: +- Elimina la compatibilidad con PHP 7.3, PHP 7.4 y PHP 8.0. +- Agrega la compatibilidad con PHP 8.4. + +Al realizar esta actualización, también cambiaron algunos nombres de parámetros, específicamente: + +- `PhpCfdi\Finkok\Finkok#__construct` parámetro `factory` a `settings`. +- `PhpCfdi\Finkok\QuickFinkok#__construct()` parámetro `factory` a `settings`. +- `PhpCfdi\Finkok\Services\Registration\Customer#__construct()` parámetro `raw` a `data`. +- `PhpCfdi\Finkok\Services\Stamping\StampingAlert#__construct()` parámetro `raw` a `data`. +- `PhpCfdi\Finkok\Services\Cancel\CancelledDocument#__construct()` parámetro `raw` a `data`. + +Se hacen varios cambios menores: + +- Se actualiza el año de licencia a 2025. +- Se actualizan las insignias a las comúnmente usadas en PhpCfdi. + +Se hacen varios cambios al entorno de desarrollo: + +- Se corrige la documentación de pruebas de integración contínua y pruebas funcionales. +- Se elimina la integración con Scrutinizer CI. Gracias por todo. +- Se agrega la integración con SonarQube Cloud. +- Se actualizan los estándares de código a los comúnmente usados en PhpCfdi. +- Se ejecutan los flujos de trabajo en PHP 8.4. +- Se agrega PHP 8.4 a la matriz de pruebas. +- Se elimina PHP 7.3, 7.4 y 8.0 de la matriz de pruebas. +- Se actualizan las herramientas de desarrollo. + ## Versión 0.5.5 2024-05-24 Se mueve `PhpCfdi\Finkok\Tests\LoggerPrinter` a `PhpCfdi\Finkok\Helpers\FileLogger` para permitir la distribución @@ -16,7 +46,7 @@ generado por la función `print_r`. Se puede configurar para enviar también el Se normaliza el formato de los mensajes JSON para usar `JSON_PRETTY_PRINT` y `JSON_UNESCAPED_SLASHES`. -Se actualiza la documentación en el `README`. +Se actualiza la documentación en el archivo `README`. ## Versión 0.5.4 2024-04-12