Skip to content

Commit 7359a7e

Browse files
authored
Merge pull request #17 from pottink/php8.1
PHP8.1 support
2 parents 46fdf98 + a043dcb commit 7359a7e

File tree

9 files changed

+38
-31
lines changed

9 files changed

+38
-31
lines changed

.github/workflows/grumphp.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['7.3', '7.4', '8.0']
10+
php-versions: ['8.0', '8.1']
1111
composer-options: ['', '--prefer-lowest']
1212
fail-fast: false
1313
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }} with ${{ matrix.composer-options }}
@@ -34,20 +34,14 @@ jobs:
3434
path: ${{ steps.composercache.outputs.dir }}
3535
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
3636
restore-keys: ${{ runner.os }}-composer-
37-
- name: Install dependencies <PHP8
38-
if: matrix.php-versions != '8.0'
39-
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
40-
#
41-
# Currently php-cs-fixer is nog PHP 8 compatible yet!
42-
#
43-
- name: Install dependencies PHP8
44-
if: matrix.php-versions == '8.0'
37+
- name: Install dependencies
4538
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }} --ignore-platform-reqs
4639
- name: Set git variables
4740
run: |
4841
git config --global user.email "[email protected]"
4942
git config --global user.name "Your Name"
5043
- name: Run the tests
5144
run: php vendor/bin/grumphp run --no-interaction
45+
continue-on-error: ${{ matrix.php-versions == '8.1' && matrix.composer-options == '--prefer-lowest' }}
5246
env:
53-
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.php-versions == '8.0'}}
47+
PHP_CS_FIXER_IGNORE_ENV: 1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/vendor/
22
composer.lock
3-
.php_cs.cache
3+
.php-cs-fixer.cache
44
.php_cs
55
grumphp.yml
66
phpspec.yml

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
return (new PhpCsFixer\Config())
44
->setFinder(
5-
\Symfony\Component\Finder\Finder::create()
5+
PhpCsFixer\Finder::create()
66
->in([
77
__DIR__ . '/src',
88
__DIR__ . '/spec',
@@ -15,7 +15,7 @@
1515
'array_indentation' => true,
1616
'array_syntax' => ['syntax' => 'short'],
1717
'backtick_to_shell_exec' => true,
18-
'blank_line_before_statement' => true,
18+
'blank_line_before_statement' => ['statements' => ['return']],
1919
'class_keyword_remove' => false,
2020
'combine_consecutive_issets' => true,
2121
'combine_consecutive_unsets' => true,
@@ -30,13 +30,13 @@
3030
'escape_implicit_backslashes' => true,
3131
'explicit_indirect_variable' => true,
3232
'explicit_string_variable' => true,
33-
'final_internal_class' => false,
33+
'final_internal_class' => true,
3434
'fully_qualified_strict_types' => true,
3535
'general_phpdoc_annotation_remove' => false,
3636
'header_comment' => false,
3737
'heredoc_to_nowdoc' => false,
3838
'linebreak_after_opening_tag' => true,
39-
'list_syntax' => true,
39+
'list_syntax' => ['syntax' => 'short'],
4040
'mb_str_functions' => true,
4141
'method_chaining_indentation' => true,
4242
'multiline_comment_opening_closing' => true,
@@ -46,7 +46,7 @@
4646
'no_blank_lines_before_namespace' => false,
4747
'no_null_property_initialization' => true,
4848
'no_php4_constructor' => true,
49-
'no_short_echo_tag' => false,
49+
'echo_tag_syntax' => ['format'=> 'long'],
5050
'no_superfluous_elseif' => true,
5151
'no_unreachable_default_argument_value' => true,
5252
'no_useless_else' => true,
@@ -60,16 +60,17 @@
6060
'php_unit_mock' => false,
6161
'php_unit_namespaced' => false,
6262
'php_unit_no_expectation_annotation' => false,
63-
'php_unit_ordered_covers' => true,
63+
'phpdoc_order_by_value' => ['annotations' => ['covers']],
6464
'php_unit_set_up_tear_down_visibility' => true,
6565
'php_unit_strict' => false,
6666
'php_unit_test_annotation' => false,
6767
'php_unit_test_class_requires_covers' => false,
68+
'php_unit_method_casing' => ['case' => 'snake_case'],
6869
'phpdoc_add_missing_param_annotation' => true,
6970
'phpdoc_order' => true,
7071
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
7172
'pow_to_exponentiation' => true,
72-
'psr0' => true,
73+
'psr_autoloading' => ['dir' => 'src'],
7374
'random_api_migration' => false,
7475
'simplified_null_return' => true,
7576
'static_lambda' => false,
@@ -79,5 +80,13 @@
7980
'ternary_to_null_coalescing' => true,
8081
'void_return' => true,
8182
'yoda_style' => true,
83+
'single_line_throw' => false,
84+
'phpdoc_align' => ['align' => 'left'],
85+
'phpdoc_to_comment' => false,
86+
'global_namespace_import' => [
87+
'import_classes' => true,
88+
'import_constants' => true,
89+
'import_functions' => true,
90+
],
8291
])
8392
;

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"description": "RFC7807 Problem details implementation",
44
"type": "library",
55
"require-dev": {
6-
"friendsofphp/php-cs-fixer": "^2.16.7",
7-
"phpro/grumphp-shim": "^1.2",
8-
"phpspec/phpspec": "^6.3",
9-
"symfony/validator": "^4.4",
10-
"sebastian/comparator": "^1.2.4"
6+
"friendsofphp/php-cs-fixer": "^3.3",
7+
"phpro/grumphp-shim": "^1.6",
8+
"phpspec/phpspec": "^7.0",
9+
"symfony/validator": "^5.3 || ^6.0",
10+
"sebastian/comparator": "^4.0"
1111
},
1212
"license": "MIT",
1313
"authors": [
@@ -17,7 +17,7 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^7.3 || ^8.0"
20+
"php": "^8.0"
2121
},
2222
"config": {
2323
"sort-packages": true

grumphp.yml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
grumphp:
22
tasks:
33
phpcsfixer2:
4-
config: ".php_cs.dist"
4+
config: ".php-cs-fixer.dist.php"
55
config_contains_finder: true
66
phpspec:
77
format: dot

spec/Exception/ApiProblemExceptionSpec.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace spec\Phpro\ApiProblem\Exception;
66

7+
use Exception;
78
use Phpro\ApiProblem\ApiProblemInterface;
89
use Phpro\ApiProblem\Exception\ApiProblemException;
910
use PhpSpec\ObjectBehavior;
@@ -23,7 +24,7 @@ public function it_is_initializable(): void
2324

2425
public function it_is_an_excpetion(): void
2526
{
26-
$this->shouldHaveType(\Exception::class);
27+
$this->shouldHaveType(Exception::class);
2728
}
2829

2930
public function it_contains_an_api_problem(ApiProblemInterface $apiProblem): void

spec/Http/ExceptionApiProblemSpec.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace spec\Phpro\ApiProblem\Http;
66

77
use Exception;
8+
use InvalidArgumentException;
89
use Phpro\ApiProblem\DebuggableApiProblemInterface;
910
use Phpro\ApiProblem\Http\ExceptionApiProblem;
1011
use Phpro\ApiProblem\Http\HttpApiProblem;
@@ -148,7 +149,7 @@ public function it_should_deal_with_string_exception_codes(): void
148149
public function it_should_use_code_as_status_code_when_valid_http_status_code_error(): void
149150
{
150151
$message = 'an honest error';
151-
$this->beConstructedWith(new \InvalidArgumentException($message, 400));
152+
$this->beConstructedWith(new InvalidArgumentException($message, 400));
152153

153154
$this->toArray()->shouldBe([
154155
'status' => 400,

src/Exception/ApiProblemException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
namespace Phpro\ApiProblem\Exception;
66

7+
use Exception;
78
use Phpro\ApiProblem\ApiProblemInterface;
89

9-
class ApiProblemException extends \Exception
10+
class ApiProblemException extends Exception
1011
{
1112
/**
1213
* @var ApiProblemInterface

src/Http/ExceptionApiProblem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Phpro\ApiProblem\Http;
66

7+
use function get_class;
78
use Phpro\ApiProblem\DebuggableApiProblemInterface;
89
use Throwable;
910

@@ -23,7 +24,7 @@ public function __construct(Throwable $exception)
2324
: 500;
2425

2526
parent::__construct($statusCode, [
26-
'detail' => $exception->getMessage() ?: \get_class($exception),
27+
'detail' => $exception->getMessage() ?: get_class($exception),
2728
]);
2829
}
2930

@@ -51,7 +52,7 @@ public function toDebuggableArray(): array
5152
private function serializeException(Throwable $throwable): array
5253
{
5354
return [
54-
'type' => \get_class($throwable),
55+
'type' => get_class($throwable),
5556
'message' => $throwable->getMessage(),
5657
'code' => $throwable->getCode(),
5758
'line' => $throwable->getLine(),

0 commit comments

Comments
 (0)