Skip to content

Commit 9c7988d

Browse files
authored
Merge pull request #65 from eclipxe13/php8.0
Version 2.15.0 (PHP 8.0 compatibility)
2 parents fa9c206 + 2edfa20 commit 9c7988d

File tree

256 files changed

+948
-780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+948
-780
lines changed

.appveyor.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ cache:
1414
## Build matrix for lowest and highest possible targets
1515
environment:
1616
matrix:
17-
- php: 7.0
18-
- php: 7.1
19-
- php: 7.2
2017
- php: 7.3
2118
- php: 7.4
19+
- php: 8.0
2220

2321
init:
2422
- SET PATH=c:\tools\php;C:\tools\composer;C:\OpenSSL-v111-Win64\bin;%PATH%
@@ -77,18 +75,17 @@ install:
7775
# setup c:\tools\php\php.ini
7876
if (Test-Path c:\tools\php\php.ini-production) {
7977
Copy-Item -Path c:\tools\php\php.ini-production -Destination c:\tools\php\php.ini
80-
[string]$php_ext_prefix=$(if ($Env:php -lt "7.2") {"php_"} else {""})
8178
Add-Content c:\tools\php\php.ini "`
8279
`n; PHP Custom config `
8380
date.timezone=UTC `
8481
extension_dir=ext `
8582
memory_limit=1G `
86-
extension=${php_ext_prefix}openssl `
87-
extension=${php_ext_prefix}mbstring `
88-
extension=${php_ext_prefix}fileinfo `
89-
extension=${php_ext_prefix}curl `
90-
extension=${php_ext_prefix}xsl `
91-
extension=${php_ext_prefix}soap `
83+
extension=openssl `
84+
extension=mbstring `
85+
extension=fileinfo `
86+
extension=curl `
87+
extension=xsl `
88+
extension=soap `
9289
"
9390
}
9491
@@ -115,8 +112,8 @@ install:
115112
}
116113
# install project dependences and list available tools
117114
- cd c:\projects\project
115+
- composer remove genkgo/xsl squizlabs/php_codesniffer friendsofphp/php-cs-fixer phpstan/phpstan --dev --no-interaction --no-progress --no-update
118116
- appveyor-retry composer install --prefer-dist --no-progress --no-interaction --ansi
119-
- dir vendor\bin
120117
# sat-xml resources as a dependency
121118
- ps: |
122119
appveyor-retry appveyor DownloadFile https://github.com/phpcfdi/resources-sat-xml/archive/master.zip -Filename c:\projects\project\build\sat-xml.zip
@@ -126,8 +123,4 @@ install:
126123
## Run the actual test
127124
test_script:
128125
- cd c:\projects\project
129-
- vendor\bin\phpcs.bat -sp src tests
130-
- vendor\bin\php-cs-fixer.bat fix --dry-run --verbose
131-
- if "%php%"=="7.0" vendor\bin\phpunit.bat --verbose
132-
- if not "%php%"=="7.0" vendor\bin\phpunit.bat --testdox --verbose
133-
- if "%php%"=="7.3" vendor\bin\phpstan.bat analyse --no-progress --level max src/ tests/
126+
- vendor\bin\phpunit.bat --testdox --verbose

.travis.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: php
33
dist: xenial
44

55
# php compatibility
6-
php: ["7.0", "7.1", "7.2", "7.3", "7.4"]
6+
php: ["7.3", "7.4", "8.0"]
77

88
branches:
99
except:
@@ -25,26 +25,29 @@ env:
2525

2626
before_script:
2727
- phpenv config-rm xdebug.ini || true
28-
- travis_retry composer install --no-interaction --prefer-dist
29-
- travis_retry npm install
30-
- travis_retry pip install --user mkdocs
31-
- travis_retry bash tests/resource-sat-xml-download build/
32-
33-
script:
34-
- vendor/bin/phpcs -sp src/ tests/
35-
- vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose
36-
- | # create code coverage file
37-
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
38-
php -dzend_extension=xdebug.so vendor/bin/phpunit --testdox --verbose --coverage-clover="$COVERAGE_FILE"
39-
else
40-
vendor/bin/phpunit --testdox --verbose
28+
- travis_retry composer self-update --2 --no-interaction
29+
- | # only require full development dependencies on FULL_BUILD_PHP_VERSION
30+
if [[ $TRAVIS_PHP_VERSION != $FULL_BUILD_PHP_VERSION ]]; then
31+
composer remove squizlabs/php_codesniffer friendsofphp/php-cs-fixer phpstan/phpstan --dev --no-interaction --no-progress --no-update
4132
fi
42-
- | # only check phpstan on FULL_BUILD_PHP_VERSION
33+
- travis_retry composer update --no-interaction --prefer-dist
34+
- | # only install full development dependencies on FULL_BUILD_PHP_VERSION
4335
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
44-
vendor/bin/phpstan --no-progress analyse --level max src/ tests/
36+
travis_retry npm install
37+
travis_retry pip install --user mkdocs
4538
fi
46-
- node node_modules/markdownlint-cli/markdownlint.js *.md docs/
47-
- ~/.local/bin/mkdocs build --strict --site-dir build/docs
39+
- travis_retry bash tests/resource-sat-xml-download build/
40+
41+
script:
42+
# only phpunit without coverage
43+
- if [[ $TRAVIS_PHP_VERSION != $FULL_BUILD_PHP_VERSION ]]; then vendor/bin/phpunit --testdox --verbose; fi
44+
# full build
45+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then vendor/bin/phpcs -sp src/ tests/; fi
46+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose; fi
47+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then php -dzend_extension=xdebug.so vendor/bin/phpunit --testdox --verbose --coverage-clover="$COVERAGE_FILE"; fi
48+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then vendor/bin/phpstan --no-progress analyse src/ tests/; fi
49+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then node node_modules/markdownlint-cli/markdownlint.js *.md docs/; fi
50+
- if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then ~/.local/bin/mkdocs build --strict --site-dir build/docs; fi
4851

4952
after_script:
5053
- | # upload test covegare to scrutinizer

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
This library provides helper objects to work with Mexican CFDI (Comprobante Fiscal Digital por Internet).
1717

1818
:mexico: Visita la **documentación en español** de esta librería en [Read the docs][documentation].
19-
También te esperamos en el [canal #phpcfdi de discord](https://discord.gg/aFGYXvX).
19+
También te esperamos en el canal [#phpcfdi de discord](https://discord.gg/aFGYXvX).
2020

2121
The documentation related to this library and its API is documented in [Read the docs][documentation].
2222
It is written in **spanish language** since is the language of the intented audience.
@@ -40,7 +40,7 @@ CFDI y herramientas del SAT. Y próximamente el lugar donde publicaremos la vers
4040
- Calculate `Comprobante` sums based on the list of `Conceptos`.
4141
- Retrieve the CFDI version information.
4242
- Keep a local copy of the tree of XSD and XSLT file dependences from SAT.
43-
- Keep a local copy of certificates to avoid download them each time.
43+
- Keep a local copy of certificates to avoid downloads them each time.
4444
- Check the SAT WebService to get the status of a CFDI (*Estado*, *EsCancelable* y *EstatusCancelacion*) without WSDL.
4545

4646

@@ -65,12 +65,20 @@ composer require eclipxe/cfdiutils
6565

6666
## PHP Support
6767

68-
This library is compatible with PHP versions 7.0 and above.
68+
This library is compatible with **PHP 7.2 and above**.
6969
Please, try to use the full potential of the language like type declarations.
7070

7171
The intented support is to be aligned with oldest *Active support* PHP Branch.
7272
See <https://www.php.net/supported-versions.php> for more details.
7373

74+
| CfdiUtils | PHP Supported versions | Since |
75+
| --------- | ------------------------ | ---------- |
76+
| 1.0 | 7.0, 7.1 | 2017-09-27 |
77+
| 2.0 | 7.0, 7.1 | 2018-01-01 |
78+
| 2.0.1 | 7.0, 7.1, 7.2 | 2018-01-03 |
79+
| 2.8.1 | 7.0, 7.1, 7.2, 7.3 | 2019-03-05 |
80+
| 2.12.7 | 7.0, 7.1, 7.2, 7.3, 7.4 | 2019-12-04 |
81+
| 2.15.0 | 7.3, 7.4, 8.0 | 2021-03-17 |
7482

7583
## Contributing
7684

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"optimize-autoloader": true
2525
},
2626
"require": {
27-
"php": ">=7.0",
27+
"php": ">=7.3",
2828
"ext-libxml": "*",
2929
"ext-dom": "*",
3030
"ext-xsl": "*",
@@ -42,11 +42,11 @@
4242
"genkgo/xsl": "Allows usage of Genkgo/Xsl transformations"
4343
},
4444
"require-dev": {
45-
"genkgo/xsl": "^0.6",
46-
"phpunit/phpunit": "^6.2|^7.3",
45+
"genkgo/xsl": "dev-master",
46+
"phpunit/phpunit": "^9.5",
4747
"squizlabs/php_codesniffer": "^3.0",
4848
"friendsofphp/php-cs-fixer": "^2.4",
49-
"phpstan/phpstan": "^0.9|^0.10|^0.11"
49+
"phpstan/phpstan": "^0.12"
5050
},
5151
"autoload": {
5252
"psr-4": {
@@ -65,21 +65,21 @@
6565
"@dev:docs"
6666
],
6767
"dev:check-style": [
68-
"vendor/bin/php-cs-fixer fix --dry-run --verbose",
69-
"vendor/bin/phpcs --colors -sp src/ tests/"
68+
"@php vendor/bin/php-cs-fixer fix --dry-run --verbose",
69+
"@php vendor/bin/phpcs --colors -sp src/ tests/"
7070
],
7171
"dev:fix-style": [
72-
"vendor/bin/php-cs-fixer fix --verbose",
73-
"vendor/bin/phpcbf --colors -sp src/ tests/"
72+
"@php vendor/bin/php-cs-fixer fix --verbose",
73+
"@php vendor/bin/phpcbf --colors -sp src/ tests/"
7474
],
7575
"dev:docs": [
7676
"node_modules/markdownlint-cli/markdownlint.js *.md docs/",
7777
"mkdocs build --strict --site-dir build/docs"
7878
],
7979
"dev:test": [
8080
"@dev:check-style",
81-
"vendor/bin/phpunit --testdox --verbose --stop-on-failure",
82-
"vendor/bin/phpstan analyse --no-progress --level max src/ tests/"
81+
"@php vendor/bin/phpunit --testdox --verbose --stop-on-failure",
82+
"@php vendor/bin/phpstan analyse --no-progress src/ tests/"
8383
],
8484
"dev:coverage": [
8585
"@php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-text --coverage-html build/coverage/html/"

docs/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,44 @@
2828
- Change visibility of `CfdiUtils\Cleaner\Cleaner#removeIncompleteSchemaLocation()` to private.
2929

3030

31+
## Version 2.15.0 2021-03-17
32+
33+
Improvements:
34+
35+
- Include validation web service version 1.3 new response `ValidacionEFOS` as
36+
`StatusResponse::getValidationEfos() string` and `StatusResponse::isEfosListed() bool`.
37+
- Update `ConsultaCFDIServiceSAT.svc.xml`. It is unused, but exists for compatibility.
38+
39+
General:
40+
41+
- Upgrade to PHPUnit 9.5 and upgrade test suite.
42+
- Test classes are declared as final.
43+
- Remove support for PHP 7.0, PHP 7.1 and PHP 7.2.
44+
- Compatilize with PHP 8.0 / OpenSSL:
45+
- openssl functions does not return resources but objects.
46+
- On deprecated functions run only if PHP version is lower than 8.0 and put annotations for `phpcs`.
47+
48+
Bugfixes:
49+
50+
- Validation `SELLO04` fails when there are special caracters like `é` and `LC_CTYPE` is not setup.
51+
- Fix `COMPIMPUESTOSC01` description typo.
52+
53+
There are some soft backwards incompatibility changes:
54+
55+
- Method __construct() of class CfdiUtils\Validate\Cfdi33\Standard\FechaComprobante became final
56+
- Method __construct() of class CfdiUtils\Validate\Cfdi33\RecepcionPagos\Pago became final
57+
- The return type of CfdiUtils\Validate\Cfdi33\RecepcionPagos\Pago#getValidators() changed from no type to array
58+
- The parameter $decimals of CfdiUtils\Utils\Format::number() changed from no type to a non-contravariant int
59+
- The parameter $content of CfdiUtils\Cleaner\Cleaner::staticClean() changed from no type to a non-contravariant string.
60+
61+
Development environment:
62+
63+
- AppVeyor: Only run PHPUnit
64+
- Travis-CI: On PHP != 7.4 only run PHPUnit
65+
- Travis-CI: On PHP == 7.4 run all the build commands
66+
- PHPStan: Upgrade to version 0.12, downgrade level to 5.
67+
68+
3169
## Version 2.14.2 2021-03-16
3270

3371
### `FormaPago` on `N - Nómina`

docs/TODO.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Lista de tareas pendientes e ideas
22

3-
- Compatibilidad con PHP 7.4
4-
- Firma de CfdiUtils\Utils\Format::number el argumento $decimals debe ser entero
3+
- Incrementar la cobertura de PHPStan al nivel máximo.
54

65
## Verificar problemas conocidos
76

87
### Descarga de certificados desde <https://rdc.sat.gob.mx/rccf/> por certificados vencidos
98

109
Ver: <https://www.phpcfdi.com/sat/problemas-conocidos/descarga-certificados/#problemas-de-caducidad-de-certificados>
1110

11+
*Actualización 2020-10-08*: Este problema se vuelve a presentar.
12+
1213
*Actualización 2020-07-18*: Desde 2019-10-24 este problema parece solucionado.
1314

1415
La descarga de certificados desde `https://rdc.sat.gob.mx/rccf/` falla por un error de configuración
@@ -68,7 +69,7 @@ ideas than need a solution:
6869
## Validation rules for Pagos
6970

7071
The validation rules for "Complemento de Recepción de pagos" are included since version 2.6 but
71-
they require more cases of use and a better understanding of the rules published by SAT.
72+
they require more cases of use, and a better understanding of the rules published by SAT.
7273

7374

7475
## Validation rules for ComercioExterior

docs/componentes/estado-sat.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ y cambiar la URL.
6464
## Datos que entrega la consulta
6565

6666
El servicio entrega cuatro valores: estado de la consulta, estado del cfdi,
67-
estado de cancelabilidad y estado de cancelación.
67+
estado de cancelabilidad, estado de cancelación y validación EFOS.
6868

6969
### CodigoEstatus (estado de consulta)
7070

71-
Este estado está relacionado a la solicitud de información al SAT. No al CFDI.
71+
Este estado está relacionado con la solicitud de información al SAT. No al CFDI.
7272

7373
- `S - Comprobante obtenido satisfactoriamente`
7474
- `N - 601: La expresión impresa proporcionada no es válida`
@@ -102,6 +102,16 @@ Se refiere al estado de la cancelación solicitada previamente.
102102
- `Cancelado con aceptación`: Cancelado con el consentimiento del receptor.
103103
- `Solicitud rechazada`: No se realizó la cancelación por rechazo.
104104

105+
### ValidacionEFOS (estado del emisor en la lista de EFOS)
106+
107+
El WebService del SAT devuelve dos códigos que asumimos se refieren al emisor del CFDI:
108+
109+
- 200: No se enctró en el listado de EFOS.
110+
- 100: Se encontró en el listado de EFOS.
111+
112+
Desconocemos si el código se refiere a si estaba listado en el momento de la emisión del CFDI,
113+
al momento de ser reportado el CFDI al SAT o al momento de consulta.
114+
105115
## Estados mutuamente excluyentes
106116

107117
CodigoEstatus | Estado | EsCancelable | EstatusCancelacion | Explicación
@@ -156,10 +166,11 @@ $service = new WebService();
156166
$response = $service->request($request);
157167

158168
// obtener las respuestas
159-
$response->getCode(); // S - ...
160-
$response->getCfdi(); // Vigente
161-
$response->getCancellable(); // Cancelable con aceptación
162-
$response->getCancellationStatus(); // En proceso
169+
echo $response->getCode(); // S - ...
170+
echo $response->getCfdi(); // Vigente
171+
echo $response->getCancellable(); // Cancelable con aceptación
172+
echo $response->getCancellationStatus(); // En proceso
173+
echo $response->getValidationEfos(); // 200
163174
```
164175

165176
## Problema con el webservice del SAT

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![Coverage Status][badge-coverage]][coverage]
1212
[![Total Downloads][badge-downloads]][downloads]
1313

14-
[`eclipxe/CfdiUtils`](https://github.com/eclipxe13/CfdiUtils)
14+
El proyecto [`eclipxe/CfdiUtils`](https://github.com/eclipxe13/CfdiUtils)
1515
es una librería de PHP para leer, validar y crear CFDI 3.3.
1616

1717
Mira el archivo [README][] para información rápida (en inglés).
@@ -26,7 +26,7 @@ México, en proyectos privados o proyectos libres como el futuro "BuzonCFDI".
2626
Esta librería se ha liberado como software libre para ayudar a otros desarrolladores a
2727
trabajar con CFDI y también para obtener su ayuda, todo lo que la comunidad pueda
2828
contribuir será bien apreciado. Tenemos una comunidad activa y dinámica, nos puedes
29-
encontrar en el [canal #phpcfdi de discord][discord].
29+
encontrar en el canal [#phpcfdi de discord][discord].
3030

3131
No olvides visitar <https://www.phpcfdi.com> donde contamos con muchas más librerías relacionadas con
3232
CFDI y herramientas del SAT. Y próximamente el lugar donde publicaremos la versión `3.y.z`.

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
parameters:
2+
level: 5
23
inferPrivatePropertyTypeFromConstructor: true
34

src/CfdiUtils/CadenaOrigen/GenkgoXslBuilder.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace CfdiUtils\CadenaOrigen;
44

55
use DOMDocument;
6+
use Genkgo\Xsl\Cache\NullCache;
7+
use Genkgo\Xsl\Exception\TransformationException;
68
use Genkgo\Xsl\XsltProcessor;
79

810
class GenkgoXslBuilder extends DOMBuilder
@@ -16,12 +18,15 @@ public function __construct()
1618

1719
protected function transform(DOMDocument $xml, DOMDocument $xsl): string
1820
{
19-
$xslt = new XSLTProcessor();
21+
$xslt = new XSLTProcessor(new NullCache());
2022
$xslt->importStyleSheet($xsl);
2123

22-
// this error silenced call is intentional, avoid transformation errors except when return false
23-
/** @var string|null|false $transform */
24-
$transform = @$xslt->transformToXML($xml);
24+
try {
25+
/** @var string|null|false $transform */
26+
$transform = $xslt->transformToXML($xml);
27+
} catch (TransformationException $exception) {
28+
throw new XsltBuildException('Error while transforming the xslt content', 0, $exception);
29+
}
2530
if (null === $transform || false === $transform) {
2631
throw $this->createLibXmlErrorOrMessage('Error while transforming the xslt content');
2732
}

0 commit comments

Comments
 (0)