Skip to content

Commit

Permalink
Migrate PHPUnit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Aug 1, 2023
1 parent 7be7af9 commit 5277d5f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 59 deletions.
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

28 changes: 17 additions & 11 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
Expand All @@ -8,14 +10,15 @@
'array_syntax' => ['syntax' => 'short'],
'assign_null_coalescing_to_coalesce_equal' => true,
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => ['operators' => ['=' => 'align', 'xor' => null, '+=' => 'align_single_space', '===' => 'align_single_space_minimal', '|' => 'single_space', '=>' => 'align_single_space_minimal_by_scope']],
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'blank_line_between_import_groups' => true,
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['const' => 'only_if_meta', 'method' => 'one', 'property' => 'only_if_meta', 'trait_import' => 'one', 'case' => 'one']],
'class_definition' => true,
'class_attributes_separation' => ['elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one', 'trait_import' => 'one', 'case' => 'one']],
'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],
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
Expand All @@ -25,7 +28,9 @@
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => ['case' => 'lower'],
'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],
'date_time_create_from_format_call' => true,
'date_time_immutable' => true,
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
Expand All @@ -46,6 +51,7 @@
'explicit_string_variable' => true,
'final_class' => true,
'final_internal_class' => true,
'final_public_method_for_abstract_class' => true,
'fopen_flag_order' => true,
'fopen_flags' => true,
'full_opening_tag' => true,
Expand Down Expand Up @@ -76,8 +82,8 @@
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'mb_str_functions' => true,
'method_argument_space' => true,
'mb_str_functions' => false,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline', 'after_heredoc' => true],
'method_chaining_indentation' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
Expand Down Expand Up @@ -138,7 +144,7 @@
'object_operator_without_whitespace' => true,
'octal_notation' => true,
'operator_linebreak' => true,
'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']],
'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']],
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']],
'ordered_interfaces' => true,
'ordered_traits' => true,
Expand Down Expand Up @@ -191,6 +197,7 @@
'single_line_throw' => true,
'single_quote' => true,
'single_space_after_construct' => true,
'single_space_around_construct' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true,
'standardize_increment' => true,
Expand All @@ -207,9 +214,9 @@
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'parameters']],
'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['arguments', 'arrays', 'match', 'parameters']],
'trim_array_spaces' => true,
'types_spaces' => ['space' => 'single'],
'types_spaces' => ['space' => 'single', 'space_multiple_catch' => 'single'],
'unary_operator_spaces' => true,
'use_arrow_functions' => true,
'visibility_required' => true,
Expand All @@ -220,6 +227,5 @@
->setFinder(
PhpCsFixer\Finder::create()
->exclude('vendor')
->in([__DIR__.'/src/'])
)
;
->in([__DIR__ . '/src/']),
);
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.14",
"infection/infection": "^0.26",
"mockery/mockery": "^1.5",
"pestphp/pest": "^2.0",
"phpstan/phpstan": "^1.10",
Expand Down
11 changes: 0 additions & 11 deletions infection.json5.dist

This file was deleted.

43 changes: 21 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>

<exclude>
<directory suffix=".php">./src/Contracts</directory>
<directory suffix=".php">./src/Exceptions</directory>
</exclude>

<report>
<clover outputFile="coverage/clover.xml" />
<cobertura outputFile="coverage/cobertura.xml"/>
</report>
</coverage>

<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd">
<coverage>
<report>
<clover outputFile="coverage/clover.xml"/>
<cobertura outputFile="coverage/cobertura.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
<exclude>
<directory suffix=".php">./src/Contracts</directory>
<directory suffix=".php">./src/Exceptions</directory>
</exclude>
</source>
</phpunit>
19 changes: 11 additions & 8 deletions src/Implementations/Psr3/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

final class Logs extends Implementation implements LogsContract
{
private static ?CandidatesCollection $candidates = null;
private static ?CandidatesCollection $candidates = null;

private static ?CandidatesCollection $extendedCandidates = null;
private static ?LoggerInterface $singleton = null;
private static ?LoggerInterface $using = null;

private static ?LoggerInterface $singleton = null;

private static ?LoggerInterface $using = null;

public static function add(CandidateEntity $candidate): void
{
Expand All @@ -29,7 +32,7 @@ public static function add(CandidateEntity $candidate): void
*/
public static function allCandidates(): CandidatesCollection
{
if (null !== self::$extendedCandidates) {
if (self::$extendedCandidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
return self::$extendedCandidates;
}

Expand Down Expand Up @@ -62,7 +65,7 @@ public static function allCandidates(): CandidatesCollection
*/
public static function candidates(): CandidatesCollection
{
if (null !== self::$candidates) {
if (self::$candidates instanceof \PsrDiscovery\Collections\CandidatesCollection) {
return self::$candidates;
}

Expand Down Expand Up @@ -118,7 +121,7 @@ public static function candidates(): CandidatesCollection
*/
public static function discover(): ?LoggerInterface
{
if (null !== self::$using) {
if (self::$using instanceof \Psr\Log\LoggerInterface) {
return self::$using;
}

Expand Down Expand Up @@ -146,7 +149,7 @@ public static function set(CandidatesCollection $candidates): void

public static function singleton(): ?LoggerInterface
{
if (null !== self::$using) {
if (self::$using instanceof \Psr\Log\LoggerInterface) {
return self::$using;
}

Expand All @@ -156,6 +159,6 @@ public static function singleton(): ?LoggerInterface
public static function use(?LoggerInterface $instance): void
{
self::$singleton = $instance;
self::$using = $instance;
self::$using = $instance;
}
}

0 comments on commit 5277d5f

Please sign in to comment.