diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d907290..8dd0ae7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,16 +12,34 @@ on:
# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action
jobs:
+
+ composer-normalize:
+ name: Composer normalization
+ runs-on: "ubuntu-latest"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.5'
+ coverage: none
+ tools: composer-normalize
+ env:
+ fail-fast: true
+ - name: Composer normalize
+ run: composer-normalize --dry-run
+
phpcs:
name: Coding standards (phpcs)
runs-on: "ubuntu-latest"
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.3'
+ php-version: '8.5'
coverage: none
tools: cs2pr, phpcs
env:
@@ -34,11 +52,11 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.3'
+ php-version: '8.5'
coverage: none
tools: cs2pr, php-cs-fixer
env:
@@ -51,10 +69,10 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
- php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
+ php-versions: ['8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
@@ -68,7 +86,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
@@ -83,11 +101,11 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
- php-version: '8.3'
+ php-version: '8.5'
extensions: bcmath
coverage: none
tools: composer:v2, phpstan
@@ -97,7 +115,7 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
deleted file mode 100644
index ece3b5b..0000000
--- a/.github/workflows/coverage.yml
+++ /dev/null
@@ -1,109 +0,0 @@
-name: coverage
-on:
- workflow_dispatch:
- push:
- branches: [ "main" ]
-
-# Actions
-# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action
-# sonarsource/sonarcloud-github-action@master https://github.com/marketplace/actions/sonarcloud-scan
-
-jobs:
-
- tests-coverage:
- name: Tests on PHP 8.3 (code coverage)
- runs-on: "ubuntu-latest"
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: '8.3'
- 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@v3
- 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: Create code coverage
- run: vendor/bin/phpunit --testdox --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml
- - name: Store code coverage
- uses: actions/upload-artifact@v3
- with:
- name: code-coverage
- path: build/coverage
-
- sonarcloud-secrets:
- name: SonarCloud check secrets are present
- runs-on: ubuntu-latest
- outputs:
- github: ${{ steps.check-secrets.outputs.github }}
- sonar: ${{ steps.check-secrets.outputs.sonar }}
- steps:
- - name: Check secrets are present
- id: check-secrets
- run: |
- if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
- echo "github=yes" >> $GITHUB_OUTPUT
- else
- echo "github=no" >> $GITHUB_OUTPUT
- echo "::warning ::GITHUB_TOKEN non set"
- fi
- if [ -n "${{ secrets.SONAR_TOKEN }}" ]; then
- echo "sonar=yes" >> $GITHUB_OUTPUT
- else
- echo "sonar=no" >> $GITHUB_OUTPUT
- echo "::warning ::SONAR_TOKEN non set"
- fi
-
- sonarcloud:
- name: SonarCloud Scan and Report
- needs: [ "tests-coverage", "sonarcloud-secrets" ]
- if: ${{ needs.sonarcloud-secrets.outputs.github == 'yes' && needs.sonarcloud-secrets.outputs.sonar == 'yes' }}
- runs-on: "ubuntu-latest"
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- - name: Unshallow clone to provide blame information
- run: git fetch --unshallow
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: '8.3'
- coverage: none
- 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@v3
- 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: Obtain code coverage
- uses: actions/download-artifact@v3
- with:
- name: code-coverage
- path: build/coverage
- - 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/sonarcloud-github-action@master
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
diff --git a/.github/workflows/sonarqube-cloud.yml b/.github/workflows/sonarqube-cloud.yml
new file mode 100644
index 0000000..f38cfbf
--- /dev/null
+++ b/.github/workflows/sonarqube-cloud.yml
@@ -0,0 +1,58 @@
+name: "SonarQube Cloud"
+on:
+ workflow_dispatch:
+ push:
+ branches: [ "main" ]
+
+# Actions
+# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action
+# SonarSource/sonarqube-scan-action@v7 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 "$SONAR_TOKEN" ]; then
+ echo "::warning ::SONAR_TOKEN non set"
+ exit 1
+ fi
+ env:
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ - name: Checkout
+ uses: actions/checkout@v6
+ with:
+ fetch-depth: 0 # Disabling shallow clones is recommended for improving the relevancy of reporting
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: '8.5'
+ extensions: bcmath
+ 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: Create code coverage
+ run: vendor/bin/phpunit --testdox --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@v7
+ env:
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
diff --git a/.phive/phars.xml b/.phive/phars.xml
index 92b7c00..5790859 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,7 +1,8 @@
-
-
-
-
+
+
+
+
+
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 176eb9b..840205d 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -15,15 +15,15 @@
->setRules([
'@PSR12' => true,
'@PSR12:risky' => true,
- '@PHP74Migration' => true,
- '@PHP74Migration:risky' => true,
+ '@PHP8x1Migration' => true,
+ '@PHP8x1Migration:risky' => true,
// symfony
'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', 'arguments']],
+ '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,
diff --git a/LICENSE b/LICENSE
index ed6db39..4918b61 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2021 - 2023 PhpCfdi https://www.phpcfdi.com/
+Copyright (c) 2021 - 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
diff --git a/README.md b/README.md
index 72edff4..894b8fc 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# phpcfdi/ceutils
[![Source Code][badge-source]][source]
-[![Packagist PHP Version Support][badge-php-version]][php-version]
+[![PHP Version][badge-php-version]][php-version]
[![Discord][badge-discord]][discord]
[![Latest Version][badge-release]][release]
[![Software License][badge-license]][license]
diff --git a/composer.json b/composer.json
index c5822e4..2a55943 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,7 @@
{
"name": "phpcfdi/ceutils",
"description": "PHP library for Mexican SAT Electronic Accounting 1.3",
+ "license": "MIT",
"keywords": [
"mexico",
"sat",
@@ -8,8 +9,6 @@
"póliza",
"balanza"
],
- "homepage": "https://github.com/PhpCfdi/CeUtils",
- "license": "MIT",
"authors": [
{
"name": "Cesar Aguilera",
@@ -20,18 +19,18 @@
"email": "eclipxe13@gmail.com"
}
],
+ "homepage": "https://github.com/PhpCfdi/CeUtils",
"require": {
- "php": ">=7.4",
+ "php": ">=8.1",
"ext-bcmath": "*",
- "ext-openssl": "*",
"ext-dom": "*",
- "eclipxe/cfdiutils": "^v2.23.3",
- "eclipxe/xmlresourceretriever": "^1.3.2",
- "eclipxe/xmlschemavalidator": "^3.0.2",
- "phpcfdi/credentials": "^1.1.3"
+ "ext-openssl": "*",
+ "eclipxe/cfdiutils": "^3.0.2",
+ "eclipxe/xmlresourceretriever": "^2.0.3",
+ "eclipxe/xmlschemavalidator": "^3.0.5",
+ "phpcfdi/credentials": "^1.3.0"
},
"require-dev": {
- "ergebnis/composer-normalize": "^2.15",
"phpunit/phpunit": "^9.5"
},
"autoload": {
@@ -44,13 +43,9 @@
"PhpCfdi\\CeUtils\\Tests\\": "tests/"
}
},
- "config": {
- "allow-plugins": {
- "ergebnis/composer-normalize": true
- }
- },
"scripts": {
"dev:build": [
+ "@php tools/composer-normalize normalize --dry-run",
"@dev:fix-style",
"@dev:test"
],
@@ -62,6 +57,7 @@
"@php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit --verbose --coverage-html build/coverage/html/"
],
"dev:fix-style": [
+ "@php tools/composer-normalize normalize",
"@php tools/php-cs-fixer fix --verbose",
"@php tools/phpcbf --colors -sp"
],
@@ -73,9 +69,9 @@
},
"scripts-descriptions": {
"dev:build": "DEV: run dev:fix-style and dev:tests, run before pull request",
- "dev:check-style": "DEV: search for code style errors using php-cs-fixer and phpcs",
+ "dev:check-style": "DEV: search for code style errors using composer-normalize, php-cs-fixer and phpcs",
"dev:coverage": "DEV: run phpunit with xdebug and storage coverage in build/coverage/html/",
- "dev:fix-style": "DEV: fix code style errors using php-cs-fixer and phpcbf",
+ "dev:fix-style": "DEV: fix code style errors using composer-normalize, php-cs-fixer and phpcbf",
"dev:test": "DEV: run dev:check-style, phpunit and phpstan"
}
}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 24f32a7..e2d7e90 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -9,6 +9,36 @@ aunque sí su incorporación en la rama principal de trabajo. Generalmente, se t
## Listado de cambios
+### Versión 0.3.0 2026-03-18
+
+Se actualizaron las dependencias del proyecto:
+
+- `Eclipxe/CfdiUtils` a `^3.0.2`.
+- `Eclipxe/XmlResourceRetriever` a `^2.0.3`.
+- `Eclipxe/XmlSchemaValidator` a `^3.0.5`.
+
+Se validó la compatibilidad con PHP 8.4 y PHP 8.5.
+Se elimina la compatibilidad con PHP 7.4 y PHP 8.0.
+
+Se actualizó el año de licencia.
+
+Se moderniza el código a PHP 8.1 con la ayuda de `rector/rector`.
+Este cambio genera múltiples cambios en la definición de propiedades
+y la definición de propiedades de tipo solo lectura.
+
+Cambios en el entorno de desarrollo:
+
+- Se migra de Scrutinizer-CI a SonarCloud.
+- Se actualizan los archivos de configuración de las herramientas de estándar de código.
+- Se agrega `composer-normalize` a las herramientas de desarrollo.
+- Se actualiza el archivo de integración continua de GitHub:
+ - Se agrega PHP 8.4 y PHP 8.5 a la matriz de pruebas.
+ - Se elimina PHP 7.4 y PHP 8.0 de la matriz de pruebas.
+ - Se actualizan las versiones de las acciones de GitHub.
+ - Se ejecutan los trabajos en PHP 8.5.
+ - Se agrega el trabajo `composer-normalize`.
+- Se actualizan las herramientas de desarrollo.
+
### Versión 0.2.3 2023-12-18
Algunas clases de validadores no estaban marcadas como *finales*.
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index e7a9c2a..f7ec9c1 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -18,7 +18,6 @@
-
diff --git a/src/AbstractCreator.php b/src/AbstractCreator.php
index 97b8c2a..94c1499 100644
--- a/src/AbstractCreator.php
+++ b/src/AbstractCreator.php
@@ -13,13 +13,14 @@
use CfdiUtils\XmlResolver\XmlResolverPropertyTrait;
use PhpCfdi\CeUtils\Validate\MultiValidator;
use PhpCfdi\Credentials\Credential;
+use RuntimeException;
abstract class AbstractCreator
{
use XsltBuilderPropertyTrait;
use XmlResolverPropertyTrait;
- public function __construct(?XmlResolver $xmlResolver = null)
+ public function __construct(XmlResolver|null $xmlResolver = null)
{
$this->setXsltBuilder(new DOMBuilder());
$this->setXmlResolver($xmlResolver ?? new XmlResolver());
@@ -60,7 +61,7 @@ public function buildCadenaDeOrigen(): string
$location = $this->getXmlResolver()->resolve($this->getXsltLocation(), 'XSLT');
$sourceString = $this->getXsltBuilder()->build($this->asXml(), $location);
if ('' === trim($sourceString, '|')) {
- throw new \RuntimeException('Unable to create the source string');
+ throw new RuntimeException('Unable to create the source string');
}
return $sourceString;
}
diff --git a/src/AuxiliarCuentasCreator13.php b/src/AuxiliarCuentasCreator13.php
index c886787..5e44416 100644
--- a/src/AuxiliarCuentasCreator13.php
+++ b/src/AuxiliarCuentasCreator13.php
@@ -12,12 +12,10 @@
class AuxiliarCuentasCreator13 extends AbstractCreator
{
- private AuxiliarCtas $auxiliarCuentas;
+ private readonly AuxiliarCtas $auxiliarCuentas;
- /**
- * @param array $attributes
- */
- public function __construct(array $attributes)
+ /** @param array $attributes */
+ public function __construct(array $attributes = [])
{
parent::__construct();
$this->auxiliarCuentas = new AuxiliarCtas($attributes);
diff --git a/src/AuxiliarFoliosCreator13.php b/src/AuxiliarFoliosCreator13.php
index ed0192a..3dd44db 100644
--- a/src/AuxiliarFoliosCreator13.php
+++ b/src/AuxiliarFoliosCreator13.php
@@ -12,12 +12,10 @@
class AuxiliarFoliosCreator13 extends AbstractCreator
{
- private RepAuxFol $repAuxFol;
+ private readonly RepAuxFol $repAuxFol;
- /**
- * @param array $attributes
- */
- public function __construct(array $attributes)
+ /** @param array $attributes */
+ public function __construct(array $attributes = [])
{
parent::__construct();
$this->repAuxFol = new RepAuxFol($attributes);
diff --git a/src/BalanzaCreator13.php b/src/BalanzaCreator13.php
index a34f200..ca195de 100644
--- a/src/BalanzaCreator13.php
+++ b/src/BalanzaCreator13.php
@@ -12,12 +12,10 @@
class BalanzaCreator13 extends AbstractCreator
{
- private Balanza $balanza;
+ private readonly Balanza $balanza;
- /**
- * @param array $attributes
- */
- public function __construct(array $attributes)
+ /** @param array $attributes */
+ public function __construct(array $attributes = [])
{
parent::__construct();
$this->balanza = new Balanza($attributes);
diff --git a/src/CatalogoCreator13.php b/src/CatalogoCreator13.php
index 396fb75..cce0b43 100644
--- a/src/CatalogoCreator13.php
+++ b/src/CatalogoCreator13.php
@@ -12,12 +12,10 @@
class CatalogoCreator13 extends AbstractCreator
{
- private Catalogo $catalogo;
+ private readonly Catalogo $catalogo;
- /**
- * @param array $attributes
- */
- public function __construct(array $attributes)
+ /** @param array $attributes */
+ public function __construct(array $attributes = [])
{
parent::__construct();
$this->catalogo = new Catalogo($attributes);
diff --git a/src/Elements/AuxiliarCuentas13/AuxiliarCtas.php b/src/Elements/AuxiliarCuentas13/AuxiliarCtas.php
index 80440cf..8549c9c 100644
--- a/src/Elements/AuxiliarCuentas13/AuxiliarCtas.php
+++ b/src/Elements/AuxiliarCuentas13/AuxiliarCtas.php
@@ -14,6 +14,7 @@ public function getElementName(): string
return AuxiliarCuentas13Definition::ELEMENT_NAME;
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
public function getFixedAttributes(): array
{
return [
diff --git a/src/Elements/AuxiliarFolios13/DetAuxFol.php b/src/Elements/AuxiliarFolios13/DetAuxFol.php
index 348be79..e7a305e 100644
--- a/src/Elements/AuxiliarFolios13/DetAuxFol.php
+++ b/src/Elements/AuxiliarFolios13/DetAuxFol.php
@@ -13,7 +13,10 @@ public function getElementName(): string
return 'RepAux:DetAuxFol';
}
- /** @return string[] */
+ /**
+ * @noinspection PhpMissingParentCallCommonInspection
+ * @return string[]
+ */
public function getChildrenOrder(): array
{
return [
diff --git a/src/Elements/AuxiliarFolios13/RepAuxFol.php b/src/Elements/AuxiliarFolios13/RepAuxFol.php
index 62bfba5..40fecb9 100644
--- a/src/Elements/AuxiliarFolios13/RepAuxFol.php
+++ b/src/Elements/AuxiliarFolios13/RepAuxFol.php
@@ -14,6 +14,7 @@ public function getElementName(): string
return AuxiliarFolios13Definition::ELEMENT_NAME;
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
public function getFixedAttributes(): array
{
return [
diff --git a/src/Elements/Balanza13/Balanza.php b/src/Elements/Balanza13/Balanza.php
index e3d04ee..261f06f 100644
--- a/src/Elements/Balanza13/Balanza.php
+++ b/src/Elements/Balanza13/Balanza.php
@@ -14,6 +14,7 @@ public function getElementName(): string
return Balanza13Definition::ELEMENT_NAME;
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
public function getFixedAttributes(): array
{
return [
diff --git a/src/Elements/Catalogo13/Catalogo.php b/src/Elements/Catalogo13/Catalogo.php
index 089f5f4..a8dc340 100644
--- a/src/Elements/Catalogo13/Catalogo.php
+++ b/src/Elements/Catalogo13/Catalogo.php
@@ -14,6 +14,7 @@ public function getElementName(): string
return Catalogo13Definition::ELEMENT_NAME;
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
public function getFixedAttributes(): array
{
return [
diff --git a/src/Elements/Polizas13/Polizas.php b/src/Elements/Polizas13/Polizas.php
index ac035ce..b7ba5d3 100644
--- a/src/Elements/Polizas13/Polizas.php
+++ b/src/Elements/Polizas13/Polizas.php
@@ -14,6 +14,7 @@ public function getElementName(): string
return Polizas13Definition::ELEMENT_NAME;
}
+ /** @noinspection PhpMissingParentCallCommonInspection */
public function getFixedAttributes(): array
{
return [
diff --git a/src/Internal/Amount.php b/src/Internal/Amount.php
index 79f25b0..d05b705 100644
--- a/src/Internal/Amount.php
+++ b/src/Internal/Amount.php
@@ -4,12 +4,14 @@
namespace PhpCfdi\CeUtils\Internal;
+use Stringable;
+
/**
* Clase para hacer operaciones con tipos t_Importe
*
* @internal
*/
-final class Amount
+final class Amount implements Stringable
{
public const MIN_VALUE = '-9999999999999999999999.99';
@@ -17,7 +19,7 @@ final class Amount
private const SCALE = 2;
- private string $value;
+ private readonly string $value;
public function __construct(string $value)
{
diff --git a/src/Internal/PathPropertyTrait.php b/src/Internal/PathPropertyTrait.php
index a7e5026..1af96b5 100644
--- a/src/Internal/PathPropertyTrait.php
+++ b/src/Internal/PathPropertyTrait.php
@@ -6,10 +6,10 @@
trait PathPropertyTrait
{
- /** @var string[] */
+ /** @var list */
private array $path;
- /** @return string[] */
+ /** @return list */
public function getPath(): array
{
return $this->path;
diff --git a/src/PolizasCreator13.php b/src/PolizasCreator13.php
index 19b020d..81c7da6 100644
--- a/src/PolizasCreator13.php
+++ b/src/PolizasCreator13.php
@@ -12,12 +12,10 @@
class PolizasCreator13 extends AbstractCreator
{
- private Polizas $polizas;
+ private readonly Polizas $polizas;
- /**
- * @param array $attributes
- */
- public function __construct(array $attributes)
+ /** @param array $attributes */
+ public function __construct(array $attributes = [])
{
parent::__construct();
$this->polizas = new Polizas($attributes);
diff --git a/src/Validate/Balanza13/CuentasSaldoFinal.php b/src/Validate/Balanza13/CuentasSaldoFinal.php
index 6b8e56d..e500263 100644
--- a/src/Validate/Balanza13/CuentasSaldoFinal.php
+++ b/src/Validate/Balanza13/CuentasSaldoFinal.php
@@ -63,7 +63,7 @@ public function validateNodeCtas(int $index, NodeInterface $node, Asserts $asser
$node['Debe'],
$node['Haber'],
$node['SaldoFin'],
- (string) $equals,
+ $equals ? 'Verdadero' : 'Falso',
),
);
return $equals;
diff --git a/src/Validate/Common/BaseCertificate.php b/src/Validate/Common/BaseCertificate.php
index 44caf5f..1f51166 100644
--- a/src/Validate/Common/BaseCertificate.php
+++ b/src/Validate/Common/BaseCertificate.php
@@ -29,12 +29,9 @@ abstract class BaseCertificate implements
use XmlResolverPropertyTrait;
use XsltBuilderPropertyTrait;
- private string $xsltLocation;
-
- public function __construct(string $assertPrefix, string $xsltLocation)
+ public function __construct(string $assertPrefix, private readonly string $xsltLocation)
{
$this->assertPrefix = $assertPrefix;
- $this->xsltLocation = $xsltLocation;
}
public function getXsltLocation(): string
diff --git a/src/Validate/Common/BaseCurrency.php b/src/Validate/Common/BaseCurrency.php
index a2495be..f9f1ccc 100644
--- a/src/Validate/Common/BaseCurrency.php
+++ b/src/Validate/Common/BaseCurrency.php
@@ -21,7 +21,7 @@ abstract class BaseCurrency implements ValidatorInterface
public function __construct(string $assertPrefix, string ...$path)
{
$this->assertPrefix = $assertPrefix;
- $this->path = $path;
+ $this->path = array_values($path);
}
public function validate(NodeInterface $root, Asserts $asserts): void
diff --git a/src/Validate/Common/BaseDifferentRfc.php b/src/Validate/Common/BaseDifferentRfc.php
index 06243fc..7c714c8 100644
--- a/src/Validate/Common/BaseDifferentRfc.php
+++ b/src/Validate/Common/BaseDifferentRfc.php
@@ -21,7 +21,7 @@ abstract class BaseDifferentRfc implements ValidatorInterface
public function __construct(string $assertPrefix, string ...$path)
{
$this->assertPrefix = $assertPrefix;
- $this->path = $path;
+ $this->path = array_values($path);
}
public function validate(NodeInterface $root, Asserts $asserts): void
@@ -47,7 +47,7 @@ private function validateNode(
NodeInterface $node,
Asserts $asserts,
string $location,
- int $count
+ int $count,
): void {
$rfc = $node['RFC'];
$asserts->put(
diff --git a/src/Validate/Common/BaseDocumentDefinition.php b/src/Validate/Common/BaseDocumentDefinition.php
index e578dbb..3a6d2b2 100644
--- a/src/Validate/Common/BaseDocumentDefinition.php
+++ b/src/Validate/Common/BaseDocumentDefinition.php
@@ -11,17 +11,11 @@
abstract class BaseDocumentDefinition implements ValidatorInterface
{
- private string $assertPrefix;
-
- private string $rootElementName;
-
- private string $namespace;
-
- public function __construct(string $assertPrefix, string $rootElementName, string $namespace)
- {
- $this->assertPrefix = $assertPrefix;
- $this->rootElementName = $rootElementName;
- $this->namespace = $namespace;
+ public function __construct(
+ private readonly string $assertPrefix,
+ private readonly string $rootElementName,
+ private readonly string $namespace,
+ ) {
}
public function getAssertName(string $suffix): string
diff --git a/src/Validate/Common/BaseDocumentFollowSchemas.php b/src/Validate/Common/BaseDocumentFollowSchemas.php
index 177ed0f..4d61459 100644
--- a/src/Validate/Common/BaseDocumentFollowSchemas.php
+++ b/src/Validate/Common/BaseDocumentFollowSchemas.php
@@ -13,12 +13,12 @@
use CfdiUtils\Validate\Traits\XmlStringPropertyTrait;
use CfdiUtils\XmlResolver\XmlResolver;
use CfdiUtils\XmlResolver\XmlResolverPropertyTrait;
+use Eclipxe\XmlResourceRetriever\XsdRetriever;
use Eclipxe\XmlSchemaValidator\Exceptions\ValidationFailException;
use Eclipxe\XmlSchemaValidator\Schema;
use Eclipxe\XmlSchemaValidator\Schemas;
use Eclipxe\XmlSchemaValidator\SchemaValidator;
use PhpCfdi\CeUtils\Validate\ValidatorInterface;
-use XmlResourceRetriever\XsdRetriever;
abstract class BaseDocumentFollowSchemas implements
ValidatorInterface,
@@ -28,17 +28,11 @@ abstract class BaseDocumentFollowSchemas implements
use XmlStringPropertyTrait;
use XmlResolverPropertyTrait;
- private string $assertPrefix;
-
- private string $namespace;
-
- private string $xsdLocation;
-
- public function __construct(string $assertPrefix, string $namespace, string $xsdLocation)
- {
- $this->assertPrefix = $assertPrefix;
- $this->namespace = $namespace;
- $this->xsdLocation = $xsdLocation;
+ public function __construct(
+ private readonly string $assertPrefix,
+ private readonly string $namespace,
+ private readonly string $xsdLocation,
+ ) {
}
public function getAssertName(string $suffix): string
@@ -106,11 +100,7 @@ public function validateLocation(Schemas $schemas, Assert $locationAssert): bool
return $locationMatches;
}
- /**
- * @param SchemaValidator $schemaValidator
- * @param Schemas $schemas
- * @return string[] XSD detected errors
- */
+ /** @return string[] XSD detected errors */
public function validateXsdSchemas(SchemaValidator $schemaValidator, Schemas $schemas): array
{
$resolver = $this->xmlResolver;
diff --git a/src/Validate/Common/BaseExchangeRate.php b/src/Validate/Common/BaseExchangeRate.php
index 6720c75..7a07531 100644
--- a/src/Validate/Common/BaseExchangeRate.php
+++ b/src/Validate/Common/BaseExchangeRate.php
@@ -21,7 +21,7 @@ abstract class BaseExchangeRate implements ValidatorInterface
public function __construct(string $assertPrefix, string ...$path)
{
$this->assertPrefix = $assertPrefix;
- $this->path = $path;
+ $this->path = array_values($path);
}
public function validate(NodeInterface $root, Asserts $asserts): void
diff --git a/src/Validate/Common/BaseUniquePolizaNumber.php b/src/Validate/Common/BaseUniquePolizaNumber.php
index 647995c..24e268e 100644
--- a/src/Validate/Common/BaseUniquePolizaNumber.php
+++ b/src/Validate/Common/BaseUniquePolizaNumber.php
@@ -16,12 +16,11 @@ abstract class BaseUniquePolizaNumber implements ValidatorInterface
{
use AssertPrefixPropertyTrait;
- private string $childName;
-
- public function __construct(string $assertPrefix, string $childName)
- {
+ public function __construct(
+ string $assertPrefix,
+ private readonly string $childName,
+ ) {
$this->assertPrefix = $assertPrefix;
- $this->childName = $childName;
}
public function getChildName(): string
diff --git a/src/Validate/MultiValidator.php b/src/Validate/MultiValidator.php
index b7569c8..507bed1 100644
--- a/src/Validate/MultiValidator.php
+++ b/src/Validate/MultiValidator.php
@@ -14,16 +14,14 @@ abstract class MultiValidator
/** @var array */
protected array $validatorClasses = [];
- private Hydrater $hydrater;
+ private readonly Hydrater $hydrater;
public function __construct()
{
$this->hydrater = new Hydrater();
}
- /**
- * @return array
- */
+ /** @return array */
public function getValidatorClasses(): array
{
return $this->validatorClasses;
@@ -46,9 +44,7 @@ public function validate(NodeInterface $root): Asserts
return $asserts;
}
- /**
- * @return Generator
- */
+ /** @return Generator */
protected function createValidators(): Generator
{
foreach ($this->getValidatorClasses() as $validatorClass) {
@@ -57,10 +53,9 @@ protected function createValidators(): Generator
}
/**
- * Creates an hydrated validator
+ * Creates a hydrated validator
*
* @param class-string $validatorClass
- * @return ValidatorInterface
*/
protected function createValidator(string $validatorClass): ValidatorInterface
{
diff --git a/src/Validate/ValidatorInterface.php b/src/Validate/ValidatorInterface.php
index 7f98335..2e2abdd 100644
--- a/src/Validate/ValidatorInterface.php
+++ b/src/Validate/ValidatorInterface.php
@@ -19,9 +19,6 @@ public static function create();
/**
* Run validations populating the asserts collection
- *
- * @param NodeInterface $root
- * @param Asserts $asserts
*/
public function validate(NodeInterface $root, Asserts $asserts): void;
}
diff --git a/tests/Unit/Validate/Common/BaseCurrencyTest.php b/tests/Unit/Validate/Common/BaseCurrencyTest.php
index 5546d77..cbe4724 100644
--- a/tests/Unit/Validate/Common/BaseCurrencyTest.php
+++ b/tests/Unit/Validate/Common/BaseCurrencyTest.php
@@ -19,7 +19,7 @@ protected function setUp(): void
parent::setUp();
$this->validator = new class ('FOO', ...['a:foo', 'a:bar']) extends BaseCurrency {
- public static function create(): void
+ public static function create(): never
{
throw new LogicException("Static method won't be tested");
}
diff --git a/tests/Unit/Validate/Common/BaseDifferentRfcTest.php b/tests/Unit/Validate/Common/BaseDifferentRfcTest.php
index cf326e1..53acf35 100644
--- a/tests/Unit/Validate/Common/BaseDifferentRfcTest.php
+++ b/tests/Unit/Validate/Common/BaseDifferentRfcTest.php
@@ -19,7 +19,7 @@ protected function setUp(): void
parent::setUp();
$this->validator = new class ('FOO', ...['a:foo', 'a:bar']) extends BaseDifferentRfc {
- public static function create(): void
+ public static function create(): never
{
throw new LogicException("Static method won't be tested");
}
diff --git a/tests/Unit/Validate/Common/BaseExchangeRateTest.php b/tests/Unit/Validate/Common/BaseExchangeRateTest.php
index a982f48..ff58af7 100644
--- a/tests/Unit/Validate/Common/BaseExchangeRateTest.php
+++ b/tests/Unit/Validate/Common/BaseExchangeRateTest.php
@@ -19,7 +19,7 @@ protected function setUp(): void
parent::setUp();
$this->validator = new class ('FOO', ...['a:foo', 'a:bar']) extends BaseExchangeRate {
- public static function create(): void
+ public static function create(): never
{
throw new LogicException('Static method wont be tested');
}
diff --git a/tests/Unit/Validate/Common/BaseNumOrdenTest.php b/tests/Unit/Validate/Common/BaseNumOrdenTest.php
index 14a2d38..af5e240 100644
--- a/tests/Unit/Validate/Common/BaseNumOrdenTest.php
+++ b/tests/Unit/Validate/Common/BaseNumOrdenTest.php
@@ -18,7 +18,7 @@ protected function setUp(): void
{
parent::setUp();
$this->validator = new class ('PREFIX') extends BaseNumOrden {
- public static function create(): void
+ public static function create(): never
{
throw new LogicException("Static method won't be tested");
}
diff --git a/tests/Unit/Validate/Common/BaseNumTramiteTest.php b/tests/Unit/Validate/Common/BaseNumTramiteTest.php
index 3237189..22d7cb4 100644
--- a/tests/Unit/Validate/Common/BaseNumTramiteTest.php
+++ b/tests/Unit/Validate/Common/BaseNumTramiteTest.php
@@ -18,7 +18,7 @@ protected function setUp(): void
{
parent::setUp();
$this->validator = new class ('PREFIX') extends BaseNumTramite {
- public static function create(): void
+ public static function create(): never
{
throw new LogicException("Static method won't be tested");
}