Skip to content

Commit 0da4ddd

Browse files
authored
Merge pull request #59 from eclipxe13/maintenance
Compatibilidad PHP 8.2 y mantenimiento (versión 0.5.3)
2 parents 4872522 + e429b82 commit 0da4ddd

File tree

13 files changed

+113
-56
lines changed

13 files changed

+113
-56
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup PHP
2222
uses: shivammathur/setup-php@v2
2323
with:
24-
php-version: '8.1'
24+
php-version: '8.2'
2525
coverage: none
2626
tools: cs2pr, phpcs
2727
env:
@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup PHP
3939
uses: shivammathur/setup-php@v2
4040
with:
41-
php-version: '8.1'
41+
php-version: '8.2'
4242
coverage: none
4343
tools: cs2pr, php-cs-fixer
4444
env:
@@ -55,14 +55,14 @@ jobs:
5555
- name: Setup PHP
5656
uses: shivammathur/setup-php@v2
5757
with:
58-
php-version: '8.1'
58+
php-version: '8.2'
5959
coverage: none
6060
tools: composer:v2, phpstan
6161
env:
6262
fail-fast: true
6363
- name: Get composer cache directory
6464
id: composer-cache
65-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
65+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
6666
- name: Cache dependencies
6767
uses: actions/cache@v3
6868
with:
@@ -79,7 +79,7 @@ jobs:
7979
runs-on: "ubuntu-latest"
8080
strategy:
8181
matrix:
82-
php-versions: ['7.3', '7.4', '8.0', '8.1']
82+
php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2']
8383
steps:
8484
- name: Checkout
8585
uses: actions/checkout@v3
@@ -93,7 +93,7 @@ jobs:
9393
fail-fast: true
9494
- name: Get composer cache directory
9595
id: composer-cache
96-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
96+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
9797
- name: Cache dependencies
9898
uses: actions/cache@v3
9999
with:

.github/workflows/coverage.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ on:
1010
jobs:
1111

1212
tests-coverage:
13-
name: Tests on PHP 8.1 (code coverage)
13+
name: Tests on PHP 8.2 (code coverage)
1414
runs-on: "ubuntu-latest"
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v3
1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2
2020
with:
21-
php-version: '8.1'
21+
php-version: '8.2'
2222
coverage: xdebug
2323
tools: composer:v2
2424
env:
2525
fail-fast: true
2626
- name: Get composer cache directory
2727
id: composer-cache
28-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
28+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
2929
- name: Cache dependencies
3030
uses: actions/cache@v3
3131
with:
@@ -54,15 +54,15 @@ jobs:
5454
id: check-secrets
5555
run: |
5656
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
57-
echo "::set-output name=github::yes"
57+
echo "github=yes" >> $GITHUB_OUTPUT
5858
else
59-
echo "::set-output name=github::no"
59+
echo "github=no" >> $GITHUB_OUTPUT
6060
echo "::warning ::GITHUB_TOKEN non set"
6161
fi
6262
if [ -n "${{ secrets.SONAR_TOKEN }}" ]; then
63-
echo "::set-output name=sonar::yes"
63+
echo "sonar=yes" >> $GITHUB_OUTPUT
6464
else
65-
echo "::set-output name=sonar::no"
65+
echo "sonar=no" >> $GITHUB_OUTPUT
6666
echo "::warning ::SONAR_TOKEN non set"
6767
fi
6868
@@ -79,12 +79,12 @@ jobs:
7979
- name: Setup PHP
8080
uses: shivammathur/setup-php@v2
8181
with:
82-
php-version: '8.0'
82+
php-version: '8.2'
8383
coverage: none
8484
tools: composer:v2
8585
- name: Get composer cache directory
8686
id: composer-cache
87-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
87+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
8888
- name: Cache dependencies
8989
uses: actions/cache@v3
9090
with:

.phive/phars.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="php-cs-fixer" version="^3.11.0" installed="3.11.0" location="./tools/php-cs-fixer" copy="false"/>
4-
<phar name="phpcs" version="^3.7.1" installed="3.7.1" location="./tools/phpcs" copy="false"/>
5-
<phar name="phpcbf" version="^3.7.1" installed="3.7.1" location="./tools/phpcbf" copy="false"/>
6-
<phar name="phpstan" version="^1.8.6" installed="1.8.6" location="./tools/phpstan" copy="false"/>
3+
<phar name="php-cs-fixer" version="^3.17.0" installed="3.17.0" location="./tools/php-cs-fixer" copy="false"/>
4+
<phar name="phpcs" version="^3.7.2" installed="3.7.2" location="./tools/phpcs" copy="false"/>
5+
<phar name="phpcbf" version="^3.7.2" installed="3.7.2" location="./tools/phpcbf" copy="false"/>
6+
<phar name="phpstan" version="^1.10.17" installed="1.10.17" location="./tools/phpstan" copy="false"/>
77
</phive>

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contribuciones
22

3-
Las contribuciones son bienvenidas. Aceptamos *Pull Requests* en el [repositorio GitHub][homepage].
3+
Las contribuciones son bienvenidas. Aceptamos *Pull Requests* en el [repositorio GitHub][project].
44

55
Este proyecto se apega al siguiente [Código de Conducta][coc].
66
Al participar en este proyecto y en su comunidad, deberás seguir este código.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 - 2022 PhpCfdi https://www.phpcfdi.com/
3+
Copyright (c) 2019 - 2023 PhpCfdi https://www.phpcfdi.com/
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (! $fiel->isValid()) {
5959
}
6060

6161
// creación del web client basado en Guzzle que implementa WebClientInterface
62-
// para usarlo necesitas instalar guzzlehttp/guzzle pues no es una dependencia directa
62+
// para usarlo necesitas instalar guzzlehttp/guzzle, pues no es una dependencia directa
6363
$webClient = new GuzzleWebClient();
6464

6565
// creación del objeto encargado de crear las solicitudes firmadas usando una FIEL
@@ -610,7 +610,7 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
610610
[badge-php-version]: https://img.shields.io/packagist/php-v/phpcfdi/sat-ws-descarga-masiva?logo=php
611611
[badge-release]: https://img.shields.io/github/release/phpcfdi/sat-ws-descarga-masiva?logo=git
612612
[badge-license]: https://img.shields.io/github/license/phpcfdi/sat-ws-descarga-masiva?logo=open-source-initiative
613-
[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/sat-ws-descarga-masiva/build/main?logo=github-actions
613+
[badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/sat-ws-descarga-masiva/build.yml?branch=main&logo=github-actions
614614
[badge-reliability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_sat-ws-descarga-masiva&metric=reliability_rating
615615
[badge-maintainability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_sat-ws-descarga-masiva&metric=sqale_rating
616616
[badge-coverage]: https://img.shields.io/sonar/coverage/phpcfdi_sat-ws-descarga-masiva/main?logo=sonarcloud&server=https%3A%2F%2Fsonarcloud.io

docs/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ que nombraremos así: ` Breaking . Feature . Fix `, donde:
1414
**Importante:** Las reglas de SEMVER no aplican si estás usando una rama (por ejemplo `main-dev`)
1515
o estás usando una versión cero (por ejemplo `0.18.4`).
1616

17+
## Versión 0.5.3 2023-06-07
18+
19+
- Se verifica la compatibilidad con PHP 8.2.
20+
- Se eliminan las llaves en la interpolación de variables (deprecado en PHP 8.2).
21+
- Se actualiza el año de la licencia.
22+
- Se modifican las pruebas para futura compatibilidad con PHPUnit 10.
23+
- Se corrige la exclusión de archivos en `sonar-project.properties`.
24+
- Se corrige el archivo `CONTRIBUTING.md` usando el ancla correcta del proyecto.
25+
- Se corrige la insignia de construcción `badge-build`.
26+
- En los flujos de trabajo
27+
- Se agrega PHP 8.2 a la matriz de pruebas.
28+
- Se ejecutan los trabajos en PHP 8.2.
29+
- Se sustituye la directiva de GitHub `::set-output` por `$GITHUB_OUTPUT`.
30+
- Se actualizan las herramientas de desarrollo.
31+
1732
## Versión 0.5.2 2022-09-30
1833

1934
#### Consulta por UUID

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sonar.sourceEncoding=UTF-8
44
sonar.language=php
55
sonar.sources=src
66
sonar.tests=tests
7-
sonar.exclusions=vendor/,tools/,build/,tests/_files/
7+
sonar.test.exclusions=tests/_files/**/*
88
sonar.working.directory=build/.scannerwork
99
sonar.php.tests.reportPath=build/sonar-junit.xml
1010
sonar.php.coverage.reportPaths=build/sonar-coverage.xml

src/PackageReader/Internal/MetadataContent.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Generator;
88
use PhpCfdi\SatWsDescargaMasiva\PackageReader\MetadataItem;
9-
use SplTempFileObject;
109

1110
/**
1211
* Helper to iterate inside a Metadata CSV file
@@ -23,7 +22,7 @@ final class MetadataContent
2322

2423
/**
2524
* The $iterator will be used in a foreach loop to create MetadataItems
26-
* The first iteration must contain an array of header names that will be renames to lower case first letter
25+
* The first iteration must contain an array of header names that will be renamed to lower case first letter
2726
* The next iterations must contain an array with data
2827
*
2928
* @param CsvReader $csvReader
@@ -36,7 +35,7 @@ public function __construct(CsvReader $csvReader, ThirdPartiesRecords $thirdPart
3635
}
3736

3837
/**
39-
* This method fix the content and create a SplTempFileObject to store the information
38+
* This method apply the preprocessor fixes on the contents
4039
*
4140
* @param string $contents
4241
* @param ThirdPartiesRecords|null $thirdParties

src/RequestBuilder/FielRequestBuilder/FielRequestBuilder.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function authorization(DateTime $created, DateTime $expires, string $secu
3737
$keyInfoData = <<<EOT
3838
<KeyInfo>
3939
<o:SecurityTokenReference>
40-
<o:Reference URI="#${uuid}" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
40+
<o:Reference URI="#$uuid" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
4141
</o:SecurityTokenReference>
4242
</KeyInfo>
4343
EOT;
@@ -57,10 +57,10 @@ public function authorization(DateTime $created, DateTime $expires, string $secu
5757
<u:Created>{$created->formatSat()}</u:Created>
5858
<u:Expires>{$expires->formatSat()}</u:Expires>
5959
</u:Timestamp>
60-
<o:BinarySecurityToken u:Id="${uuid}" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
61-
${certificate}
60+
<o:BinarySecurityToken u:Id="$uuid" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
61+
$certificate
6262
</o:BinarySecurityToken>
63-
${signatureData}
63+
$signatureData
6464
</o:Security>
6565
</s:Header>
6666
<s:Body>
@@ -119,7 +119,7 @@ function (RfcMatch $rfcMatch): string {
119119
},
120120
iterator_to_array($rfcReceivers)
121121
));
122-
$xmlRfcReceived = "<des:RfcReceptores>{$xmlRfcReceived}</des:RfcReceptores>";
122+
$xmlRfcReceived = "<des:RfcReceptores>$xmlRfcReceived</des:RfcReceptores>";
123123
}
124124
}
125125

@@ -141,8 +141,8 @@ function (string $name, string $value): string {
141141

142142
$toDigestXml = <<<EOT
143143
<des:SolicitaDescarga xmlns:des="http://DescargaMasivaTerceros.sat.gob.mx">
144-
<des:solicitud ${solicitudAttributesAsText}>
145-
${xmlRfcReceived}
144+
<des:solicitud $solicitudAttributesAsText>
145+
$xmlRfcReceived
146146
</des:solicitud>
147147
</des:SolicitaDescarga>
148148
EOT;
@@ -153,9 +153,9 @@ function (string $name, string $value): string {
153153
<s:Header/>
154154
<s:Body>
155155
<des:SolicitaDescarga>
156-
<des:solicitud ${solicitudAttributesAsText}>
157-
${xmlRfcReceived}
158-
${signatureData}
156+
<des:solicitud $solicitudAttributesAsText>
157+
$xmlRfcReceived
158+
$signatureData
159159
</des:solicitud>
160160
</des:SolicitaDescarga>
161161
</s:Body>
@@ -172,7 +172,7 @@ public function verify(string $requestId): string
172172

173173
$toDigestXml = <<<EOT
174174
<des:VerificaSolicitudDescarga xmlns:des="http://DescargaMasivaTerceros.sat.gob.mx">
175-
<des:solicitud IdSolicitud="${xmlRequestId}" RfcSolicitante="${xmlRfc}"></des:solicitud>
175+
<des:solicitud IdSolicitud="$xmlRequestId" RfcSolicitante="$xmlRfc"></des:solicitud>
176176
</des:VerificaSolicitudDescarga>
177177
EOT;
178178
$signatureData = $this->createSignature($toDigestXml);
@@ -182,8 +182,8 @@ public function verify(string $requestId): string
182182
<s:Header/>
183183
<s:Body>
184184
<des:VerificaSolicitudDescarga>
185-
<des:solicitud IdSolicitud="${xmlRequestId}" RfcSolicitante="${xmlRfc}">
186-
${signatureData}
185+
<des:solicitud IdSolicitud="$xmlRequestId" RfcSolicitante="$xmlRfc">
186+
$signatureData
187187
</des:solicitud>
188188
</des:VerificaSolicitudDescarga>
189189
</s:Body>
@@ -200,7 +200,7 @@ public function download(string $packageId): string
200200

201201
$toDigestXml = <<<EOT
202202
<des:PeticionDescargaMasivaTercerosEntrada xmlns:des="http://DescargaMasivaTerceros.sat.gob.mx">
203-
<des:peticionDescarga IdPaquete="${xmlPackageId}" RfcSolicitante="${xmlRfcOwner}"></des:peticionDescarga>
203+
<des:peticionDescarga IdPaquete="$xmlPackageId" RfcSolicitante="$xmlRfcOwner"></des:peticionDescarga>
204204
</des:PeticionDescargaMasivaTercerosEntrada>
205205
EOT;
206206
$signatureData = $this->createSignature($toDigestXml);
@@ -210,8 +210,8 @@ public function download(string $packageId): string
210210
<s:Header/>
211211
<s:Body>
212212
<des:PeticionDescargaMasivaTercerosEntrada>
213-
<des:peticionDescarga IdPaquete="${xmlPackageId}" RfcSolicitante="${xmlRfcOwner}">
214-
${signatureData}
213+
<des:peticionDescarga IdPaquete="$xmlPackageId" RfcSolicitante="$xmlRfcOwner">
214+
$signatureData
215215
</des:peticionDescarga>
216216
</des:PeticionDescargaMasivaTercerosEntrada>
217217
</s:Body>
@@ -248,9 +248,9 @@ private function createSignature(string $toDigest, string $signedInfoUri = '', s
248248

249249
return <<<EOT
250250
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
251-
${signedInfo}
252-
<SignatureValue>${signatureValue}</SignatureValue>
253-
${keyInfo}
251+
$signedInfo
252+
<SignatureValue>$signatureValue</SignatureValue>
253+
$keyInfo
254254
</Signature>
255255
EOT;
256256
}
@@ -263,12 +263,12 @@ private function createSignedInfoCanonicalExclusive(string $digested, string $ur
263263
<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
264264
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod>
265265
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
266-
<Reference URI="${uri}">
266+
<Reference URI="$uri">
267267
<Transforms>
268268
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform>
269269
</Transforms>
270270
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
271-
<DigestValue>${digested}</DigestValue>
271+
<DigestValue>$digested</DigestValue>
272272
</Reference>
273273
</SignedInfo>
274274
EOT;
@@ -286,10 +286,10 @@ private function createKeyInfoData(): string
286286
<KeyInfo>
287287
<X509Data>
288288
<X509IssuerSerial>
289-
<X509IssuerName>${issuerName}</X509IssuerName>
290-
<X509SerialNumber>${serial}</X509SerialNumber>
289+
<X509IssuerName>$issuerName</X509IssuerName>
290+
<X509SerialNumber>$serial</X509SerialNumber>
291291
</X509IssuerSerial>
292-
<X509Certificate>${certificate}</X509Certificate>
292+
<X509Certificate>$certificate</X509Certificate>
293293
</X509Data>
294294
</KeyInfo>
295295
EOT;

tests/TestCase.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,41 @@ public static function xmlFormat(string $content): string
4747
$document->loadXML($content);
4848
return $document->saveXML() ?: '';
4949
}
50+
51+
/**
52+
* @param mixed ...$arguments
53+
* @return array{
54+
* number: int,
55+
* message: string,
56+
* file: string,
57+
* line: int,
58+
* return: mixed,
59+
* }
60+
*/
61+
public static function trapError(callable $function, ...$arguments): array
62+
{
63+
$capturedError = [
64+
'number' => 0,
65+
'message' => '',
66+
'file' => '',
67+
'line' => 0,
68+
];
69+
set_error_handler(
70+
function (int $errno, string $errstr, string $errfile = '', int $errline = 0) use (&$capturedError): bool {
71+
$capturedError = [
72+
'number' => $errno,
73+
'message' => $errstr,
74+
'file' => $errfile,
75+
'line' => $errline,
76+
] + $capturedError;
77+
return true;
78+
}
79+
);
80+
try {
81+
$capturedError['return'] = call_user_func($function, ...$arguments);
82+
} finally {
83+
restore_error_handler();
84+
}
85+
return $capturedError;
86+
}
5087
}

0 commit comments

Comments
 (0)