Skip to content

Commit 66b9858

Browse files
committed
Migrate PHPUnit configuration
1 parent 064bb0e commit 66b9858

File tree

8 files changed

+71
-75
lines changed

8 files changed

+71
-75
lines changed

.github/dependabot.yml

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

.php-cs-fixer.dist.php

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

3+
declare(strict_types=1);
4+
35
return (new PhpCsFixer\Config())
46
->setRiskyAllowed(true)
57
->setRules([
@@ -8,14 +10,15 @@
810
'array_syntax' => ['syntax' => 'short'],
911
'assign_null_coalescing_to_coalesce_equal' => true,
1012
'backtick_to_shell_exec' => true,
11-
'binary_operator_spaces' => ['operators' => ['=' => 'align', 'xor' => null, '+=' => 'align_single_space', '===' => 'align_single_space_minimal', '|' => 'single_space', '=>' => 'align_single_space_minimal_by_scope']],
13+
'binary_operator_spaces' => true,
1214
'blank_line_after_namespace' => true,
1315
'blank_line_after_opening_tag' => true,
1416
'blank_line_before_statement' => true,
17+
'blank_line_between_import_groups' => true,
1518
'braces' => true,
1619
'cast_spaces' => true,
17-
'class_attributes_separation' => ['elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'only_if_meta', 'trait_import' => 'one', 'case' => 'one']],
18-
'class_definition' => true,
20+
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one', 'trait_import' => 'one', 'case' => 'one']],
21+
'class_definition' => ['multi_line_extends_each_single_line' => true, 'single_line' => true, 'single_item_single_line' => true, 'space_before_parenthesis' => false, 'inline_constructor_arguments' => false],
1922
'class_reference_name_casing' => true,
2023
'clean_namespace' => true,
2124
'combine_consecutive_issets' => true,
@@ -25,7 +28,9 @@
2528
'compact_nullable_typehint' => true,
2629
'concat_space' => ['spacing' => 'one'],
2730
'constant_case' => ['case' => 'lower'],
31+
'curly_braces_position' => ['control_structures_opening_brace' => 'same_line', 'functions_opening_brace' => 'next_line_unless_newline_at_signature_end', 'anonymous_functions_opening_brace' => 'same_line', 'classes_opening_brace' => 'next_line_unless_newline_at_signature_end', 'anonymous_classes_opening_brace' => 'same_line', 'allow_single_line_empty_anonymous_classes' => true, 'allow_single_line_anonymous_functions' => true],
2832
'date_time_create_from_format_call' => true,
33+
'date_time_immutable' => true,
2934
'declare_equal_normalize' => ['space' => 'none'],
3035
'declare_parentheses' => true,
3136
'declare_strict_types' => true,
@@ -46,6 +51,7 @@
4651
'explicit_string_variable' => true,
4752
'final_class' => true,
4853
'final_internal_class' => true,
54+
'final_public_method_for_abstract_class' => true,
4955
'fopen_flag_order' => true,
5056
'fopen_flags' => true,
5157
'full_opening_tag' => true,
@@ -76,8 +82,8 @@
7682
'lowercase_static_reference' => true,
7783
'magic_constant_casing' => true,
7884
'magic_method_casing' => true,
79-
'mb_str_functions' => true,
80-
'method_argument_space' => true,
85+
'mb_str_functions' => false,
86+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'after_heredoc' => true],
8187
'method_chaining_indentation' => true,
8288
'modernize_strpos' => true,
8389
'modernize_types_casting' => true,
@@ -138,7 +144,7 @@
138144
'object_operator_without_whitespace' => true,
139145
'octal_notation' => true,
140146
'operator_linebreak' => true,
141-
'ordered_class_elements' => ['sort_algorithm' => 'alpha', 'order' => ['use_trait', 'case', 'constant', 'constant_private', 'constant_protected', 'constant_public', 'property_private', 'property_private_readonly', 'property_private_static', 'property_protected', 'property_protected_readonly', 'property_protected_static', 'property_public', 'property_public_readonly', 'property_public_static', 'property_static', 'protected', 'construct', 'destruct', 'magic', 'method', 'public', 'method_abstract', 'method_private', 'method_private_abstract', 'method_private_abstract_static', 'method_private_static', 'method_protected', 'method_protected_abstract', 'method_protected_abstract_static', 'method_protected_static', 'method_public', 'method_public_abstract', 'method_public_abstract_static', 'method_public_static', 'method_static', 'phpunit', 'private', 'property']],
147+
'ordered_class_elements' => ['sort_algorithm' => 'alpha', 'order' => ['use_trait', 'case', 'constant', 'constant_private', 'constant_protected', 'constant_public', 'property_private', 'property_private_readonly', 'property_private_static', 'property_protected', 'property_protected_readonly', 'property_protected_static', 'property_public', 'property_public_readonly', 'property_public_static', 'property_static', 'protected', 'construct', 'destruct', 'magic', 'method', 'public', 'method_public', 'method_abstract', 'method_public_abstract', 'method_public_abstract_static', 'method_public_static', 'method_static', 'method_private', 'method_private_abstract', 'method_private_abstract_static', 'method_private_static', 'method_protected', 'method_protected_abstract', 'method_protected_abstract_static', 'method_protected_static', 'phpunit', 'private', 'property']],
142148
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
143149
'ordered_interfaces' => true,
144150
'ordered_traits' => true,
@@ -191,6 +197,7 @@
191197
'single_line_throw' => true,
192198
'single_quote' => true,
193199
'single_space_after_construct' => true,
200+
'single_space_around_construct' => true,
194201
'single_trait_insert_per_statement' => true,
195202
'space_after_semicolon' => true,
196203
'standardize_increment' => true,
@@ -207,9 +214,9 @@
207214
'ternary_operator_spaces' => true,
208215
'ternary_to_elvis_operator' => true,
209216
'ternary_to_null_coalescing' => true,
210-
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'parameters']],
217+
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'arrays', 'match', 'parameters']],
211218
'trim_array_spaces' => true,
212-
'types_spaces' => ['space' => 'single'],
219+
'types_spaces' => ['space' => 'single', 'space_multiple_catch' => 'single'],
213220
'unary_operator_spaces' => true,
214221
'use_arrow_functions' => true,
215222
'visibility_required' => true,
@@ -220,6 +227,5 @@
220227
->setFinder(
221228
PhpCsFixer\Finder::create()
222229
->exclude('vendor')
223-
->in([__DIR__.'/src/'])
224-
)
225-
;
230+
->in([__DIR__ . '/src/']),
231+
);

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
},
2424
"require-dev": {
2525
"friendsofphp/php-cs-fixer": "^3.14",
26-
"infection/infection": "^0.26",
2726
"mockery/mockery": "^1.5",
2827
"pestphp/pest": "^2.0",
2928
"phpstan/phpstan": "^1.10",

infection.json5.dist

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

phpunit.xml.dist

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">./src/</directory>
6-
</include>
7-
8-
<exclude>
9-
<directory suffix=".php">./src/Contracts</directory>
10-
<directory suffix=".php">./src/Exceptions</directory>
11-
</exclude>
12-
13-
<report>
14-
<clover outputFile="coverage/clover.xml" />
15-
<cobertura outputFile="coverage/cobertura.xml"/>
16-
</report>
17-
</coverage>
18-
19-
<testsuites>
20-
<testsuite name="unit">
21-
<directory>tests/Unit</directory>
22-
</testsuite>
23-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd">
3+
<coverage>
4+
<report>
5+
<clover outputFile="coverage/clover.xml"/>
6+
<cobertura outputFile="coverage/cobertura.xml"/>
7+
</report>
8+
</coverage>
9+
<testsuites>
10+
<testsuite name="unit">
11+
<directory>tests/Unit</directory>
12+
</testsuite>
13+
</testsuites>
14+
<source>
15+
<include>
16+
<directory suffix=".php">./src/</directory>
17+
</include>
18+
<exclude>
19+
<directory suffix=".php">./src/Contracts</directory>
20+
<directory suffix=".php">./src/Exceptions</directory>
21+
</exclude>
22+
</source>
2423
</phpunit>

src/Implementations/Psr17/RequestFactories.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
final class RequestFactories extends Implementation implements RequestFactoriesContract
1515
{
16-
private static ?CandidatesCollection $candidates = null;
16+
private static ?CandidatesCollection $candidates = null;
17+
1718
private static ?CandidatesCollection $extendedCandidates = null;
18-
private static ?RequestFactoryInterface $singleton = null;
19-
private static ?RequestFactoryInterface $using = null;
19+
20+
private static ?RequestFactoryInterface $singleton = null;
21+
22+
private static ?RequestFactoryInterface $using = null;
2023

2124
public static function add(CandidateEntity $candidate): void
2225
{
@@ -30,7 +33,7 @@ public static function add(CandidateEntity $candidate): void
3033
*/
3134
public static function allCandidates(): CandidatesCollection
3235
{
33-
if (null !== self::$extendedCandidates) {
36+
if (self::$extendedCandidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
3437
return self::$extendedCandidates;
3538
}
3639

@@ -45,7 +48,7 @@ public static function allCandidates(): CandidatesCollection
4548
*/
4649
public static function candidates(): CandidatesCollection
4750
{
48-
if (null !== self::$candidates) {
51+
if (self::$candidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
4952
return self::$candidates;
5053
}
5154

@@ -131,7 +134,7 @@ public static function candidates(): CandidatesCollection
131134
*/
132135
public static function discover(): ?RequestFactoryInterface
133136
{
134-
if (null !== self::$using) {
137+
if (self::$using instanceof \Psr\Http\Message\RequestFactoryInterface) {
135138
return self::$using;
136139
}
137140

@@ -159,7 +162,7 @@ public static function set(CandidatesCollection $candidates): void
159162

160163
public static function singleton(): ?RequestFactoryInterface
161164
{
162-
if (null !== self::$using) {
165+
if (self::$using instanceof \Psr\Http\Message\RequestFactoryInterface) {
163166
return self::$using;
164167
}
165168

@@ -169,6 +172,6 @@ public static function singleton(): ?RequestFactoryInterface
169172
public static function use(?RequestFactoryInterface $instance): void
170173
{
171174
self::$singleton = $instance;
172-
self::$using = $instance;
175+
self::$using = $instance;
173176
}
174177
}

src/Implementations/Psr17/ResponseFactories.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
final class ResponseFactories extends Implementation implements ResponseFactoriesContract
1515
{
16-
private static ?CandidatesCollection $candidates = null;
16+
private static ?CandidatesCollection $candidates = null;
17+
1718
private static ?CandidatesCollection $extendedCandidates = null;
18-
private static ?ResponseFactoryInterface $singleton = null;
19-
private static ?ResponseFactoryInterface $using = null;
19+
20+
private static ?ResponseFactoryInterface $singleton = null;
21+
22+
private static ?ResponseFactoryInterface $using = null;
2023

2124
public static function add(CandidateEntity $candidate): void
2225
{
@@ -30,7 +33,7 @@ public static function add(CandidateEntity $candidate): void
3033
*/
3134
public static function allCandidates(): CandidatesCollection
3235
{
33-
if (null !== self::$extendedCandidates) {
36+
if (self::$extendedCandidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
3437
return self::$extendedCandidates;
3538
}
3639

@@ -45,7 +48,7 @@ public static function allCandidates(): CandidatesCollection
4548
*/
4649
public static function candidates(): CandidatesCollection
4750
{
48-
if (null !== self::$candidates) {
51+
if (self::$candidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
4952
return self::$candidates;
5053
}
5154

@@ -131,7 +134,7 @@ public static function candidates(): CandidatesCollection
131134
*/
132135
public static function discover(): ?ResponseFactoryInterface
133136
{
134-
if (null !== self::$using) {
137+
if (self::$using instanceof \Psr\Http\Message\ResponseFactoryInterface) {
135138
return self::$using;
136139
}
137140

@@ -159,7 +162,7 @@ public static function set(CandidatesCollection $candidates): void
159162

160163
public static function singleton(): ?ResponseFactoryInterface
161164
{
162-
if (null !== self::$using) {
165+
if (self::$using instanceof \Psr\Http\Message\ResponseFactoryInterface) {
163166
return self::$using;
164167
}
165168

@@ -169,6 +172,6 @@ public static function singleton(): ?ResponseFactoryInterface
169172
public static function use(?ResponseFactoryInterface $instance): void
170173
{
171174
self::$singleton = $instance;
172-
self::$using = $instance;
175+
self::$using = $instance;
173176
}
174177
}

src/Implementations/Psr17/StreamFactories.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
final class StreamFactories extends Implementation implements StreamFactoriesContract
1515
{
16-
private static ?CandidatesCollection $candidates = null;
16+
private static ?CandidatesCollection $candidates = null;
17+
1718
private static ?CandidatesCollection $extendedCandidates = null;
18-
private static ?StreamFactoryInterface $singleton = null;
19-
private static ?StreamFactoryInterface $using = null;
19+
20+
private static ?StreamFactoryInterface $singleton = null;
21+
22+
private static ?StreamFactoryInterface $using = null;
2023

2124
public static function add(CandidateEntity $candidate): void
2225
{
@@ -30,7 +33,7 @@ public static function add(CandidateEntity $candidate): void
3033
*/
3134
public static function allCandidates(): CandidatesCollection
3235
{
33-
if (null !== self::$extendedCandidates) {
36+
if (self::$extendedCandidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
3437
return self::$extendedCandidates;
3538
}
3639

@@ -45,7 +48,7 @@ public static function allCandidates(): CandidatesCollection
4548
*/
4649
public static function candidates(): CandidatesCollection
4750
{
48-
if (null !== self::$candidates) {
51+
if (self::$candidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
4952
return self::$candidates;
5053
}
5154

@@ -131,7 +134,7 @@ public static function candidates(): CandidatesCollection
131134
*/
132135
public static function discover(): ?StreamFactoryInterface
133136
{
134-
if (null !== self::$using) {
137+
if (self::$using instanceof \Psr\Http\Message\StreamFactoryInterface) {
135138
return self::$using;
136139
}
137140

@@ -159,7 +162,7 @@ public static function set(CandidatesCollection $candidates): void
159162

160163
public static function singleton(): ?StreamFactoryInterface
161164
{
162-
if (null !== self::$using) {
165+
if (self::$using instanceof \Psr\Http\Message\StreamFactoryInterface) {
163166
return self::$using;
164167
}
165168

@@ -169,6 +172,6 @@ public static function singleton(): ?StreamFactoryInterface
169172
public static function use(?StreamFactoryInterface $instance): void
170173
{
171174
self::$singleton = $instance;
172-
self::$using = $instance;
175+
self::$using = $instance;
173176
}
174177
}

0 commit comments

Comments
 (0)