From 5bf822e4028e7a8064a438f274b4f7c8c53deb77 Mon Sep 17 00:00:00 2001 From: celli33 Date: Tue, 20 Oct 2026 17:29:02 -0600 Subject: [PATCH 01/13] chore: update deps for allowing symfony 8 --- .phive/phars.xml | 12 ++++++------ composer.json | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index f95968a..fdd0238 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,9 +1,9 @@ - - - - - - + + + + + + diff --git a/composer.json b/composer.json index 3479612..fb3b941 100644 --- a/composer.json +++ b/composer.json @@ -32,12 +32,12 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^7.4", - "phpcfdi/rfc": "^1.1", + "guzzlehttp/guzzle": "^7.4 || ^8.3", + "phpcfdi/rfc": "^1.2", "psr/http-client": "^1.0", - "symfony/css-selector": "^7.0", - "symfony/dom-crawler": "^7.0", - "symfony/process": "^7.0" + "symfony/css-selector": "^7.0 || ^8.0", + "symfony/dom-crawler": "^7.0 || ^8.0", + "symfony/process": "^7.0 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^11.5" From 43d6d44512e0a1666f96fb5430d7b6ff6f9162a1 Mon Sep 17 00:00:00 2001 From: celli33 Date: Tue, 20 Oct 2026 17:29:06 -0600 Subject: [PATCH 02/13] fix: handle form feed characters when splitting PDF content lines in CsfExtractor --- src/PdfReader/CsfExtractor.php | 2 +- tests/Unit/PdfReader/CsfExtractor/GetCifIdTest.php | 6 ++++++ tests/Unit/PdfReader/CsfExtractor/GetRfcTest.php | 6 ++++++ tests/_files/csf-content-form-feed.txt | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/_files/csf-content-form-feed.txt diff --git a/src/PdfReader/CsfExtractor.php b/src/PdfReader/CsfExtractor.php index 6edc146..767088f 100644 --- a/src/PdfReader/CsfExtractor.php +++ b/src/PdfReader/CsfExtractor.php @@ -18,7 +18,7 @@ public function __construct(string $contents) if ('' === $contents) { throw new EmptyPdfContentException('Cannot read pdf contents.'); } - $this->lines = explode("\n", $contents); + $this->lines = preg_split('/[\n\f]/', $contents) ?: []; } public function getRfc(): ?string diff --git a/tests/Unit/PdfReader/CsfExtractor/GetCifIdTest.php b/tests/Unit/PdfReader/CsfExtractor/GetCifIdTest.php index b0b3eb4..d91b8ec 100644 --- a/tests/Unit/PdfReader/CsfExtractor/GetCifIdTest.php +++ b/tests/Unit/PdfReader/CsfExtractor/GetCifIdTest.php @@ -15,6 +15,12 @@ public function test_obtains_cif(): void $this->assertSame('12345678', $csfExtractor->getCifId()); } + public function test_obtains_cif_from_content_with_page_breaks(): void + { + $csfExtractor = new CsfExtractor($this->fileContents('csf-content-form-feed.txt')); + $this->assertSame('12345678', $csfExtractor->getCifId()); + } + public function test_bad_content_returns_empty_rfc(): void { $csfExtractor = new CsfExtractor($this->fileContents('csf-bad-content.txt')); diff --git a/tests/Unit/PdfReader/CsfExtractor/GetRfcTest.php b/tests/Unit/PdfReader/CsfExtractor/GetRfcTest.php index 4e85641..9151e12 100644 --- a/tests/Unit/PdfReader/CsfExtractor/GetRfcTest.php +++ b/tests/Unit/PdfReader/CsfExtractor/GetRfcTest.php @@ -17,6 +17,12 @@ public function test_obtains_rfc(): void $this->assertSame('DIM8701081LA', $csfExtractor->getRfc()); } + public function test_obtains_rfc_from_content_with_page_breaks(): void + { + $csfExtractor = new CsfExtractor($this->fileContents('csf-content-form-feed.txt')); + $this->assertSame('DIM8701081LA', $csfExtractor->getRfc()); + } + public function test_bad_content_returns_empty_rfc(): void { $csfExtractor = new CsfExtractor($this->fileContents('csf-bad-content.txt')); diff --git a/tests/_files/csf-content-form-feed.txt b/tests/_files/csf-content-form-feed.txt new file mode 100644 index 0000000..56e8159 --- /dev/null +++ b/tests/_files/csf-content-form-feed.txt @@ -0,0 +1,2 @@ +CONSTANCIA DE SITUACION FISCAL idCIF: 12345678 +RFC: DIM8701081LA \ No newline at end of file From 42dc4787fa99f4d2a160cfb2b9dabd40d7885d94 Mon Sep 17 00:00:00 2001 From: celli33 Date: Tue, 20 Oct 2026 17:34:25 -0600 Subject: [PATCH 03/13] docs: add changelog entries for version 0.2.1 --- docs/CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4c8f56d..05d7eec 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,15 @@ versión, aunque sí su incorporación en la rama principal de trabajo, generalm ## Listado de cambios +### Versión 0.2.1 2026-10-20 + +- Se agrega compatibilidad con Symfony 8 (`symfony/css-selector`, `symfony/dom-crawler` y `symfony/process`). +- Se agrega compatibilidad con Guzzle 8, se mantiene la compatibilidad con Guzzle 7. +- Se actualiza la dependencia mínima de `phpcfdi/rfc` a la versión 1.2. +- Se corrige la lectura del RFC y del idCIF desde el PDF de la Constancia de Situación Fiscal cuando `pdftotext` + agrega el separador de página (`\f`) pegado al texto (encontrado en la versión de poppler-utils 26.10.0 para Mac). +- Se actualiza el año de la licencia a 2026. + ### Versión 0.2.0 2025-11-10 - Se asegura la compatibilidad con PHP 8.3 y PHP 8.4. From 5aaeeeb3c0d90f986c0c7f8f4c4baa726c493cd1 Mon Sep 17 00:00:00 2001 From: celli33 Date: Tue, 20 Oct 2026 17:41:06 -0600 Subject: [PATCH 04/13] chore: update copyright year and website format in LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 84985b8..2035313 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 - 2025 PhpCfdi https://www.phpcfdi.com/ +Copyright (c) 2022 - 2026 PhpCfdi 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 2eabfdf57cc9f8b4462dcc79f2436686b8424b1a Mon Sep 17 00:00:00 2001 From: celli33 Date: Wed, 21 Oct 2026 14:33:54 -0600 Subject: [PATCH 05/13] chore: update copyright URL format in LICENSE file --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 2035313..7214122 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 - 2026 PhpCfdi +Copyright (c) 2022 - 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 From d51e4d8eb5d4a2c462a8426a0b3e769535f94082 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 12 Jun 2026 14:24:58 -0600 Subject: [PATCH 06/13] Add script to get information using a pdf file --- tests/bin/csf-info-pdf.php | 107 +++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/bin/csf-info-pdf.php diff --git a/tests/bin/csf-info-pdf.php b/tests/bin/csf-info-pdf.php new file mode 100644 index 0000000..f47a6a1 --- /dev/null +++ b/tests/bin/csf-info-pdf.php @@ -0,0 +1,107 @@ + */ + public array $arguments; + + public function __construct(string $command, string ...$arguments) + { + $this->debug = false; + $this->command = $command; + foreach ($arguments as $key => $value) { + if (in_array($value, ['-d', '--debug'])) { + $this->debug = true; + unset($arguments[$key]); + } + } + $this->arguments = array_values($arguments); + } + + public function printHelp(): void + { + $command = basename($this->command); + echo implode(PHP_EOL, [ + "$command - Obtiene la información con base en un archivo PDF", + 'Sintaxis:', + " $command help|-h|--help", + " $command [-d|--debug] CSF-FILE", + 'Argumentos:', + ' --debug|-d Si se encuentra un error, muestra la excepción y todas las excepciones previas.', + ' CSF-FILE Archivo PDF con la constancia de situación fiscal.', + 'Salida:', + ' Información extraída del sitio del SAT en formato JSON', + 'Licencia y autoría:', + ' La misma del proyecto https://github.com/phpcfdi/csf-scraper', + 'Advertencia:', + ' Este es un ejemplo de uso y este script pruebe cambiar en cualquier momento.', + ' Use su propia implementación para evitar conflictos entre versiones.', + '', + '', + ]); + } + + public function __invoke(): int + { + if ([] !== array_intersect($this->arguments, ['--help', '-h', 'help'])) { + $this->printHelp(); + return 0; + } + try { + $this->execute(); + return 0; + } catch (Throwable $exception) { + if ($this->debug) { + for ($current = $exception; null !== $current; $current = $current->getPrevious()) { + $this->printError(sprintf('Exception (%s) %s', $exception::class, $exception->getMessage())); + $this->printError(sprintf('At %s(%s)', $exception->getFile(), $exception->getLine())); + $this->printError($exception->gettraceAsString()); + } + } else { + $this->printError(sprintf('ERROR: %s', $exception->getMessage())); + } + return is_int($exception->getCode()) && $exception->getCode() > 0 ? $exception->getCode() : 1; + } + } + + private function printError(string ...$messages): void + { + foreach ($messages as $message) { + file_put_contents('php://stderr', $message, FILE_APPEND); + file_put_contents('php://stderr', PHP_EOL, FILE_APPEND); + } + } + + public function execute(): void + { + $filename = ''; + + $arguments = $this->arguments; + foreach ($arguments as $argument) { + if ('' === $filename) { + $filename = $argument; + } else { + throw new RuntimeException(sprintf('Unexpected argument "%s".', $argument)); + } + } + if ('' === $filename) { + throw new RuntimeException('Expected argument CSF-FILE is not set.'); + } + if (! file_exists($filename)) { + throw new RuntimeException(sprintf('File "%s" does not exists.', $filename)); + } + + $scraper = Scraper::create(); + $person = $scraper->obtainFromPdfPath($filename); + echo json_encode($person, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE), PHP_EOL; + } +})); From e35285f3657062dcffa4d81667af863f2878ca51 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 12 Jun 2026 14:22:25 -0600 Subject: [PATCH 07/13] Fix dev:test description to include composer-require-checker --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fb3b941..0c71001 100644 --- a/composer.json +++ b/composer.json @@ -89,6 +89,6 @@ "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 composer-normalize, php-cs-fixer and phpcbf", - "dev:test": "DEV: run @dev:check-style, phpunit and phpstan" + "dev:test": "DEV: run @dev:check-style, phpunit, phpstan and composer-require-checker" } } From 2a1de3cc84ec452062285ab6574e21c8e228524d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 12 Jun 2026 14:22:49 -0600 Subject: [PATCH 08/13] Rename job tests to phpunit --- .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 f817611..f1f290e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,7 +122,7 @@ jobs: - name: PHPStan run: phpstan analyse --no-progress --verbose - tests: + phpunit: name: PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }} strategy: From 43ca86ed16294ca8a6f8f0121742e1a67dcc0030 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 12 Jun 2026 14:23:08 -0600 Subject: [PATCH 09/13] Add PHP 8.5 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 f1f290e..7f3d1a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,7 +128,7 @@ jobs: strategy: matrix: operating-system: ["windows-latest", "ubuntu-latest"] - php-version: ['8.2', '8.3', '8.4'] + php-version: ['8.2', '8.3', '8.4', '8.5'] steps: - name: Checkout uses: actions/checkout@v4 From c59ce18aa358fa040bc79ddc082190c471cd30e3 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Fri, 12 Jun 2026 14:23:37 -0600 Subject: [PATCH 10/13] Run jobs using PHP 8.5 --- .github/workflows/build.yml | 10 +++++----- .github/workflows/sonarqube-cloud.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f3d1a4..06cba53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer-normalize env: @@ -39,7 +39,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer-require-checker env: @@ -68,7 +68,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: cs2pr, phpcs env: @@ -85,7 +85,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: cs2pr, php-cs-fixer env: @@ -102,7 +102,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: none tools: composer:v2, phpstan env: diff --git a/.github/workflows/sonarqube-cloud.yml b/.github/workflows/sonarqube-cloud.yml index 9abdcbf..4acd934 100644 --- a/.github/workflows/sonarqube-cloud.yml +++ b/.github/workflows/sonarqube-cloud.yml @@ -27,7 +27,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.5' coverage: xdebug tools: composer:v2 - name: Install poppler-utils From c5a718febf875a892883cea024c5d542d1aed1db Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 21 Oct 2026 20:54:41 -0600 Subject: [PATCH 11/13] Update development tools --- .phive/phars.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index fdd0238..f0deddc 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,9 +1,9 @@ - - + + - - + + From 25ec30eeb92157c652676b4571bc574f1d1fb593 Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 21 Oct 2026 20:54:55 -0600 Subject: [PATCH 12/13] Update actions versions --- .github/workflows/build.yml | 18 +++++++++--------- .github/workflows/sonarqube-cloud.yml | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06cba53..8b9c019 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -35,7 +35,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -49,7 +49,7 @@ jobs: shell: bash run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -64,7 +64,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -81,7 +81,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -98,7 +98,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -112,7 +112,7 @@ jobs: shell: bash run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -131,7 +131,7 @@ jobs: php-version: ['8.2', '8.3', '8.4', '8.5'] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@v2 with: @@ -150,7 +150,7 @@ jobs: shell: bash run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/.github/workflows/sonarqube-cloud.yml b/.github/workflows/sonarqube-cloud.yml index 4acd934..1a4fdfa 100644 --- a/.github/workflows/sonarqube-cloud.yml +++ b/.github/workflows/sonarqube-cloud.yml @@ -6,7 +6,7 @@ on: # Actions # shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action -# SonarSource/sonarqube-scan-action@v6 https://github.com/marketplace/actions/official-sonarqube-scan +# SonarSource/sonarqube-scan-action@v8 https://github.com/marketplace/actions/official-sonarqube-scan jobs: @@ -21,7 +21,7 @@ jobs: exit 1 fi - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Unshallow clone to provide blame information run: git fetch --unshallow - name: Setup PHP @@ -38,7 +38,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache dependencies - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} @@ -52,6 +52,6 @@ jobs: 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@v6 + uses: SonarSource/sonarqube-scan-action@v8 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 8ad68fada3d6c66d1a8bee4e991c11d2efaa482d Mon Sep 17 00:00:00 2001 From: Carlos C Soto Date: Wed, 21 Oct 2026 21:04:28 -0600 Subject: [PATCH 13/13] Prepare version 0.2.1 --- docs/CHANGELOG.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 05d7eec..9b7af78 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,14 +11,27 @@ versión, aunque sí su incorporación en la rama principal de trabajo, generalm ## Listado de cambios -### Versión 0.2.1 2026-10-20 +### Versión 0.2.1 2026-10-21 +- Se asegura la compatibilidad con PHP 8.5. - Se agrega compatibilidad con Symfony 8 (`symfony/css-selector`, `symfony/dom-crawler` y `symfony/process`). - Se agrega compatibilidad con Guzzle 8, se mantiene la compatibilidad con Guzzle 7. - Se actualiza la dependencia mínima de `phpcfdi/rfc` a la versión 1.2. - Se corrige la lectura del RFC y del idCIF desde el PDF de la Constancia de Situación Fiscal cuando `pdftotext` agrega el separador de página (`\f`) pegado al texto (encontrado en la versión de poppler-utils 26.10.0 para Mac). - Se actualiza el año de la licencia a 2026. +- Se agrega un script funcional de ejemplo en `tests/bin/csf-info-pdf.php` que sirve para obtener la información en + formato JSON del archivo PDF dado. + +Cambios al entorno de desarrollo: + +- En los flujos de trabajo: + - Se actualizan las versiones de las acciones. + - Se agrega PHP 8.5 a la matriz de pruebas. + - Se ejecutan los trabajos en PHP 8.5. + - Se renombra el trabajo `tests` a `phpunit`. +- Se corrige la descripción de `composer dev:test` para incluir `composer-require-checker`. +- Se actualizan las herramientas de desarrollo. ### Versión 0.2.0 2025-11-10