Skip to content

Commit e4cb244

Browse files
authored
Merge pull request #15 from pottink/php81
Add PHP8.1 & Symfony 6 support
2 parents bd53374 + b1a089d commit e4cb244

18 files changed

+144
-129
lines changed

.github/workflows/grumphp.yaml

Lines changed: 3 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,14 +34,7 @@ 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 PHP
4538
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }} --ignore-platform-reqs
4639
- name: Set git variables
4740
run: |
@@ -50,4 +43,4 @@ jobs:
5043
- name: Run the tests
5144
run: php vendor/bin/grumphp run --no-interaction
5245
env:
53-
PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.php-versions == '8.0'}}
46+
PHP_CS_FIXER_IGNORE_ENV: 1

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/vendor/
22
composer.lock
3-
.php_cs.cache
3+
.php-cs-fixer.cache
44
.php_cs
55
grumphp.yml
66
phpunit.xml
77
var
8-
.phpunit.result.cache
8+
.phpunit.result.cache

.php-cs-fixer.dist.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
return (new PhpCsFixer\Config())
4+
->setFinder(
5+
\Symfony\Component\Finder\Finder::create()
6+
->in([
7+
__DIR__ . '/src',
8+
__DIR__ . '/test',
9+
])
10+
)
11+
->setRiskyAllowed(true)
12+
->setRules([
13+
'@Symfony' => true,
14+
'align_multiline_comment' => true,
15+
'array_indentation' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'backtick_to_shell_exec' => true,
18+
'blank_line_before_statement' => ['statements' => ['return']],
19+
'class_keyword_remove' => false,
20+
'combine_consecutive_issets' => true,
21+
'combine_consecutive_unsets' => true,
22+
'comment_to_phpdoc' => true,
23+
'compact_nullable_typehint' => true,
24+
'date_time_immutable' => true,
25+
'declare_strict_types' => true,
26+
'doctrine_annotation_array_assignment' => true,
27+
'doctrine_annotation_braces' => true,
28+
'doctrine_annotation_indentation' => true,
29+
'doctrine_annotation_spaces' => true,
30+
'escape_implicit_backslashes' => true,
31+
'explicit_indirect_variable' => true,
32+
'explicit_string_variable' => true,
33+
'final_internal_class' => true,
34+
'fully_qualified_strict_types' => true,
35+
'general_phpdoc_annotation_remove' => false,
36+
'header_comment' => false,
37+
'heredoc_to_nowdoc' => false,
38+
'linebreak_after_opening_tag' => true,
39+
'list_syntax' => ['syntax' => 'short'],
40+
'mb_str_functions' => true,
41+
'method_chaining_indentation' => true,
42+
'multiline_comment_opening_closing' => true,
43+
'multiline_whitespace_before_semicolons' => true,
44+
'native_function_invocation' => false,
45+
'no_alternative_syntax' => true,
46+
'no_blank_lines_before_namespace' => false,
47+
'no_null_property_initialization' => true,
48+
'no_php4_constructor' => true,
49+
'echo_tag_syntax' => ['format'=> 'long'],
50+
'no_superfluous_elseif' => true,
51+
'no_unreachable_default_argument_value' => true,
52+
'no_useless_else' => true,
53+
'no_useless_return' => true,
54+
'not_operator_with_space' => false,
55+
'not_operator_with_successor_space' => false,
56+
'ordered_class_elements' => false,
57+
'ordered_imports' => true,
58+
'php_unit_dedicate_assert' => false,
59+
'php_unit_expectation' => false,
60+
'php_unit_mock' => false,
61+
'php_unit_namespaced' => false,
62+
'php_unit_no_expectation_annotation' => false,
63+
'phpdoc_order_by_value' => ['annotations' => ['covers']],
64+
'php_unit_set_up_tear_down_visibility' => true,
65+
'php_unit_strict' => false,
66+
'php_unit_test_annotation' => false,
67+
'php_unit_test_class_requires_covers' => false,
68+
'php_unit_method_casing' => ['case' => 'snake_case'],
69+
'phpdoc_add_missing_param_annotation' => true,
70+
'phpdoc_order' => true,
71+
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
72+
'pow_to_exponentiation' => true,
73+
'psr_autoloading' => ['dir' => 'src'],
74+
'random_api_migration' => false,
75+
'simplified_null_return' => true,
76+
'static_lambda' => false,
77+
'strict_comparison' => true,
78+
'strict_param' => true,
79+
'string_line_ending' => true,
80+
'ternary_to_null_coalescing' => true,
81+
'void_return' => true,
82+
'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+
],
91+
])
92+
;

.php_cs.dist

Lines changed: 0 additions & 83 deletions
This file was deleted.

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.3 || ^8.0",
13+
"php": "^8.0",
1414
"phpro/api-problem": "^1.0",
15-
"symfony/dependency-injection": "^4.4|^5.0",
16-
"symfony/event-dispatcher": "^4.4|^5.0",
17-
"symfony/http-kernel": "^4.4|^5.0"
15+
"symfony/dependency-injection": "^5.3 || ^6.0",
16+
"symfony/event-dispatcher": "^5.3 || ^6.0",
17+
"symfony/http-kernel": "^5.3 || ^6.0"
1818
},
1919
"require-dev": {
20-
"friendsofphp/php-cs-fixer": "^2.16.7",
20+
"friendsofphp/php-cs-fixer": "^3.3",
2121
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
22-
"phpro/grumphp-shim": "^1.2.0",
22+
"phpro/grumphp-shim": "^1.6.0",
2323
"phpspec/prophecy-phpunit": "^2.0",
2424
"phpunit/phpunit": "^9.4",
25-
"symfony/security-core": "^4.4|^5.0"
25+
"symfony/security-core": "^5.3 || ^6.0"
2626
},
2727
"config": {
2828
"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
phpunit: ~
77
clover_coverage:

src/EventListener/JsonApiProblemExceptionListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Symfony\Component\HttpFoundation\JsonResponse;
1212
use Symfony\Component\HttpFoundation\Response;
1313
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
14+
use Throwable;
1415

1516
class JsonApiProblemExceptionListener
1617
{
@@ -45,7 +46,7 @@ public function onKernelException(ExceptionEvent $event): void
4546
$event->setResponse($this->generateResponse($apiProblem));
4647
}
4748

48-
private function convertExceptionToProblem(\Throwable $exception): ApiProblemInterface
49+
private function convertExceptionToProblem(Throwable $exception): ApiProblemInterface
4950
{
5051
if (!$this->exceptionTransformer->accepts($exception)) {
5152
return new ExceptionApiProblem($exception);

src/Transformer/ApiProblemExceptionTransformer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
use Phpro\ApiProblem\ApiProblemInterface;
88
use Phpro\ApiProblem\Exception\ApiProblemException;
99
use Phpro\ApiProblemBundle\Exception\ApiProblemHttpException;
10+
use Throwable;
1011

1112
class ApiProblemExceptionTransformer implements ExceptionTransformerInterface
1213
{
1314
/**
1415
* @param ApiProblemException|ApiProblemHttpException $exception
1516
*/
16-
public function transform(\Throwable $exception): ApiProblemInterface
17+
public function transform(Throwable $exception): ApiProblemInterface
1718
{
1819
return $exception->getApiProblem();
1920
}
2021

21-
public function accepts(\Throwable $exception): bool
22+
public function accepts(Throwable $exception): bool
2223
{
2324
return $exception instanceof ApiProblemException || $exception instanceof ApiProblemHttpException;
2425
}

src/Transformer/Chain.php

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

77
use Phpro\ApiProblem\ApiProblemInterface;
88
use Phpro\ApiProblem\Http\ExceptionApiProblem;
9+
use Throwable;
910

1011
class Chain implements ExceptionTransformerInterface
1112
{
@@ -21,7 +22,7 @@ public function __construct(iterable $transformers)
2122
}
2223
}
2324

24-
public function transform(\Throwable $exception): ApiProblemInterface
25+
public function transform(Throwable $exception): ApiProblemInterface
2526
{
2627
foreach ($this->transformers as $transformer) {
2728
if ($transformer->accepts($exception)) {
@@ -32,7 +33,7 @@ public function transform(\Throwable $exception): ApiProblemInterface
3233
return new ExceptionApiProblem($exception);
3334
}
3435

35-
public function accepts(\Throwable $exception): bool
36+
public function accepts(Throwable $exception): bool
3637
{
3738
return true;
3839
}

src/Transformer/ExceptionTransformerInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
namespace Phpro\ApiProblemBundle\Transformer;
66

77
use Phpro\ApiProblem\ApiProblemInterface;
8+
use Throwable;
89

910
interface ExceptionTransformerInterface
1011
{
11-
public function transform(\Throwable $exception): ApiProblemInterface;
12+
public function transform(Throwable $exception): ApiProblemInterface;
1213

13-
public function accepts(\Throwable $exception): bool;
14+
public function accepts(Throwable $exception): bool;
1415
}

0 commit comments

Comments
 (0)