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-22 #5

Merged
merged 18 commits into from
Jan 22, 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
19 changes: 10 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: build
on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
push:
Expand All @@ -20,7 +21,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none
tools: cs2pr, phpcs
env:
Expand All @@ -37,7 +38,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'
coverage: none
tools: cs2pr, php-cs-fixer
env:
Expand All @@ -54,7 +55,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none
tools: composer:v2, cs2pr, phpstan
env:
Expand All @@ -71,7 +72,7 @@ jobs:
- name: Install project dependencies
run: composer upgrade --no-interaction --no-progress --prefer-dist
- name: PHPStan
run: phpstan analyse --no-progress --verbose
run: phpstan analyse --no-progress

psalm:
name: Code analysis (psalm)
Expand All @@ -82,7 +83,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none
tools: composer:v2, cs2pr, psalm
env:
Expand All @@ -102,18 +103,18 @@ jobs:
run: psalm --no-progress --output-format=github

tests:
name: Tests on PHP ${{ matrix.php-versions }}
name: Tests on PHP ${{ matrix.php-version }}
runs-on: "ubuntu-latest"
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2']
php-version: ['8.3']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer:v2
env:
Expand All @@ -130,4 +131,4 @@ jobs:
- name: Install project dependencies
run: composer upgrade --no-interaction --no-progress --prefer-dist
- name: Tests (phpunit)
run: vendor/bin/phpunit --testdox --verbose
run: vendor/bin/phpunit --testdox
10 changes: 5 additions & 5 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpcs" version="^3.7.1" installed="3.7.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.7.1" installed="3.7.1" location="./tools/phpcbf" copy="false"/>
<phar name="php-cs-fixer" version="^3.14.3" installed="3.14.3" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpstan" version="^1.9.14" installed="1.9.14" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="^5.6.0" installed="5.6.0" location="./tools/psalm" 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="php-cs-fixer" version="^3.48.0" installed="3.48.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="phpstan" version="^1.10.56" installed="1.10.56" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="^5.20.0" installed="5.20.0" location="./tools/psalm" copy="false"/>
</phive>
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'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', 'arguments']],
'no_blank_lines_after_phpdoc' => true,
'object_operator_without_whitespace' => true,
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build:
tests:
override:
- php-scrutinizer-run --enable-security-analysis
- command: php -dxdebug.mode=coverage vendor/bin/phpunit --verbose --coverage-clover=build/coverage.clover
- command: php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-clover=build/coverage.clover
coverage:
file: build/coverage.clover
format: clover
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 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.0-cli
FROM php:8.3-cli

COPY . /opt/generator

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) 2020 - 2023 PhpCfdi https://www.phpcfdi.com/
Copyright (c) 2020 - 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
1 change: 1 addition & 0 deletions bin/resources-sat-xml-generator
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ declare(strict_types=1);

include __DIR__ . '/../vendor/autoload.php';

/** @noinspection PhpUnhandledExceptionInspection */
exit((new PhpCfdi\ResourcesSatXmlGenerator\CLI\Application())->run());
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"issues": "https://github.com/phpcfdi/resources-sat-xml-generator/issues"
},
"require": {
"php": ">=8.0",
"php": ">=8.3",
"ext-json": "*",
"eclipxe/xmlresourceretriever": "^2.0.1",
"symfony/http-client": "^6.0",
"symfony/console": "^6.0"
"symfony/http-client": "^7.0",
"symfony/console": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.1",
"phpunit/phpunit": "^10.5",
"fakerphp/faker": "^1.17",
"symfony/finder": "^6.0"
"symfony/finder": "^7.0"
},
"autoload": {
"psr-4": {
Expand All @@ -48,12 +48,12 @@
],
"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"
],
"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
22 changes: 21 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@

Utilizamos [Versionado Semántico 2.0.0](SEMVER.md).

Importante: **Cambiar la versión en `Application::__construct`**.

## Versión 3.0.0 2024-01-22

- Se actualiza la versión mínima de PHP a 8.3.
- Se corrigen los problemas encontrados por PhpStorm.
- Se establece la versión correcta en `Application::__construct`.

## Mantenimiento 2024-01-22

- Se actualiza la imagen de docker para que esté basada en PHP 8.3.
- Se cambia el archivo de licencia. ¡Feliz 2024!
- Se corrige el ancla del proyecto en el archivo `CONTRIBUTING.md`.
- Se actualiza el archivo de configuración de `php-cs-fixer`.
- Se actualizan los flujos de trabajo de GitHub:
- Se agrega PHP 8.3 a la matriz de pruebas.
- Se ejecutan los flujos de trabajo en PHP 8.3.
- Se permite ejecutar manualmente el flujo de trabajo.
- Se actualizan las herramientas de desarrollo.

## Versión 2.0.1 2023-01-30

- Se corrige un posible bug en `Downloader` al dividir un texto en dos partes.
La segunda parte podría no existir y no estaba tratado correctamente.
- Se le da mantenimiento a el proyecto:
- Se le da mantenimiento al proyecto:
- Actualización de licencia. Feliz 2023.
- Actualización del emblema de construcción.
- Se agrega PHP 8.2 a la matrix de pruebas.
Expand Down
12 changes: 9 additions & 3 deletions docs/TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# phpcfdi/resources-sat-xml-generator To Do List

## Cambio de versión mínima de PHP a 8.0
Liste en este archivo los posibles cambios futuros e ideas pendientes.

Este proyecto podría utilizar todas las ventajas del lenguaje en una versión más reciente.
Se podría utilizar `rector` para hacer esta migración.
## Tipo de datos de constantes

A la fecha 2024-01-22 la herramienta `phpcs` no detecta correctamente los tipos en las constantes de PHP 8.3,
por lo que no se han agregado. En cuanto se corrija este problema, se debe agregar el tipo de datos.
Por ejemplo en `PhpCfdi\ResourcesSatXmlGenerator\CLI\FetchSatCommand::NS_REGISTRY`.

## Migrar de Scrutinizer-CI a SonarCloud

La migración de *Scrutinizer-CI* a *SonarCloud* es deseable porque tiene mejores métricas y visualización de cobertura de código.
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/CLI/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Application extends SymfonyApplication
{
public function __construct()
{
parent::__construct('resources-sat-xml-generator', '1.2.0');
parent::__construct('resources-sat-xml-generator', '3.0.0');
$this->add(new FetchSatCommand());
$this->add(new FetchCommand());
}
Expand Down
10 changes: 8 additions & 2 deletions src/CLI/FetchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@

final class FetchCommand extends Command
{
protected static $defaultName = 'fetch:urls';
/** @noinspection PhpMissingParentCallCommonInspection */
public static function getDefaultName(): string
{
return 'fetch:urls';
}

/** @noinspection PhpMissingParentCallCommonInspection */
protected function configure(): void
{
$this->setDescription('Fetch xsd or xslt resources and store them on destination folder');
Expand All @@ -29,7 +34,8 @@ protected function configure(): void
);
}

public function execute(InputInterface $input, OutputInterface $output): int
/** @noinspection PhpMissingParentCallCommonInspection */
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string $destinationPath */
$destinationPath = $input->getArgument('destination-path');
Expand Down
14 changes: 10 additions & 4 deletions src/CLI/FetchSatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace PhpCfdi\ResourcesSatXmlGenerator\CLI;

use Exception;
use PhpCfdi\ResourcesSatXmlGenerator\Fetcher;
use PhpCfdi\ResourcesSatXmlGenerator\NsRegistry\NsRegistry;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -18,8 +18,13 @@ final class FetchSatCommand extends Command
{
public const NS_REGISTRY = 'https://raw.githubusercontent.com/phpcfdi/sat-ns-registry/master/complementos_v1.json';

protected static $defaultName = 'fetch:sat';
/** @noinspection PhpMissingParentCallCommonInspection */
public static function getDefaultName(): string
{
return 'fetch:sat';
}

/** @noinspection PhpMissingParentCallCommonInspection */
protected function configure(): void
{
$this->setDescription('Fetch the XSD collection files from SAT Registry, see ' . self::NS_REGISTRY);
Expand All @@ -34,18 +39,19 @@ protected function configure(): void
);
}

/** @noinspection PhpMissingParentCallCommonInspection */
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string|null $type */
$type = $input->getArgument('type');
$type = strtolower($type ?? '' ?: 'all');
if (! in_array($type, ['all', 'xsd', 'xslt'], true)) {
throw new Exception('Argument type (optional) must be one of all, xsd or xslt');
throw new RuntimeException('Argument type (optional) must be one of all, xsd or xslt');
}
$downloadXsd = in_array($type, ['all', 'xsd'], true);
$downloadXslt = in_array($type, ['all', 'xslt'], true);
/** @var string $registryLocation */
$registryLocation = $input->getOption('ns-registry') ?? '' ?: self::NS_REGISTRY;
$registryLocation = $input->getOption('ns-registry') ?: self::NS_REGISTRY;
/** @var string $destinationPath */
$destinationPath = $input->getArgument('destination-path');
/** @var string[] $ignoredLocations */
Expand Down
2 changes: 1 addition & 1 deletion src/CLI/OutputObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PhpCfdi\ResourcesSatXmlGenerator\ObserverInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class OutputObserver implements ObserverInterface
final readonly class OutputObserver implements ObserverInterface
{
public function __construct(private OutputInterface $output)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@

final class Downloader implements DownloaderInterface
{
private HttpClientInterface $httpClient;
private readonly HttpClientInterface $httpClient;

/** @var array<string, string> */
private array $overrides = [];

public function __construct(private ObserverInterface $observer, ?HttpClientInterface $httpClient = null)
public function __construct(private readonly ObserverInterface $observer, ?HttpClientInterface $httpClient = null)
{
$this->httpClient = $httpClient ?? HttpClient::create();
}

/**
* @throws DownloaderException
*/
public function downloadTo(string $source, string $destination): void
{
try {
Expand Down
4 changes: 2 additions & 2 deletions src/DownloaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

final class DownloaderException extends Exception
{
private string $source;
private readonly string $source;

private string $destination;
private readonly string $destination;

public function __construct(string $source, string $destination, Throwable $previous = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PhpCfdi\ResourcesSatXmlGenerator\Retrievers\XmlRetriever;
use PhpCfdi\ResourcesSatXmlGenerator\Retrievers\XmlRetrievers;

class Fetcher
readonly class Fetcher
{
private Downloader $downloader;

Expand Down
2 changes: 1 addition & 1 deletion src/NsRegistry/Locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @implements IteratorAggregate<string>
*/
final class Locations implements IteratorAggregate
final readonly class Locations implements IteratorAggregate
{
/** @var string[] */
private array $locations;
Expand Down
2 changes: 1 addition & 1 deletion src/NsRegistry/NsEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PhpCfdi\ResourcesSatXmlGenerator\NsRegistry;

final class NsEntry
final readonly class NsEntry
{
public function __construct(private string $xsd, private string $xslt)
{
Expand Down
Loading
Loading