From da6a45ca38eb1a4c1335fc359e30aaf53e0810e0 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:28:46 -0600 Subject: [PATCH 01/15] Rename provate property for better reading --- src/DiscoverExtractor.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/DiscoverExtractor.php b/src/DiscoverExtractor.php index 675fc41..88a3610 100644 --- a/src/DiscoverExtractor.php +++ b/src/DiscoverExtractor.php @@ -15,14 +15,14 @@ class DiscoverExtractor implements ExpressionExtractorInterface { /** @var ExpressionExtractorInterface[] */ - private $expressions; + private $extractors; - public function __construct(ExpressionExtractorInterface ...$expressions) + public function __construct(ExpressionExtractorInterface ...$extractors) { - if ([] === $expressions) { - $expressions = $this->defaultExtractors(); + if ([] === $extractors) { + $extractors = $this->defaultExtractors(); } - $this->expressions = $expressions; + $this->extractors = $extractors; } /** @return ExpressionExtractorInterface[] */ @@ -40,14 +40,14 @@ public function defaultExtractors(): array /** @return ExpressionExtractorInterface[] */ public function currentExpressionExtractors(): array { - return $this->expressions; + return $this->extractors; } protected function findByUniqueName(string $uniqueName): ?ExpressionExtractorInterface { - foreach ($this->expressions as $expression) { - if ($uniqueName === $expression->uniqueName()) { - return $expression; + foreach ($this->extractors as $extractor) { + if ($uniqueName === $extractor->uniqueName()) { + return $extractor; } } return null; @@ -55,9 +55,9 @@ protected function findByUniqueName(string $uniqueName): ?ExpressionExtractorInt protected function findMatch(DOMDocument $document): ?ExpressionExtractorInterface { - foreach ($this->expressions as $expression) { - if ($expression->matches($document)) { - return $expression; + foreach ($this->extractors as $extractor) { + if ($extractor->matches($document)) { + return $extractor; } } return null; From 53c9b3b2aea7e2d4afbb042c5f7bdd05ae6a61f5 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:29:24 -0600 Subject: [PATCH 02/15] [SonarCloud] Fix exclude files --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 321e608..9a3c389 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -4,7 +4,7 @@ sonar.sourceEncoding=UTF-8 sonar.language=php sonar.sources=src sonar.tests=tests -sonar.exclusions=vendor/,tools/,build/,tests/_files/ +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 From b2a6ad61e4eae61f14ab9907d8ca2a7a52448dbf Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:29:46 -0600 Subject: [PATCH 03/15] Fix project anchor --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbd9435..05b47e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contribuciones -Las contribuciones son bienvenidas. Aceptamos *Pull Requests* en [el repositorio GitHub][homepage]. +Las contribuciones son bienvenidas. Aceptamos *Pull Requests* en [el repositorio GitHub][project]. Este proyecto se apega al siguiente [Código de Conducta][coc]. Al participar en este proyecto y en su comunidad, deberás seguir este código. From 2401e57f1aac11b8e4a48c6cc41f7b61ed3d54a9 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:31:06 -0600 Subject: [PATCH 04/15] [PHPUnit] Remove verbose argument --- .github/workflows/build.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- composer.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7be1956..108f86e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,7 +119,7 @@ jobs: - name: Install project dependencies run: composer upgrade --no-interaction --no-progress --prefer-dist - name: Tests - run: vendor/bin/phpunit --testdox --verbose + run: vendor/bin/phpunit --testdox infection: name: Mutation testing analysis diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 719ddd2..3595cfe 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -39,7 +39,7 @@ jobs: - name: Install project dependencies run: composer upgrade --no-interaction --no-progress --prefer-dist - name: Create code coverage - run: vendor/bin/phpunit --testdox --verbose --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml + 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: diff --git a/composer.json b/composer.json index b10dd19..4f58d66 100644 --- a/composer.json +++ b/composer.json @@ -53,13 +53,13 @@ ], "dev:test": [ "@dev:check-style", - "@php vendor/bin/phpunit --testdox --verbose --stop-on-failure", + "@php vendor/bin/phpunit --testdox --stop-on-failure", "@php tools/phpstan analyse --no-progress", "@php tools/psalm --no-progress", "@php tools/infection --no-progress --no-interaction --show-mutations" ], "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/" ] }, "scripts-descriptions": { From ae6d3dab89c4d50e8f2866a0d78928745d93545a Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:31:20 -0600 Subject: [PATCH 05/15] Fix build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bc57c7..5a7351d 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor [badge-discord]: https://img.shields.io/discord/459860554090283019?logo=discord [badge-release]: https://img.shields.io/github/release/phpcfdi/cfdi-expresiones.svg??logo=git [badge-license]: https://img.shields.io/github/license/phpcfdi/cfdi-expresiones.svg?logo=open-source-initiative -[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/cfdi-expresiones/build/main?logo=github-actions +[badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/cfdi-expresiones/build.yml?branch=main&logo=github-actions [badge-reliability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_cfdi-expresiones&metric=reliability_rating [badge-maintainability]: https://sonarcloud.io/api/project_badges/measure?project=phpcfdi_cfdi-expresiones&metric=sqale_rating [badge-coverage]: https://img.shields.io/sonar/coverage/phpcfdi_cfdi-expresiones/main?logo=sonarcloud&server=https%3A%2F%2Fsonarcloud.io From a6f2080ab88af1ab7d822437003f03c8cf35232a Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:31:35 -0600 Subject: [PATCH 06/15] Update license year. Happy 2024! --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index bcf9a90..79ffed7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2019 - 2022 PhpCfdi https://www.phpcfdi.com +Copyright (c) 2019 - 2024 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 35cf0093e936629583e614b6bd5519b8c8eba759 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:34:56 -0600 Subject: [PATCH 07/15] [PHPUnit] Remove verbose argument --- .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 108f86e..c9c6455 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,6 +145,6 @@ jobs: - name: Install project dependencies run: composer upgrade --no-interaction --no-progress --prefer-dist - name: Create code coverage - run: vendor/bin/phpunit --testdox --verbose --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml + run: vendor/bin/phpunit --testdox --coverage-xml=build/coverage --coverage-clover=build/coverage/clover.xml --log-junit=build/coverage/junit.xml - name: infection run: infection --skip-initial-tests --coverage=build/coverage --no-progress --no-interaction --logger-github From 7b2913070f370cacb928565ac07f158b33fd57c6 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:35:54 -0600 Subject: [PATCH 08/15] Replace GH workflow directive ::set-output with $GITHUB_OUTPUT --- .github/workflows/build.yml | 8 ++++---- .github/workflows/sonarcloud.yml | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9c6455..2cb6e8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: tools: composer:v2, phpstan, cs2pr - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: @@ -78,7 +78,7 @@ jobs: tools: psalm, cs2pr - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: @@ -109,7 +109,7 @@ jobs: fail-fast: true - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: @@ -135,7 +135,7 @@ jobs: tools: composer:v2, infection - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 3595cfe..8064fbd 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -29,7 +29,7 @@ jobs: sudo apt install poppler-utils - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: @@ -57,15 +57,15 @@ jobs: id: check-secrets run: | if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then - echo "::set-output name=github::yes" + echo "github=yes" >> $GITHUB_OUTPUT else - echo "::set-output name=github::no" + echo "github=no" >> $GITHUB_OUTPUT echo "::warning ::GITHUB_TOKEN non set" fi if [ -n "${{ secrets.SONAR_TOKEN }}" ]; then - echo "::set-output name=sonar::yes" + echo "sonar=yes" >> $GITHUB_OUTPUT else - echo "::set-output name=sonar::no" + echo "sonar=no" >> $GITHUB_OUTPUT echo "::warning ::SONAR_TOKEN non set" fi @@ -87,7 +87,7 @@ jobs: tools: composer:v2 - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies uses: actions/cache@v3 with: From be8943811069b3b79246005c4b822f318f745618 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:36:44 -0600 Subject: [PATCH 09/15] Allow to manually dispatch workflow --- .github/workflows/build.yml | 1 + .github/workflows/sonarcloud.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2cb6e8f..447e917 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,6 @@ name: build on: + workflow_dispatch: pull_request: branches: [ main ] push: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 8064fbd..063b8b2 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,5 +1,6 @@ name: sonarcloud on: + workflow_dispatch: push: branches: [ "main" ] From e1f33f9f680708536cc77123776038c6d64d585f Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:37:33 -0600 Subject: [PATCH 10/15] Improve code style --- .github/workflows/build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 447e917..58ab810 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,12 +2,15 @@ name: build on: workflow_dispatch: pull_request: - branches: [ main ] + branches: [ "main" ] push: - branches: [ main ] + branches: [ "main" ] schedule: - cron: '0 16 * * 0' # sunday 16:00 +# Actions +# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action + jobs: phpcs: name: Code Style (phpcs) @@ -101,7 +104,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Setup PHP - uses: shivammathur/setup-php@v2 # see https://github.com/marketplace/actions/setup-php-action + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} coverage: none From 54e547e5362f3864c5220821ac5e821deff39ad6 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:38:06 -0600 Subject: [PATCH 11/15] Add PHP 8.2 and PHP 8.3 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 58ab810..61d45ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,7 +99,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - php-versions: ['7.3', '7.4', '8.0', '8.1'] + php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout uses: actions/checkout@v3 From 8e5654a1d5eef5bec190b7cd27287ced0046a214 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:38:39 -0600 Subject: [PATCH 12/15] Run jobs using PHP 8.3 --- .github/workflows/build.yml | 10 +++++----- .github/workflows/sonarcloud.yml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61d45ca..79898c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: phpcs, cs2pr - name: phpcs @@ -36,7 +36,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: php-cs-fixer, cs2pr - name: php-cs-fixer @@ -51,7 +51,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: composer:v2, phpstan, cs2pr - name: Get composer cache directory @@ -77,7 +77,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: psalm, cs2pr - name: Get composer cache directory @@ -134,7 +134,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: xdebug tools: composer:v2, infection - name: Get composer cache directory diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 063b8b2..07b88f3 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -19,7 +19,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: xdebug tools: composer:v2 env: @@ -83,7 +83,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: composer:v2 - name: Get composer cache directory From c8c9cfc28d9493b5f25d38308e041196120ca6e9 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:40:58 -0600 Subject: [PATCH 13/15] Update php-cs-fixer configuration file --- .php-cs-fixer.dist.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 92c4142..32ed11d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -22,12 +22,13 @@ 'whitespace_after_comma_in_array' => true, 'no_empty_statement' => true, 'no_extra_blank_lines' => true, - 'function_typehint_space' => true, + 'type_declaration_spaces' => true, + 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays']], 'no_blank_lines_after_phpdoc' => true, 'object_operator_without_whitespace' => true, 'binary_operator_spaces' => true, 'phpdoc_scalar' => true, - 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_comma_in_singleline' => true, 'single_quote' => true, 'no_singleline_whitespace_before_semicolons' => true, 'no_unused_imports' => true, @@ -40,11 +41,12 @@ 'self_accessor' => true, // contrib 'not_operator_with_successor_space' => true, + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], // @PSR12 sort_algorithm: none ]) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__) ->append([__FILE__]) - ->exclude(['vendor', 'tools', 'build']), + ->exclude(['vendor', 'tools', 'build']) ) ; From 8ece7cff8a2b638a184361d2a857e840fc30e843 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 17 Jan 2024 23:41:08 -0600 Subject: [PATCH 14/15] Update development tools --- .phive/phars.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index a7e8701..776b292 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,9 +1,9 @@ - - - - - - + + + + + + From e33b728cf3a88c15dfa4b32a13c90af292e89b6d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Thu, 18 Jan 2024 00:00:33 -0600 Subject: [PATCH 15/15] Document unreleased changes --- docs/CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 77f2931..745704f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,23 @@ Usamos [Versionado Semántico 2.0.0](SEMVER.md) por lo que puedes usar esta libr Pueden aparecer cambios no liberados que se integran a la rama principal, pero no ameritan una nueva liberación de versión, aunque sí su incorporación en la rama principal de trabajo, generalmente se tratan de cambios en el desarrollo. +### Mantenimiento 2024-10-17 + +- Se actualiza el año en el archivo de licencia. +- Renombrar la propiedad privada `DiscoverExtractor::expressions` a `DiscoverExtractor::extractors` para mejorar la lectura. +- Se corrige el ancla del proyecto en el archivo `CONTRIBUTING.md`. +- Se corrige la insignia de construcción del proyecto. +- Se vuelve a registrar el proyecto en [SonarCloud](https://sonarcloud.io/project/overview?id=phpcfdi_cfdi-expresiones). +- Se excluyen los archivos de `test/_files` correctamente en SonarCloud. +- Se remueve el argumento `--verbose` para PHPUnit. +- En los flujos de trabajo de integración continua: + - Se sustituye la directiva `::set-output` con `$GITHUB_OUTPUT`. + - Se permite que los flujos de trabajo se ejecuten manualmente. + - Se agrega PHP 8.2 y PHP 8.3 a la matriz de pruebas. + - Se ejecutan los trabajos en PHP 8.3. +- Se actualiza el archivo de configuración de `php-cs-fixer`. +- Se actualizan las herramientas de desarrollo. + ### Sonarcloud 2022-06-27 - Se agrega la integración con [SonarCloud](https://sonarcloud.io/project/overview?id=phpcfdi_cfdi-expresiones).