Skip to content

Commit 7678021

Browse files
authored
Merge pull request #18 from eclipxe13/maintenance
Maintenance 2023-06-07 (v0.4.1)
2 parents 390fbf8 + 4e66371 commit 7678021

11 files changed

Lines changed: 92 additions & 37 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: build
22
on:
3+
workflow_dispatch:
34
pull_request:
45
branches: [ "master" ]
56
push:
@@ -22,7 +23,7 @@ jobs:
2223
- name: Setup PHP
2324
uses: shivammathur/setup-php@v2
2425
with:
25-
php-version: '8.1'
26+
php-version: '8.2'
2627
coverage: none
2728
tools: composer-normalize
2829
env:
@@ -39,7 +40,7 @@ jobs:
3940
- name: Setup PHP
4041
uses: shivammathur/setup-php@v2
4142
with:
42-
php-version: '8.1'
43+
php-version: '8.2'
4344
coverage: none
4445
tools: cs2pr, phpcs
4546
env:
@@ -56,7 +57,7 @@ jobs:
5657
- name: Setup PHP
5758
uses: shivammathur/setup-php@v2
5859
with:
59-
php-version: '8.1'
60+
php-version: '8.2'
6061
coverage: none
6162
tools: cs2pr, php-cs-fixer
6263
env:
@@ -73,15 +74,15 @@ jobs:
7374
- name: Setup PHP
7475
uses: shivammathur/setup-php@v2
7576
with:
76-
php-version: '8.1'
77+
php-version: '8.2'
7778
coverage: none
7879
tools: composer:v2, phpstan
79-
extensions: soap
80+
extensions: soap, gd
8081
env:
8182
fail-fast: true
8283
- name: Get composer cache directory
8384
id: composer-cache
84-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
85+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
8586
- name: Cache dependencies
8687
uses: actions/cache@v3
8788
with:
@@ -98,7 +99,7 @@ jobs:
9899
runs-on: "ubuntu-latest"
99100
strategy:
100101
matrix:
101-
php-versions: ['7.3', '7.4', '8.0', '8.1']
102+
php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2']
102103
steps:
103104
- name: Checkout
104105
uses: actions/checkout@v3
@@ -114,7 +115,7 @@ jobs:
114115
php-version: ${{ matrix.php-versions }}
115116
coverage: xdebug
116117
tools: composer:v2
117-
extensions: soap
118+
extensions: soap, gd
118119
env:
119120
fail-fast: true
120121
- name: Install SAT XML resources
@@ -130,7 +131,7 @@ jobs:
130131
fi
131132
- name: Get composer cache directory
132133
id: composer-cache
133-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
134+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
134135
- name: Cache dependencies
135136
uses: actions/cache@v3
136137
with:
@@ -142,6 +143,7 @@ jobs:
142143
- name: Tests (phpunit)
143144
run: vendor/bin/phpunit --testdox --verbose --coverage-clover=build/coverage-clover.xml
144145
- name: Upload code coverage to scrutinizer
146+
if: ${{ !env.ACT }} # do not run if using nektos/act
145147
uses: sudo-bot/action-scrutinizer@latest
146148
with:
147149
cli-args: "--format=php-clover build/coverage-clover.xml"

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
php-version: '7.3' # use minimal version
2525
coverage: none
2626
tools: composer:v2
27-
extensions: soap
27+
extensions: soap, gd
2828
env:
2929
fail-fast: true
3030
- name: "Get composer cache directory"
3131
id: composer-cache
32-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3333
- name: "Cache dependencies"
3434
uses: actions/cache@v3
3535
with:

.phive/phars.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="composer-normalize" version="^2.28.3" installed="2.28.3" location="./tools/composer-normalize" copy="false"/>
4-
<phar name="php-cs-fixer" version="^3.11.0" installed="3.11.0" location="./tools/php-cs-fixer" copy="false"/>
5-
<phar name="phpcs" version="^3.7.1" installed="3.7.1" location="./tools/phpcs" copy="false"/>
6-
<phar name="phpcbf" version="^3.7.1" installed="3.7.1" location="./tools/phpcbf" copy="false"/>
7-
<phar name="phpstan" version="^1.8.5" installed="1.8.5" location="./tools/phpstan" copy="false"/>
3+
<phar name="composer-normalize" version="^2.31.0" installed="2.31.0" location="./tools/composer-normalize" copy="false"/>
4+
<phar name="php-cs-fixer" version="^3.17.0" installed="3.17.0" location="./tools/php-cs-fixer" copy="false"/>
5+
<phar name="phpcs" version="^3.7.2" installed="3.7.2" location="./tools/phpcs" copy="false"/>
6+
<phar name="phpcbf" version="^3.7.2" installed="3.7.2" location="./tools/phpcbf" copy="false"/>
7+
<phar name="phpstan" version="^1.10.16" installed="1.10.16" location="./tools/phpstan" copy="false"/>
88
</phive>

.php-cs-fixer.dist.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,23 @@
1818
'@PHP71Migration:risky' => true,
1919
'@PHP73Migration' => true,
2020
// basic
21-
'braces' => false, // do not let php-cs-fixer fix this, causes problem with php close tag
21+
'statement_indentation' => false, // invalid indentation
2222
// symfony
2323
'class_attributes_separation' => true,
2424
'whitespace_after_comma_in_array' => true,
2525
'no_empty_statement' => true,
2626
'no_extra_blank_lines' => true,
2727
'function_typehint_space' => true,
2828
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'arguments']],
29+
'new_with_braces' => true,
30+
'no_blank_lines_after_class_opening' => true,
2931
'no_blank_lines_after_phpdoc' => true,
3032
'object_operator_without_whitespace' => true,
3133
'binary_operator_spaces' => true,
3234
'phpdoc_scalar' => true,
3335
'no_trailing_comma_in_singleline' => true,
3436
'single_quote' => true,
37+
'single_blank_line_before_namespace' => true,
3538
'no_singleline_whitespace_before_semicolons' => true,
3639
'no_unused_imports' => true,
3740
'yoda_style' => ['equal' => true, 'identical' => true, 'less_and_greater' => null],

.scrutinizer.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ filter:
77
build:
88
dependencies:
99
override:
10-
- composer self-update --no-interaction --no-progress
11-
- composer remove squizlabs/php_codesniffer friendsofphp/php-cs-fixer phpstan/phpstan phpunit/phpunit --dev --no-interaction --no-progress --no-update
12-
- composer install --no-interaction
10+
- composer update --no-interaction
1311
nodes:
1412
php:
1513
tests:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 - 2020 PHPCFDI
3+
Copyright (c) 2018 - 2023 PhpCfdi https://www.phpcfdi.com/
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
119119
[badge-php-version]: https://img.shields.io/packagist/php-v/phpcfdi/cfditopdf?style=flat-square
120120
[badge-release]: https://img.shields.io/github/release/phpcfdi/cfditopdf?style=flat-square
121121
[badge-license]: https://img.shields.io/github/license/phpcfdi/cfditopdf?style=flat-square
122-
[badge-build]: https://img.shields.io/github/workflow/status/phpcfdi/cfditopdf/build/master?style=flat-square
122+
[badge-build]: https://img.shields.io/github/actions/workflow/status/phpcfdi/cfditopdf/build.yml?branch=master&style=flat-square
123123
[badge-quality]: https://img.shields.io/scrutinizer/g/phpcfdi/cfditopdf/master?style=flat-square
124124
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/phpcfdi/cfditopdf/master?style=flat-square
125125
[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/cfditopdf?style=flat-square

docs/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# `phpcfdi/cfditopdf` Changelog
22

3+
## Version 0.4.1 2023-06-07
4+
5+
This update fixes the continuous integration process and ensures compatibility with PHP 8.2.
6+
7+
- Introduce `CastToStringTrait#strval()` to avoid PHPStan issues.
8+
- Update `php-cs-fixer` configuration file.
9+
- Update license year.
10+
- Fix build badge.
11+
- On GitHub workflows:
12+
- Replace GitHub directive `::set-output` to `$GITHUB_OUTPUT`.
13+
- Require extension `gd`.
14+
- Add PHP 8.2 to test matrix.
15+
- Run jobs using PHP 8.2.
16+
- Allow run `build.yml` on demand.
17+
- Remove obsolete commands on Scrutinizer-CI.
18+
- Update development tools.
19+
320
## Version 0.4.0 2022-09-22 - Viva México
421

522
- Bump PHP Version to 7.3.

src/CfdiDataBuilder.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
use CfdiUtils\Nodes\XmlNodeUtils;
1212
use CfdiUtils\TimbreFiscalDigital\TfdCadenaDeOrigen;
1313
use CfdiUtils\XmlResolver\XmlResolver;
14+
use PhpCfdi\CfdiToPdf\Internal\CastToStringTrait;
1415

1516
class CfdiDataBuilder
1617
{
18+
use CastToStringTrait;
19+
1720
/** @var XmlResolver */
1821
private $xmlResolver;
1922

@@ -72,7 +75,10 @@ public function createTfdSourceString(NodeInterface $comprobante): string
7275
return '';
7376
}
7477
$tfdCadenaOrigen = new TfdCadenaDeOrigen($this->xmlResolver(), $this->xsltBuilder());
75-
return $tfdCadenaOrigen->build(XmlNodeUtils::nodeToXmlString($tfd), strval($tfd['Version'] ?: $tfd['version']));
78+
return $tfdCadenaOrigen->build(
79+
XmlNodeUtils::nodeToXmlString($tfd),
80+
$this->strval($tfd['Version'] ?: $tfd['version']),
81+
);
7682
}
7783

7884
/**
@@ -82,12 +88,12 @@ public function createTfdSourceString(NodeInterface $comprobante): string
8288
public function createQrUrl(NodeInterface $comprobante): string
8389
{
8490
$parameters = new RequestParameters(
85-
strval($comprobante['Version']),
91+
$this->strval($comprobante['Version']),
8692
$comprobante->searchAttribute('cfdi:Emisor', 'Rfc'),
8793
$comprobante->searchAttribute('cfdi:Receptor', 'Rfc'),
88-
strval($comprobante['Total']),
94+
$this->strval($comprobante['Total']),
8995
$comprobante->searchAttribute('cfdi:Complemento', 'tfd:TimbreFiscalDigital', 'UUID'),
90-
strval($comprobante['Sello']),
96+
$this->strval($comprobante['Sello']),
9197
);
9298
return $parameters->expression();
9399
}

src/Internal/CastToStringTrait.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpCfdi\CfdiToPdf\Internal;
6+
7+
use Stringable;
8+
9+
/**
10+
* @internal
11+
*/
12+
trait CastToStringTrait
13+
{
14+
/** @param mixed $value */
15+
private function strval($value): string
16+
{
17+
if (is_string($value)) {
18+
return $value;
19+
}
20+
if (null === $value || is_scalar($value) || (is_object($value) && is_callable([$value, '__toString']))) {
21+
/** @phpstan-var null|scalar|Stringable $value */
22+
return strval($value);
23+
}
24+
return '';
25+
}
26+
}

0 commit comments

Comments
 (0)