Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mantenimiento 2024-01-17 #19

Merged
merged 15 commits into from
Jan 18, 2024
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
34 changes: 19 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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)
Expand All @@ -17,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
Expand All @@ -32,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
Expand All @@ -47,12 +51,12 @@ 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
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:
Expand All @@ -73,12 +77,12 @@ 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
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:
Expand All @@ -95,12 +99,12 @@ 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
- 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
Expand All @@ -109,7 +113,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:
Expand All @@ -119,7 +123,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
Expand All @@ -130,12 +134,12 @@ 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
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:
Expand All @@ -145,6 +149,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
19 changes: 10 additions & 9 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: sonarcloud
on:
workflow_dispatch:
push:
branches: [ "main" ]

Expand All @@ -18,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:
Expand All @@ -29,7 +30,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:
Expand All @@ -39,7 +40,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:
Expand All @@ -57,15 +58,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

Expand All @@ -82,12 +83,12 @@ 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
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:
Expand Down
12 changes: 6 additions & 6 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.8.0" installed="3.8.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.7.0" installed="3.7.0" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.7.0" installed="3.7.0" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.7.14" installed="1.7.14" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="^4.23.0" installed="4.23.0" location="./tools/psalm" copy="false"/>
<phar name="infection" version="^0.26.11" installed="0.26.11" location="./tools/infection" copy="false"/>
<phar name="php-cs-fixer" version="^3.47.1" installed="3.47.1" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpcs" version="^3.8.1" installed="3.8.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.8.1" installed="3.8.1" location="./tools/phpcbf" copy="false"/>
<phar name="phpstan" version="^1.10.56" installed="1.10.56" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="^4.30.0" installed="4.30.0" location="./tools/psalm" copy="false"/>
<phar name="infection" version="^0.26.21" installed="0.26.21" location="./tools/infection" copy="false"/>
</phive>
8 changes: 5 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'])
)
;
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
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 - 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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 17 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 12 additions & 12 deletions src/DiscoverExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] */
Expand All @@ -40,30 +40,30 @@
/** @return ExpressionExtractorInterface[] */
public function currentExpressionExtractors(): array
{
return $this->expressions;
return $this->extractors;
}

protected function findByUniqueName(string $uniqueName): ?ExpressionExtractorInterface

Check warning on line 46 in src/DiscoverExtractor.php

View workflow job for this annotation

GitHub Actions / Mutation testing analysis

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ { return $this->extractors; } - protected function findByUniqueName(string $uniqueName) : ?ExpressionExtractorInterface + private function findByUniqueName(string $uniqueName) : ?ExpressionExtractorInterface { foreach ($this->extractors as $extractor) { if ($uniqueName === $extractor->uniqueName()) {
{
foreach ($this->expressions as $expression) {
if ($uniqueName === $expression->uniqueName()) {
return $expression;
foreach ($this->extractors as $extractor) {
if ($uniqueName === $extractor->uniqueName()) {
return $extractor;
}
}
return null;
}

protected function findMatch(DOMDocument $document): ?ExpressionExtractorInterface

Check warning on line 56 in src/DiscoverExtractor.php

View workflow job for this annotation

GitHub Actions / Mutation testing analysis

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return null; } - protected function findMatch(DOMDocument $document) : ?ExpressionExtractorInterface + private function findMatch(DOMDocument $document) : ?ExpressionExtractorInterface { foreach ($this->extractors as $extractor) { if ($extractor->matches($document)) {
{
foreach ($this->expressions as $expression) {
if ($expression->matches($document)) {
return $expression;
foreach ($this->extractors as $extractor) {
if ($extractor->matches($document)) {
return $extractor;
}
}
return null;
}

protected function getFirstMatch(DOMDocument $document): ExpressionExtractorInterface

Check warning on line 66 in src/DiscoverExtractor.php

View workflow job for this annotation

GitHub Actions / Mutation testing analysis

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return null; } - protected function getFirstMatch(DOMDocument $document) : ExpressionExtractorInterface + private function getFirstMatch(DOMDocument $document) : ExpressionExtractorInterface { $discovered = $this->findMatch($document); if (null === $discovered) {
{
$discovered = $this->findMatch($document);
if (null === $discovered) {
Expand Down