Skip to content

Commit 0aa6155

Browse files
committed
Added php 8.0 support
1 parent da5ec6c commit 0aa6155

File tree

13 files changed

+180
-127
lines changed

13 files changed

+180
-127
lines changed

.github/workflows/code-analysis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install PHP
2020
uses: shivammathur/setup-php@v2
2121
with:
22-
php-version: '7.4'
22+
php-version: '8.0'
2323

2424
- name: Get composer cache directory
2525
id: composercache
@@ -33,7 +33,7 @@ jobs:
3333
restore-keys: ${{ runner.os }}-composer-
3434

3535
- name: Install dependencies
36-
run: composer install --prefer-dist --no-progress --no-suggest
36+
run: composer install --prefer-dist --no-progress
3737

3838
- name: Execute PhpStan
3939
run: php bin/githooks tool:phpstan
@@ -48,7 +48,7 @@ jobs:
4848
- name: Install PHP
4949
uses: shivammathur/setup-php@v2
5050
with:
51-
php-version: '7.4'
51+
php-version: '8.0'
5252

5353
- name: Get composer cache directory
5454
id: composercache
@@ -62,7 +62,7 @@ jobs:
6262
restore-keys: ${{ runner.os }}-composer-
6363

6464
- name: Install dependencies
65-
run: composer install --prefer-dist --no-progress --no-suggest
65+
run: composer install --prefer-dist --no-progress
6666

6767
- name: Execute Php Code Sniffer
6868
run: php bin/githooks tool:phpcs
@@ -77,7 +77,7 @@ jobs:
7777
- name: Install PHP
7878
uses: shivammathur/setup-php@v2
7979
with:
80-
php-version: '7.4'
80+
php-version: '8.0'
8181

8282
- name: Get composer cache directory
8383
id: composercache
@@ -91,7 +91,7 @@ jobs:
9191
restore-keys: ${{ runner.os }}-composer-
9292

9393
- name: Install dependencies
94-
run: composer install --prefer-dist --no-progress --no-suggest
94+
run: composer install --prefer-dist --no-progress
9595

9696
- name: Execute Php Mess Detector
9797
run: php bin/githooks tool:phpmd

.github/workflows/executable-finder.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Executable Finder
22
# https://github.com/shivammathur/setup-php
33
on:
44
push:
5-
branches-ignore: [ master ] #on master it only runs on ubuntu to speed up
5+
branches-ignore: [ master, 1.x ]
66

77
pull_request:
8-
branches-ignore: [ master ]
8+
branches-ignore: [ master, 1.x ]
99

1010
env:
1111
extensions: mbstring #intl, pcov
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
operating-system: [ubuntu-latest, macos-latest, windows-latest]
19-
php-versions: ['7.4']
19+
php-versions: ['8.0']
2020
name: Executable Finder on Local Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
2121
steps:
2222
- name: Checkout
@@ -32,7 +32,7 @@ jobs:
3232
coverage: none
3333

3434
- name: Install dependencies
35-
run: composer install --prefer-dist --no-progress --no-suggest
35+
run: composer install --prefer-dist --no-progress
3636

3737
- name: Install Parallel-Lint
3838
run: composer global require php-parallel-lint/php-parallel-lint
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
matrix:
4747
operating-system: [ubuntu-latest, macos-latest, windows-latest]
48-
php-versions: ['7.4']
48+
php-versions: ['8.0']
4949
name: Executable Finder on Phar Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
5050
steps:
5151
- name: Checkout
@@ -61,7 +61,7 @@ jobs:
6161
coverage: none
6262

6363
- name: Install dependencies
64-
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
64+
run: composer install --prefer-dist --no-progress --no-dev
6565

6666
- name: Install Parallel-Lint
6767
run: composer global require php-parallel-lint/php-parallel-lint
@@ -98,7 +98,7 @@ jobs:
9898
strategy:
9999
matrix:
100100
operating-system: [ubuntu-latest, macos-latest, windows-latest]
101-
php-versions: ['7.4']
101+
php-versions: ['8.0']
102102
name: Executable Finder on Global Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
103103
steps:
104104
- name: Checkout
@@ -114,7 +114,7 @@ jobs:
114114
coverage: none
115115

116116
- name: Install dependencies
117-
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
117+
run: composer install --prefer-dist --no-progress --no-dev
118118

119119
- name: Install Parallel-Lint
120120
run: composer global require php-parallel-lint/php-parallel-lint

.github/workflows/feature-ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Feature CI
22
# https://github.com/shivammathur/setup-php
33
on:
44
push:
5-
branches-ignore: [ master ]
5+
branches-ignore: [ master, php8 ]
66

77
pull_request:
88
branches-ignore: [ master ]
@@ -15,8 +15,8 @@ jobs:
1515
runs-on: ${{ matrix.operating-system }}
1616
strategy:
1717
matrix:
18-
operating-system: [ubuntu-18.04]
19-
php-versions: ['7.1']
18+
operating-system: [ubuntu-latest]
19+
php-versions: ['7.1', '8.0']
2020
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
2121
steps:
2222
- name: Checkout
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
php-version: ${{ matrix.php-versions }}
2929
extensions: ${{ env.extensions }} #optional
30-
tools: phpcs, phpcbf, phpmd, phpstan
30+
tools: phpcs, phpcbf, phpmd, phpstan, phpcpd
3131
ini-values: "post_max_size=256M" #optional
3232
coverage: none
3333

@@ -43,7 +43,7 @@ jobs:
4343
restore-keys: ${{ runner.os }}-composer-
4444

4545
- name: Install dependencies
46-
run: composer install --prefer-dist --no-progress --no-suggest
46+
run: composer install --prefer-dist --no-progress
4747

4848
- name: Install Phpcpd Unix
4949
if: ${{ ('7.2' == matrix.php-versions || '7.1' == matrix.php-versions) && ('ubuntu-18.04' == matrix.operating-system || 'macos-latest' == matrix.operating-system)}}

.github/workflows/master-ci.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Master
22
# https://github.com/shivammathur/setup-php
33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, 1.x ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, 1.x ]
88

99
env:
1010
extensions: mbstring #intl, pcov
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
operating-system: [ubuntu-18.04]
17-
php-versions: ['7.4']
17+
php-versions: ['8.0']
1818
name: Executable Finder on Local Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
1919
steps:
2020
- name: Checkout
@@ -30,7 +30,7 @@ jobs:
3030
coverage: none
3131

3232
- name: Install dependencies
33-
run: composer install --prefer-dist --no-progress --no-suggest
33+
run: composer install --prefer-dist --no-progress
3434

3535
- name: Install Parallel-Lint
3636
run: composer global require php-parallel-lint/php-parallel-lint
@@ -43,7 +43,7 @@ jobs:
4343
strategy:
4444
matrix:
4545
operating-system: [ubuntu-18.04]
46-
php-versions: ['7.4']
46+
php-versions: ['8.0']
4747
name: Executable Finder on Phar Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
4848
steps:
4949
- name: Checkout
@@ -59,7 +59,7 @@ jobs:
5959
coverage: none
6060

6161
- name: Install dependencies
62-
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
62+
run: composer install --prefer-dist --no-progress --no-dev
6363

6464
- name: Install Parallel-Lint
6565
run: composer global require php-parallel-lint/php-parallel-lint
@@ -96,7 +96,7 @@ jobs:
9696
strategy:
9797
matrix:
9898
operating-system: [ubuntu-18.04]
99-
php-versions: ['7.4']
99+
php-versions: ['8.0']
100100
name: Executable Finder on Global Test (${{ matrix.operating-system }}, PHP ${{ matrix.php-versions }})
101101
steps:
102102
- name: Checkout
@@ -112,7 +112,7 @@ jobs:
112112
coverage: none
113113

114114
- name: Install dependencies
115-
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
115+
run: composer install --prefer-dist --no-progress --no-dev
116116

117117
- name: Install Parallel-Lint
118118
run: composer global require php-parallel-lint/php-parallel-lint
@@ -126,44 +126,44 @@ jobs:
126126
- name: Testing the Executable Finder
127127
run: phpunit tests/System/ExecutableFinderTest.php
128128

129-
all-tests:
130-
runs-on: ${{ matrix.operating-system }}
131-
strategy:
132-
fail-fast: false
133-
matrix:
134-
operating-system: [ windows-latest, ubuntu-18.04, macos-latest ]
135-
php-versions: ['7.1', '7.2', '7.3', '7.4']
136-
name: PHP ${{ matrix.php-versions }} Full Tests on ${{ matrix.operating-system }}
137-
steps:
138-
- name: Checkout
139-
uses: actions/checkout@v2
140-
141-
- name: Install PHP
142-
uses: shivammathur/setup-php@v2
143-
with:
144-
php-version: ${{ matrix.php-versions }}
145-
extensions: ${{ env.extensions }} #optional
146-
tools: phpcs, phpcbf, phpmd, phpstan, phpcpd
147-
ini-values: "post_max_size=256M" #optional
148-
coverage: none
149-
150-
- name: Install dependencies
151-
run: composer install --prefer-dist --no-progress --no-suggest
152-
153-
- name: Install Parallel-Lint
154-
run: composer global require php-parallel-lint/php-parallel-lint
155-
156-
- name: Install Phpcpd Unix
157-
if: ${{ ('7.2' == matrix.php-versions || '7.1' == matrix.php-versions) && ('ubuntu-18.04' == matrix.operating-system || 'macos-latest' == matrix.operating-system)}}
158-
run: wget -O phpcpd.phar https://phar.phpunit.de/phpcpd-3.0.1.phar
129+
# all-tests:
130+
# runs-on: ${{ matrix.operating-system }}
131+
# strategy:
132+
# fail-fast: false
133+
# matrix:
134+
# operating-system: [ windows-latest, ubuntu-18.04, macos-latest ]
135+
# php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0']
136+
# name: PHP ${{ matrix.php-versions }} Full Tests on ${{ matrix.operating-system }}
137+
# steps:
138+
# - name: Checkout
139+
# uses: actions/checkout@v2
140+
141+
# - name: Install PHP
142+
# uses: shivammathur/setup-php@v2
143+
# with:
144+
# php-version: ${{ matrix.php-versions }}
145+
# extensions: ${{ env.extensions }} #optional
146+
# tools: phpcs, phpcbf, phpmd, phpstan, phpcpd
147+
# ini-values: "post_max_size=256M" #optional
148+
# coverage: none
149+
150+
# - name: Install dependencies
151+
# run: composer install --prefer-dist --no-progress
152+
153+
# - name: Install Parallel-Lint
154+
# run: composer global require php-parallel-lint/php-parallel-lint
155+
156+
# - name: Install Phpcpd Unix
157+
# if: ${{ ('7.2' == matrix.php-versions || '7.1' == matrix.php-versions) && ('ubuntu-18.04' == matrix.operating-system || 'macos-latest' == matrix.operating-system)}}
158+
# run: wget -O phpcpd.phar https://phar.phpunit.de/phpcpd-3.0.1.phar
159159

160-
- name: Install Phpcpd Windows
161-
if: ${{ ('7.2' == matrix.php-versions || '7.1' == matrix.php-versions) && ('windows-latest' == matrix.operating-system)}}
162-
run: curl -o phpcpd.phar https://phar.phpunit.de/phpcpd-3.0.1.phar
163-
164-
- name: Testing the Aplication
165-
run: |
166-
echo "**** Main Test Suite ****"
167-
vendor/bin/phpunit
168-
echo "**** GitfilesTest ****"
169-
vendor/bin/phpunit tests/Integration/GitFilesTest.php
160+
# - name: Install Phpcpd Windows
161+
# if: ${{ ('7.2' == matrix.php-versions || '7.1' == matrix.php-versions) && ('windows-latest' == matrix.operating-system)}}
162+
# run: curl -o phpcpd.phar https://phar.phpunit.de/phpcpd-3.0.1.phar
163+
164+
# - name: Testing the Aplication
165+
# run: |
166+
# echo "**** Main Test Suite ****"
167+
# vendor/bin/phpunit
168+
# echo "**** GitfilesTest ****"
169+
# vendor/bin/phpunit tests/Integration/GitFilesTest.php

.github/workflows/schedule-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
restore-keys: ${{ runner.os }}-composer-
4545

4646
- name: Install dependencies
47-
run: composer install --prefer-dist --no-progress --no-suggest
47+
run: composer install --prefer-dist --no-progress
4848

4949
- name: Tests with code coverage
5050
run: vendor/bin/phpunit --coverage-html ${{ env.report_path }}/coverage
@@ -78,7 +78,7 @@ jobs:
7878
coverage: xdebug
7979

8080
- name: Install dependencies
81-
run: composer install --prefer-dist --no-progress --no-suggest
81+
run: composer install --prefer-dist --no-progress
8282

8383
- name: Install Parallel-Lint
8484
run: composer global require php-parallel-lint/php-parallel-lint
@@ -112,7 +112,7 @@ jobs:
112112
coverage: xdebug
113113

114114
- name: Install dependencies
115-
run: composer install --prefer-dist --no-progress --no-suggest
115+
run: composer install --prefer-dist --no-progress
116116

117117
- name: Install PhPMetrics
118118
run: composer global require 'phpmetrics/phpmetrics'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a href="https://github.com/Wtyd/githooks/commits/" title="Last Commit"><img src="https://img.shields.io/github/last-commit/Wtyd/githooks"></a>
55
<a href="https://github.com/Wtyd/githooks/issues" title="Open Issues"><img src="https://img.shields.io/github/issues/Wtyd/githooks"></a>
66
<a href="https://github.com/Wtyd/githooks/blob/master/LICENSE" title="License"><img src="https://img.shields.io/github/license/Wtyd/githooks"></a>
7-
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-7.1%20to%207.4-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
7+
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-7.1%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
88
<img src="https://img.shields.io/github/v/release/Wtyd/githooks">
99
</p>
1010
<p align="center">

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"bin/githooks"
4141
],
4242
"require-dev": {
43+
"php": ">=7.1",
4344
"larapack/dd": "^1.1",
4445
"laravel-zero/foundation": "^5.0 | ^6.0 | ^7.0 | ^8.0",
4546
"mikey179/vfsstream": "^1.6",

src/Exception/ExitException.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,36 @@
22

33
namespace GitHooks\Exception;
44

5+
use GitHooks\Tools\Errors;
6+
57
/**
68
* Exception launched when some tool detects errors.
79
*/
810
class ExitException extends \RuntimeException implements GitHooksExceptionInterface
911
{
10-
public function __construct()
12+
public static function forErrors(string $errors): ExitException
13+
{
14+
$exception = new self(
15+
$errors
16+
);
17+
18+
return $exception;
19+
}
20+
21+
/**
22+
* Convierte un array asociativo en un string con el formato 'key'='value'
23+
*
24+
* @param array $array a transformar.
25+
* @return string
26+
*/
27+
protected function arrayToString(array $array)
1128
{
12-
$this->message = 'Some tool has found errors';
29+
return implode(', ', array_map(
30+
function ($value, $key) {
31+
return sprintf("'%s'='%s'", $key, $value);
32+
},
33+
$array,
34+
array_keys($array)
35+
));
1336
}
1437
}

0 commit comments

Comments
 (0)