Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']
php-version: ['8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpcs" version="^3.13.5" installed="3.13.5" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.13.5" installed="3.13.5" location="./tools/phpcbf" copy="false"/>
<phar name="php-cs-fixer" version="^3.89.2" installed="3.89.2" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpstan" version="^2.1.31" installed="2.1.31" location="./tools/phpstan" copy="false"/>
<phar name="phpcs" version="^4.0.1" installed="4.0.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^4.0.1" installed="4.0.1" location="./tools/phpcbf" copy="false"/>
<phar name="php-cs-fixer" version="^3.92.5" installed="3.92.5" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpstan" version="^2.1.36" installed="2.1.36" location="./tools/phpstan" copy="false"/>
<phar name="composer-normalize" version="^2.48.2" installed="2.48.2" location="./tools/composer-normalize" copy="false"/>
</phive>
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'type_declaration_spaces' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'match', 'parameters']],
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['array_destructuring', 'arrays', 'match', 'arguments', 'parameters']],
'no_blank_lines_after_phpdoc' => true,
'object_operator_without_whitespace' => true,
'binary_operator_spaces' => true,
Expand All @@ -38,6 +38,7 @@
'concat_space' => ['spacing' => 'one'],
'linebreak_after_opening_tag' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => ['import_classes' => true],
// symfony:risky
'no_alias_functions' => true,
'self_accessor' => true,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 - 2025 PhpCfdi https://www.phpcfdi.com/
Copyright (c) 2019 - 2026 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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
"phpcfdi/credentials": "^1.3.0",
"phpcfdi/xml-cancelacion": "^2.0.5",
"psr/log": "^3.0",
"robrichards/xmlseclibs": "^3.1.3"
"robrichards/xmlseclibs": "^3.1.4"
},
"require-dev": {
"ext-fileinfo": "*",
"eclipxe/cfdiutils": "^3.0.1",
"phpcfdi/rfc": "^1.2",
"phpunit/phpunit": "^10.5",
"phpunit/phpunit": "^10.5.50",
"rector/rector": "^2.2",
"symfony/dotenv": "^6.0 || ^7.0"
},
Expand Down
17 changes: 17 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@ 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.1 2026-02-04

- Se comprueba la compatibilidad con PHP 8.5.
- Se actualizan dependencias para evitar alertas de seguridad (CVE).
- Se agrega una validación para prevenir el uso de `json_validate` en versiones de PHP donde no se soporta.

Se hacen varios cambios menores:

- Actualización del estándar de código.
- Actualización del año de licencia a 2026.

Se hacen varios cambios al entorno de desarrollo:

- Se agrega PHP 8.5 a la matriz de pruebas.
- Se actualizan las herramientas de desarrollo.

## 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.

Expand Down
2 changes: 1 addition & 1 deletion src/Finkok.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,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', $service::class, $method)
sprintf('The service %s does not have a method %s', $service::class, $method),
);
}
return $service->{$method}($command);
Expand Down
2 changes: 1 addition & 1 deletion src/FinkokSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function createCallerForService(
$wsdlLocation = $this->environment()->endpoint($service);
$credentials = array_merge(
('' !== $usernameKey) ? [$usernameKey => $this->username()] : [],
('' !== $passwordKey) ? [$passwordKey => $this->password()] : []
('' !== $passwordKey) ? [$passwordKey => $this->password()] : [],
);
return $this->soapFactory()->createSoapCaller($wsdlLocation, $credentials);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/DocumentSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function signDocumentUsingCredential(DOMDocument $document, Credential $c
$document,
XMLSecurityDSig::SHA1,
['http://www.w3.org/2000/09/xmldsig#enveloped-signature'],
['force_uri' => true]
['force_uri' => true],
);

$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, ['type' => 'private']);
Expand Down
23 changes: 16 additions & 7 deletions src/Helpers/JsonDecoderLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,17 @@ public function log($level, string|Stringable $message, array $context = []): vo
private function jsonDecode(string|Stringable $string): string
{
$this->lastMessageWasJsonValid = false;
$string = strval($string);

// json_validate and json_decode
if ($this->useJsonValidateIfAvailable && function_exists('\json_validate')) {
if (\json_validate($string)) {
$this->lastMessageWasJsonValid = true;
return $this->varDump(json_decode($string));
if ($this->useJsonValidateIfAvailable) {
$string = $this->jsonDecodeWithValidate($string);
if ($this->lastMessageWasJsonValid()) {
return $string;
}

return $string;
}

// json_decode only
$string = (string) $string;
$decoded = json_decode($string);
if (JSON_ERROR_NONE === json_last_error()) {
$this->lastMessageWasJsonValid = true;
Expand All @@ -103,6 +101,17 @@ private function jsonDecode(string|Stringable $string): string
return $string;
}

private function jsonDecodeWithValidate(string|Stringable $string): string
{
$string = (string) $string;
if (function_exists('json_validate') && json_validate($string)) {
$this->lastMessageWasJsonValid = true;
return $this->varDump(json_decode($string));
}

return $string;
}

private function varDump(mixed $var): string
{
return print_r($var, true);
Expand Down
2 changes: 1 addition & 1 deletion src/QuickFinkok.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public function customerSignAndSendContracts(
if (! $documents->success()) {
return Manifest\SignContractsResult::createFromData(
false,
sprintf('Unable to get contracts: %s', $documents->error() ?: '(no error)')
sprintf('Unable to get contracts: %s', $documents->error() ?: '(no error)'),
);
}
$privacy = (new Helpers\DocumentSigner($rfc, $signedOn, $documents->privacy()))->signUsingCredential($fiel);
Expand Down
2 changes: 1 addition & 1 deletion src/Services/AbstractResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(protected stdClass $data, string ...$meanLocation)
$root = $this->findInDescendent($this->data, ...$meanLocation);
if (! $root instanceof stdClass) {
throw new InvalidArgumentException(
sprintf('Unable to find mean object at /%s', implode('/', $meanLocation))
sprintf('Unable to find mean object at /%s', implode('/', $meanLocation)),
);
}
$this->root = $root;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Cancel/AcceptRejectSignatureResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(stdClass $data)
array_merge(
$this->filterArrayOfStdClass($aceptacion),
$this->filterArrayOfStdClass($rechazo),
)
),
);
$this->error = $this->get('error');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Cancel/AcceptRejectUuidList.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function createItemFromStdClass(stdClass $content): object
return new AcceptRejectUuidItem(
$this->filterString($source->uuid ?? ''),
new AcceptRejectUuidStatus($this->filterString($source->status ?? '0')),
$answer
$answer,
);
}
}
2 changes: 1 addition & 1 deletion src/Services/Cancel/RelatedItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function createItemFromStdClass(stdClass $content): object
return new RelatedItem(
$this->filterString($content->{'uuid'} ?? ''),
$this->filterString($content->{'emisor'} ?? ''),
$this->filterString($content->{'receptor'} ?? '')
$this->filterString($content->{'receptor'} ?? ''),
);
}
}
2 changes: 1 addition & 1 deletion src/Services/Registration/AddService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function add(AddCommand $command): AddResult
$soapCaller = $this->settings()->createCallerForService(
Services::registration(),
'reseller_username',
'reseller_password'
'reseller_password',
);
$rawResponse = $soapCaller->call('add', array_filter([
'taxpayer_id' => $command->rfc(),
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Registration/EditService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function edit(EditCommand $command): EditResult
$soapCaller = $this->settings()->createCallerForService(
Services::registration(),
'reseller_username',
'reseller_password'
'reseller_password',
);
$rawResponse = $soapCaller->call('edit', array_filter([
'taxpayer_id' => $command->rfc(),
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Registration/ObtainCustomersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function obtainPage(ObtainCustomersCommand $command): ObtainCustomersResu
$soapCaller = $this->settings()->createCallerForService(
Services::registration(),
'username',
'password'
'password',
);
$rawResponse = $soapCaller->call('customers', [
'page' => $command->page(),
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Registration/ObtainService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function obtain(ObtainCommand $command): ObtainResult
$soapCaller = $this->settings()->createCallerForService(
Services::registration(),
'reseller_username',
'reseller_password'
'reseller_password',
);
$rawResponse = $soapCaller->call('get', [
'taxpayer_id' => $command->rfc(),
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Utilities/ReportCreditResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(stdClass $data)
parent::__construct($data, 'report_creditResult');

$items = $this->filterArrayOfStdClass(
$this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit')
$this->findInDescendent($data, 'report_creditResult', 'result', 'ReportTotalCredit'),
);
foreach ($items as $item) {
$this->items[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Utilities/ReportTotalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(

if ($this->startPeriod > $this->endPeriod) {
throw new LogicException(
sprintf('Start period %s cannot be greater than end period %s', $this->startPeriod, $this->endPeriod)
sprintf('Start period %s cannot be greater than end period %s', $this->startPeriod, $this->endPeriod),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Utilities/ReportUuidResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(stdClass $data)
parent::__construct($data, 'report_uuidResult');

$items = $this->filterArrayOfStdClass(
$this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID')
$this->findInDescendent($data, 'report_uuidResult', 'invoices', 'ReportUUID'),
);
foreach ($items as $item) {
$this->items[] = [
Expand Down
4 changes: 2 additions & 2 deletions src/SoapCaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public function call(string $methodName, array $parameters): stdClass
array_merge(
['method' => $methodName, 'parameters' => $finalParameters],
$this->extractSoapClientTrace($soap),
['exception' => ($exception instanceof JsonSerializable) ? $exception : print_r($exception, true)]
['exception' => ($exception instanceof JsonSerializable) ? $exception : print_r($exception, true)],
),
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
)));
throw new RuntimeException(sprintf('Fail soap call to %s', $methodName), previous: $exception);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Factories/RandomPreCfdi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function createHelper(): PreCfdiCreatorHelper
return new PreCfdiCreatorHelper(
TestCase::filePath('certs/EKU9003173C9.cer'),
TestCase::filePath('certs/EKU9003173C9.key.pem'),
trim(TestCase::fileContentPath('certs/EKU9003173C9.password.bin'))
trim(TestCase::fileContentPath('certs/EKU9003173C9.password.bin')),
);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Factories/RandomPreCfdiRetention.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function createValid(): string
'EKU9003173C9',
'ESCUELA KEMPER URGATE',
'52000',
'601'
'601',
);
$helper->setCveReten('14');
$helper->setInvoiceDate(new DateTimeImmutable());
Expand Down Expand Up @@ -57,7 +57,7 @@ public function createValid(): string
'MontISRAcredNal' => '0',
'MontDivAcumNal' => '0',
'MontDivAcumExt' => '0',
])
]),
);

$preCfdi = $helper->signPreCfdi($creator);
Expand All @@ -70,8 +70,8 @@ public function createValid(): string
PHP_EOL,
implode(PHP_EOL, array_map(fn (Assert $assert): string => rtrim(
sprintf('%s - %s: %s', $assert->getCode(), $assert->getTitle(), $assert->getExplanation()),
' :'
), $assets->errors()))
' :',
), $assets->errors())),
));
}

Expand Down
Loading