Skip to content
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
12 changes: 6 additions & 6 deletions .github/workflows/monorepo_split_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ on:

jobs:
provide_packages_json:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

# required for matrix of packages set
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v1"
- uses: "ramsey/composer-install@v4"

- name: Install Monorepo-Builder
run: composer require symplify/monorepo-builder:11.0.8 --update-no-dev
Expand All @@ -35,19 +35,19 @@ jobs:
split_monorepo:
needs: provide_packages_json

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.provide_packages_json.outputs.matrix)}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

-
# Uses an action in the root directory
name: Monorepo Split of ${{ matrix.package }}
uses: symplify/monorepo-split-github-action@v2.3.0
uses: symplify/monorepo-split-github-action@v2.4.5
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/monorepo_split_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ on:

jobs:
provide_packages_json_tagged:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

# required for matrix of packages set
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none

- uses: "ramsey/composer-install@v1"
- uses: "ramsey/composer-install@v4"

- name: Install Monorepo-Builder
run: composer require symplify/monorepo-builder:11.0.8 --update-no-dev
Expand All @@ -35,19 +35,19 @@ jobs:
split_monorepo_tagged:
needs: provide_packages_json_tagged

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.provide_packages_json_tagged.outputs.matrix)}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

-
# Uses an action in the root directory
name: Monorepo Split of ${{ matrix.package }}
uses: symplify/monorepo-split-github-action@v2.3.0
uses: symplify/monorepo-split-github-action@v2.4.5
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
Expand Down
112 changes: 83 additions & 29 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,102 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

# Cancela el run anterior cuando se hace push de nuevo al mismo PR/rama.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-22.04
# --------------------------------------------------------------------------
# Tests deterministas (sin red).
# --------------------------------------------------------------------------
unit:
name: Unit · PHP ${{ matrix.php }}
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
php: ['8.2']
report-coverage: [false]
php: [ '7.4', '8.2', '8.4' ]
include:
- php: '7.4'
report-coverage: true
coverage: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, curl, soap, dom, xsl, zip, :fileinfo
# pcov solo donde se reporta cobertura; en el resto 'none' (más rápido)
coverage: ${{ matrix.coverage && 'pcov' || 'none' }}
tools: composer:v2, psalm:5

- name: Validate composer.json
run: composer validate --strict

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, curl, soap, :fileinfo
- name: Install dependencies (con caché)
uses: ramsey/composer-install@v4
with:
composer-options: --prefer-dist --no-progress

- name: Validate composer.json
run: composer validate
- name: PHPStan
run: composer run-script lint:ci

- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Psalm
if: ${{ matrix.coverage }}
run: psalm --shepherd --no-progress

- name: Run PHPStan
run: composer run-script lint:ci
- name: Unit tests
if: ${{ !matrix.coverage }}
run: vendor/bin/phpunit --exclude-group integration,manual

- name: Run PSalm
if: ${{ matrix.report-coverage }}
run: vendor/bin/psalm --shepherd
- name: Unit tests + coverage
if: ${{ matrix.coverage }}
run: vendor/bin/phpunit --exclude-group integration,manual --coverage-clover clover.xml

- name: Upload coverage
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v7
with:
files: ./clover.xml
flags: unittests
name: codecov-greenter
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

# --------------------------------------------------------------------------
# Tests de integración contra SUNAT beta / GRE (nubefact). Dependen de
# servicios externos: se ejecutan aparte.
# --------------------------------------------------------------------------
integration:
name: Integración SUNAT beta (informativo)
runs-on: ubuntu-24.04
timeout-minutes: 20
continue-on-error: true
# En PRs de forks no hay secrets ni sentido de golpear SUNAT; correr solo
# en push a master, PRs internos o manualmente.
if: >-
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository

steps:
- uses: actions/checkout@v7

- name: Unit Tests
run: vendor/bin/phpunit --exclude-group manual --coverage-clover clover.xml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, curl, soap, dom, xsl, zip, :fileinfo
coverage: none
tools: composer:v2

- uses: codecov/codecov-action@v1
if: ${{ matrix.report-coverage }}
with:
file: ./clover.xml
flags: unittests
name: codecov-greenter
- name: Install dependencies (con caché)
uses: ramsey/composer-install@v4

- name: Integration tests
run: vendor/bin/phpunit --group integration --exclude-group manual
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Los cambios notables de cada lanzamiento serán documentados en este archivo.

## Unreleased
- CI: tests unitarios separados de los de integración (SUNAT beta ya no bloquea PRs); matrix PHP 7.4–8.4; actions actualizadas.
- Corregir parámetros implícitamente nullable (deprecación PHP 8.4).
- Registrar filtros y funciones Twig del reporte con instancias (compatibilidad con Psalm 5.26).

## 5.0.0 - 2023-05-01
- #206 Agregar xml para nueva Guia de Remisión.
- #209 Cambiar versión mínima de PHP a `7.4`
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"greenter/ubl-validator": "^2.0",
"mockery/mockery": "^1.2",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9",
"vimeo/psalm": "~5.10.0"
"phpunit/phpunit": "^9"
},
"suggest": {
"ext-dom": "For xml, xml-parser, cpe-validator, ws package",
Expand Down
19 changes: 12 additions & 7 deletions packages/report/src/Report/Extension/ReportTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

namespace Greenter\Report\Extension;

use Greenter\Report\Filter\DocumentFilter;
use Greenter\Report\Filter\FormatFilter;
use Greenter\Report\Filter\ImageFilter;
use Greenter\Report\Filter\ResolveFilter;
use Greenter\Report\Render\QrRender;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
Expand All @@ -20,19 +25,19 @@ class ReportTwigExtension extends AbstractExtension
public function getFilters()
{
return [
new TwigFilter('catalog', ['Greenter\Report\Filter\DocumentFilter', 'getValueCatalog']),
new TwigFilter('image_b64', ['Greenter\Report\Filter\ImageFilter', 'toBase64']),
new TwigFilter('n_format', ['Greenter\Report\Filter\FormatFilter', 'number']),
new TwigFilter('catalog', [new DocumentFilter(), 'getValueCatalog']),
new TwigFilter('image_b64', [new ImageFilter(), 'toBase64']),
new TwigFilter('n_format', [new FormatFilter(), 'number']),
];
}

public function getFunctions()
{
return [
new TwigFunction('legend', ['Greenter\Report\Filter\ResolveFilter', 'getValueLegend']),
new TwigFunction('qrCode', ['Greenter\Report\Render\QrRender', 'getImage']),
new TwigFunction('qrCodeDespatch', ['Greenter\Report\Render\QrRender', 'getImageDespatch']),
new TwigFunction('qrUrl', ['Greenter\Report\Render\QrRender', 'getQrUrl']),
new TwigFunction('legend', [new ResolveFilter(), 'getValueLegend']),
new TwigFunction('qrCode', [new QrRender(), 'getImage']),
new TwigFunction('qrCodeDespatch', [new QrRender(), 'getImageDespatch']),
new TwigFunction('qrUrl', [new QrRender(), 'getQrUrl']),
];
}
}
2 changes: 1 addition & 1 deletion packages/validator/src/Validator/MessageTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addResource(array $items)
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
return $this->getValue($id);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ws/src/Zip/DecompressInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface DecompressInterface
*
* @return array
*/
public function decompress(?string $content, callable $filter = null): ?array;
public function decompress(?string $content, ?callable $filter = null): ?array;
}
2 changes: 1 addition & 1 deletion packages/ws/src/Zip/ZipDecompressDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(DecompressInterface $decompressor)
/**
* @inheritDoc
*/
public function decompress(?string $content, callable $filter = null): ?array
public function decompress(?string $content, ?callable $filter = null): ?array
{
if (empty($content)) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/ws/src/Zip/ZipFly.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function compress(?string $filename, ?string $content): ?string
*
* @return array
*/
public function decompress(?string $content, callable $filter = null): ?array
public function decompress(?string $content, ?callable $filter = null): ?array
{
$zipFile = new ZipFile();
$zipFile->openFromString($content);
Expand Down
6 changes: 6 additions & 0 deletions packages/ws/tests/Ws/Services/ConsultCdrServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class ConsultCdrServiceTest extends TestCase
{
use ConsultCdrServiceTrait;

/**
* @group integration
*/
public function testGetStatusInvalidUser()
{
$service = $this->getConsultService();
Expand All @@ -27,6 +30,9 @@ public function testGetStatusInvalidUser()
$this->assertEquals('00103', $result->getError()->getCode());
}

/**
* @group integration
*/
public function testGetStatusCdrInvalidUser()
{
$service = $this->getConsultService();
Expand Down
3 changes: 3 additions & 0 deletions packages/ws/tests/Ws/Services/FeSunatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public function testSendVoided()
$this->assertEquals(13, strlen($result->getTicket()));
}

/**
* @group integration
*/
public function testSendVoidedSummarySender()
{
$nameXml = '20600995805-RA-20170719-01';
Expand Down
4 changes: 2 additions & 2 deletions packages/xml-parser/src/Xml/Parser/InvoiceParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function defNodeAttribute(DOMNodeList $nodeList, string $attribute, stri
return $node->getAttribute($attribute);
}

private function loadTotals(Invoice $inv, DOMXPath $xpt, DOMNode $node = null)
private function loadTotals(Invoice $inv, DOMXPath $xpt, ?DOMNode $node = null)
{
if (empty($node)) {
return;
Expand Down Expand Up @@ -186,7 +186,7 @@ private function getPrepayments(DOMXPath $xpt)
}
}

private function getLegends(DOMXPath $xpt, DOMNode $node = null)
private function getLegends(DOMXPath $xpt, ?DOMNode $node = null)
{
if (empty($node)) {
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/xml-parser/src/Xml/Parser/NoteParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function parse($value): ?DocumentInterface
return $note;
}

private function loadTotals(Note $inv, DOMNode $node = null)
private function loadTotals(Note $inv, ?DOMNode $node = null)
{
if (empty($node)) {
return;
Expand Down Expand Up @@ -139,7 +139,7 @@ private function loadTributos(Note $inv)
}
}

private function getLegends(DOMNode $node = null)
private function getLegends(?DOMNode $node = null)
{
if (empty($node)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/xml-parser/src/Xml/XmlReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getXpath()
* @param string|null $def Default Value
* @return string
*/
public function getValue($query, DOMNode $context = null, ?string $def = ''): ?string
public function getValue($query, ?DOMNode $context = null, ?string $def = ''): ?string
{
$nodes = $this->xpath->query($query, $context);
if ($nodes->length == 0) {
Expand Down
Loading
Loading