Skip to content

Commit 1bb03ea

Browse files
committed
Add PHP8.1 & Symfony 6 support
Signed-off-by: Jelle Deneweth <jelle.deneweth@gmail.com>
1 parent bd53374 commit 1bb03ea

18 files changed

Lines changed: 143 additions & 127 deletions

.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

.php-cs-fixer.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"8.0.13","version":"3.3.2:v3.3.2#06bdbdfcd619183dd7a1a6948360f8af73b9ecec","indent":" ","lineEnding":"\n","rules":{"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"braces":{"allow_single_line_anonymous_class_with_empty_body":true,"allow_single_line_closure":true},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"clean_namespace":true,"concat_space":true,"echo_tag_syntax":{"format":"long"},"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":{"case":"snake_case"},"phpdoc_align":{"align":"left"},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"align_multiline_comment":true,"array_indentation":true,"combine_consecutive_issets":true,"combine_consecutive_unsets":true,"comment_to_phpdoc":true,"date_time_immutable":true,"declare_strict_types":true,"doctrine_annotation_array_assignment":true,"doctrine_annotation_braces":true,"doctrine_annotation_indentation":true,"doctrine_annotation_spaces":true,"escape_implicit_backslashes":true,"explicit_indirect_variable":true,"explicit_string_variable":true,"final_internal_class":true,"list_syntax":{"syntax":"short"},"mb_str_functions":true,"method_chaining_indentation":true,"multiline_comment_opening_closing":true,"multiline_whitespace_before_semicolons":true,"no_null_property_initialization":true,"no_php4_constructor":true,"no_superfluous_elseif":true,"no_unreachable_default_argument_value":true,"no_useless_else":true,"no_useless_return":true,"phpdoc_order_by_value":{"annotations":["covers"]},"php_unit_set_up_tear_down_visibility":true,"phpdoc_add_missing_param_annotation":true,"phpdoc_order":true,"pow_to_exponentiation":true,"psr_autoloading":{"dir":"src"},"simplified_null_return":true,"strict_comparison":true,"strict_param":true,"string_line_ending":true,"ternary_to_null_coalescing":true,"void_return":true,"global_namespace_import":{"import_classes":true,"import_constants":true,"import_functions":true}},"hashes":{"src\/EventListener\/JsonApiProblemExceptionListener.php":3370518202,"src\/Transformer\/HttpExceptionTransformer.php":326027393,"src\/Transformer\/ExceptionTransformerInterface.php":2751164189,"src\/Transformer\/SecurityExceptionTransformer.php":2004785248,"src\/Transformer\/ApiProblemExceptionTransformer.php":4217022154,"src\/Transformer\/Chain.php":673462146,"src\/Exception\/ApiProblemHttpException.php":2140000361,"src\/DependencyInjection\/ApiProblemExtension.php":1581141798,"src\/ApiProblemBundle.php":1382394439,"test\/EventListener\/JsonApiProblemExceptionListenerTest.php":3707063159,"test\/ApiProblemBundleTest.php":2971244330,"test\/Transformer\/ApiProblemExceptionTransformerTest.php":3963316912,"test\/Transformer\/HttpExceptionTransformerTest.php":2380537184,"test\/Transformer\/ChainTest.php":4071150179,"test\/Transformer\/SecurityExceptionTransformerTest.php":219608745,"test\/Exception\/ApiProblemHttpExceptionTest.php":856727078,"test\/DependencyInjection\/ApiProblemExtensionTest.php":2706743894}}

.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)