Skip to content

Commit 744079b

Browse files
authored
Merge pull request #15 from NotMorales/master
Update of traditional CFDI 3.3 to 4.0
2 parents 2fda6ba + 462c235 commit 744079b

44 files changed

Lines changed: 1380 additions & 547 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22
* text=auto
33

44
# Do not put this files on a distribution package (by .gitignore)
5-
/vendor export-ignore
6-
/composer.lock export-ignore
5+
/tools/ export-ignore
6+
/vendor/ export-ignore
7+
/composer.lock export-ignore
78

89
# Do not put this files on a distribution package
9-
/build/ export-ignore
10-
/development/ export-ignore
11-
/tests/ export-ignore
12-
/.gitattributes export-ignore
13-
/.gitignore export-ignore
14-
/.php_cs.dist export-ignore
15-
/.scrutinizer.yml export-ignore
16-
/.travis.yml export-ignore
17-
/phpcs.xml.dist export-ignore
18-
/phpstan.neon.dist export-ignore
19-
/phpunit.xml.dist export-ignore
10+
/github/ export-ignore
11+
/build/ export-ignore
12+
/development/ export-ignore
13+
/tests/ export-ignore
14+
/.gitattributes export-ignore
15+
/.gitignore export-ignore
16+
/.php-cs-fixer.dist.php export-ignore
17+
/.scrutinizer.yml export-ignore
18+
/.travis.yml export-ignore
19+
/phpcs.xml.dist export-ignore
20+
/phpstan.neon.dist export-ignore
21+
/phpunit.xml.dist export-ignore
22+
23+
# Do not count these files on github code language
24+
/tests/_files/** linguist-detectable=false

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# see https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
2+
/.github/* @phpcfdi/core-maintainers

.github/workflows/build.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: build
2+
on:
3+
pull_request:
4+
branches: [ "master" ]
5+
push:
6+
branches: [ "master" ]
7+
schedule:
8+
- cron: '0 16 * * 0' # sunday 16:00
9+
10+
# Actions
11+
# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action
12+
# sudo-bot/action-scrutinizer@latest https://github.com/marketplace/actions/action-scrutinizer
13+
14+
jobs:
15+
16+
composer-normalize:
17+
name: Composer normalization
18+
runs-on: "ubuntu-latest"
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.1'
26+
coverage: none
27+
tools: composer-normalize
28+
env:
29+
fail-fast: true
30+
- name: Composer normalize
31+
run: composer-normalize
32+
33+
phpcs:
34+
name: Code style (phpcs)
35+
runs-on: "ubuntu-latest"
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: '8.1'
43+
coverage: none
44+
tools: cs2pr, phpcs
45+
env:
46+
fail-fast: true
47+
- name: Code style (phpcs)
48+
run: phpcs -q --report=checkstyle | cs2pr
49+
50+
php-cs-fixer:
51+
name: Code style (php-cs-fixer)
52+
runs-on: "ubuntu-latest"
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v3
56+
- name: Setup PHP
57+
uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: '8.1'
60+
coverage: none
61+
tools: cs2pr, php-cs-fixer
62+
env:
63+
fail-fast: true
64+
- name: Code style (php-cs-fixer)
65+
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
66+
67+
phpstan:
68+
name: Code analysis (phpstan)
69+
runs-on: "ubuntu-latest"
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v3
73+
- name: Setup PHP
74+
uses: shivammathur/setup-php@v2
75+
with:
76+
php-version: '8.1'
77+
coverage: none
78+
tools: composer:v2, phpstan
79+
extensions: soap
80+
env:
81+
fail-fast: true
82+
- name: Get composer cache directory
83+
id: composer-cache
84+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
85+
- name: Cache dependencies
86+
uses: actions/cache@v3
87+
with:
88+
path: ${{ steps.composer-cache.outputs.dir }}
89+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
90+
restore-keys: ${{ runner.os }}-composer-
91+
- name: Install project dependencies
92+
run: composer upgrade --no-interaction --no-progress --prefer-dist
93+
- name: PHPStan
94+
run: phpstan analyse --no-progress --verbose
95+
96+
tests:
97+
name: Tests on PHP ${{ matrix.php-versions }}
98+
runs-on: "ubuntu-latest"
99+
strategy:
100+
matrix:
101+
php-versions: ['7.3', '7.4', '8.0', '8.1']
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v3
105+
with:
106+
fetch-depth: 0 # required for sudo-bot/action-scrutinizer
107+
- name: Install poppler-utils
108+
run: |
109+
sudo apt-get update -y -qq
110+
sudo apt-get install -y -qq poppler-utils
111+
- name: Setup PHP
112+
uses: shivammathur/setup-php@v2
113+
with:
114+
php-version: ${{ matrix.php-versions }}
115+
coverage: xdebug
116+
tools: composer:v2
117+
extensions: soap
118+
env:
119+
fail-fast: true
120+
- name: Install SAT XML resources
121+
shell: bash
122+
run: |
123+
if [ ! -d tests/_files/external-resources ]; then
124+
rm -r -f tests/_files/external-resources
125+
git clone --depth 1 https://github.com/phpcfdi/resources-sat-xml resources-sat-xml-cloned
126+
mv resources-sat-xml-cloned/resources tests/_files/external-resources
127+
rm -r -f resources-sat-xml-cloned
128+
else
129+
echo tests/_files/external-resources already exists
130+
fi
131+
- name: Get composer cache directory
132+
id: composer-cache
133+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
134+
- name: Cache dependencies
135+
uses: actions/cache@v3
136+
with:
137+
path: ${{ steps.composer-cache.outputs.dir }}
138+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
139+
restore-keys: ${{ runner.os }}-composer-
140+
- name: Install project dependencies
141+
run: composer upgrade --no-interaction --no-progress --prefer-dist
142+
- name: Tests (phpunit)
143+
run: vendor/bin/phpunit --testdox --verbose --coverage-clover=build/coverage-clover.xml
144+
- name: Upload code coverage to scrutinizer
145+
uses: sudo-bot/action-scrutinizer@latest
146+
with:
147+
cli-args: "--format=php-clover build/coverage-clover.xml"
148+
continue-on-error: true

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Create and publish Phar"
2+
3+
on:
4+
release:
5+
branches: [ "master" ]
6+
tags: [ "v*" ]
7+
8+
# Actions
9+
# shivammathur/setup-php@v2 https://github.com/marketplace/actions/setup-php-action
10+
# svenstaro/upload-release-action@v2 https://github.com/marketplace/actions/upload-files-to-a-github-release
11+
12+
jobs:
13+
14+
publish:
15+
name: "Build PHAR file"
16+
runs-on: "ubuntu-latest"
17+
steps:
18+
- name: "Checkout"
19+
uses: actions/checkout@v3
20+
- name: "Setup PHP"
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '7.3' # use minimal version
24+
coverage: none
25+
tools: composer:v2
26+
extensions: soap
27+
env:
28+
fail-fast: true
29+
- name: "Get composer cache directory"
30+
id: composer-cache
31+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
32+
- name: "Cache dependencies"
33+
uses: actions/cache@v3
34+
with:
35+
path: ${{ steps.composer-cache.outputs.dir }}
36+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
37+
restore-keys: ${{ runner.os }}-composer-
38+
- name: "Install project dependencies"
39+
run: composer upgrade --no-interaction --no-progress --prefer-dist --no-dev
40+
- name: Install humbug/box
41+
run: |
42+
mkdir -p build/box
43+
composer -d build/box require humbug/box
44+
- name: "Set version file"
45+
run: git describe --tags | tee bin/version.txt
46+
- name: "Validate configuration for humbug/box"
47+
run: php build/box/vendor/bin/box validate
48+
- name: "Build build/cfditopdf.phar"
49+
run: php -d phar.readonly=0 build/box/vendor/bin/box compile
50+
- name: "Show build/cfditopdf.phar information"
51+
run: php build/box/vendor/bin/box info build/cfditopdf.phar
52+
- name: Upload binary to release
53+
if: ${{ !env.ACT }} # do not run if using nektos/act
54+
uses: svenstaro/upload-release-action@v2
55+
with:
56+
repo_token: ${{ secrets.GITHUB_TOKEN }}
57+
file: build/cfditopdf.phar
58+
asset_name: cfditopdf.phar
59+
tag: ${{ github.ref }}
60+
overwrite: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# do not include this files on git
2-
/vendor
2+
/tools/
3+
/vendor/
34
/composer.lock

.phive/phars.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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"/>
8+
</phive>
Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
11
<?php
22

3+
/**
4+
* @noinspection PhpUndefinedClassInspection
5+
* @noinspection PhpUndefinedNamespaceInspection
6+
* @see https://cs.symfony.com/doc/ruleSets/
7+
* @see https://cs.symfony.com/doc/rules/
8+
*/
9+
310
declare(strict_types=1);
411

5-
return PhpCsFixer\Config::create()
12+
return (new PhpCsFixer\Config())
613
->setRiskyAllowed(true)
7-
->setCacheFile(__DIR__.'/build/.php_cs.cache')
14+
->setCacheFile(__DIR__ . '/build/php-cs-fixer.cache')
815
->setRules([
9-
'@PSR2' => true,
10-
'@PHP70Migration' => true,
11-
'@PHP70Migration:risky' => true,
16+
'@PSR12' => true,
17+
'@PSR12:risky' => true,
18+
'@PHP71Migration:risky' => true,
19+
'@PHP73Migration' => true,
20+
// basic
21+
'braces' => false, // do not let php-cs-fixer fix this, causes problem with php close tag
1222
// symfony
1323
'class_attributes_separation' => true,
1424
'whitespace_after_comma_in_array' => true,
1525
'no_empty_statement' => true,
1626
'no_extra_blank_lines' => true,
1727
'function_typehint_space' => true,
18-
'no_alias_functions' => true,
19-
'trailing_comma_in_multiline_array' => true,
20-
'new_with_braces' => true,
21-
'no_blank_lines_after_class_opening' => true,
28+
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arrays', 'arguments']],
2229
'no_blank_lines_after_phpdoc' => true,
2330
'object_operator_without_whitespace' => true,
2431
'binary_operator_spaces' => true,
2532
'phpdoc_scalar' => true,
26-
'self_accessor' => true,
27-
'no_trailing_comma_in_singleline_array' => true,
33+
'no_trailing_comma_in_singleline' => true,
2834
'single_quote' => true,
2935
'no_singleline_whitespace_before_semicolons' => true,
3036
'no_unused_imports' => true,
31-
'no_whitespace_in_blank_line' => true,
3237
'yoda_style' => ['equal' => true, 'identical' => true, 'less_and_greater' => null],
3338
'standardize_not_equals' => true,
34-
// contrib
3539
'concat_space' => ['spacing' => 'one'],
36-
'not_operator_with_successor_space' => true,
37-
'single_blank_line_before_namespace' => true,
3840
'linebreak_after_opening_tag' => true,
39-
'blank_line_after_opening_tag' => true,
40-
'ordered_imports' => true,
41-
'array_syntax' => ['syntax' => 'short'],
41+
// symfony:risky
42+
'no_alias_functions' => true,
43+
'self_accessor' => true,
44+
// contrib
45+
'not_operator_with_successor_space' => true,
46+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], // @PSR12 sort_algorithm: none
4247
])
4348
->setFinder(
4449
PhpCsFixer\Finder::create()
4550
->in(__DIR__)
46-
->exclude(['vendor', 'tools', 'build'])
51+
->append([__FILE__])
52+
->exclude(['vendor', 'tools', 'build']),
4753
)
4854
;

.scrutinizer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ build:
1515
tests:
1616
override:
1717
- php-scrutinizer-run --enable-security-analysis
18+
1819
tools:
1920
external_code_coverage: true

0 commit comments

Comments
 (0)