Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Enhancement: Use Php73 rule set #531

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ $license = License\Type\MIT::markdown(
__DIR__ . '/LICENSE.md',
License\Range::since(
License\Year::fromString('2017'),
new \DateTimeZone('UTC')
new \DateTimeZone('UTC'),
),
License\Holder::fromString('Andreas Möller'),
License\Url::fromString('https://github.com/ergebnis/test-util')
License\Url::fromString('https://github.com/ergebnis/test-util'),
);

$license->save();

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php71($license->header()), [
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php73($license->header()), [
'strict_comparison' => false,
]);

Expand Down
2 changes: 1 addition & 1 deletion .php_cs.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare(strict_types=1);

use Ergebnis\PhpCsFixer;

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php71(''), [
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php73(''), [
'final_class' => false,
]);

Expand Down
22 changes: 11 additions & 11 deletions src/DataProvider/StringProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ private static function values(): array
\array_map(static function (string $key): string {
return \sprintf(
'string-blank-%s',
$key
$key,
);
}, \array_keys($whitespaceCharacters)),
$whitespaceCharacters
$whitespaceCharacters,
);

$emptyValues = [
Expand All @@ -119,31 +119,31 @@ private static function values(): array
\array_map(static function (string $key): string {
return \sprintf(
'string-untrimmed-%s',
$key
$key,
);
}, \array_keys($whitespaceCharacters)),
\array_map(static function (string $whitespaceCharacter) use ($faker): string {
return \sprintf(
'%s%s%s',
\str_repeat(
$whitespaceCharacter,
$faker->numberBetween(1, 5)
$faker->numberBetween(1, 5),
),
$faker->word(),
\str_repeat(
$whitespaceCharacter,
$faker->numberBetween(1, 5)
)
$faker->numberBetween(1, 5),
),
);
}, $whitespaceCharacters)
}, $whitespaceCharacters),
);

/** @var array<string, string> $withWhitespaceValues */
$withWhitespaceValues = \array_combine(
\array_map(static function (string $key): string {
return \sprintf(
'string-with-whitespace-%s',
$key
$key,
);
}, \array_keys($whitespaceCharacters)),
\array_map(static function (string $whitespaceCharacter) use ($faker): string {
Expand All @@ -152,17 +152,17 @@ private static function values(): array

return \implode(
$whitespaceCharacter,
$words
$words,
);
}, $whitespaceCharacters)
}, $whitespaceCharacters),
);

return \array_merge(
$arbitraryValues,
$blankValues,
$emptyValues,
$untrimmedValues,
$withWhitespaceValues
$withWhitespaceValues,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidExcludeClassName.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function fromClassName($className): self
{
return new self(\sprintf(
'Exclude class name should be a string, got "%s" instead.',
\is_object($className) ? \get_class($className) : \gettype($className)
\is_object($className) ? \get_class($className) : \gettype($className),
));
}
}
2 changes: 1 addition & 1 deletion src/Exception/NonExistentDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function fromDirectory(string $directory): self
{
return new self(\sprintf(
'Directory "%s" does not exist.',
$directory
$directory,
));
}
}
2 changes: 1 addition & 1 deletion src/Exception/NonExistentExcludeClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function fromClassName(string $className): self
{
return new self(\sprintf(
'Exclude class "%s" does not exist.',
$className
$className,
));
}
}
40 changes: 20 additions & 20 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static function (string $className): bool {
},
$directory,
$excludeClassNames,
"Failed asserting that the classes\n\n%s\n\nare abstract or final."
"Failed asserting that the classes\n\n%s\n\nare abstract or final.",
);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ final protected static function assertClassesHaveTests(string $directory, string
\array_map(static function (Classy\Construct $construct): string {
return $construct->name();
}, $constructs),
$excludeClassyNames
$excludeClassyNames,
);

$namespace = \rtrim($namespace, '\\') . '\\';
Expand All @@ -125,7 +125,7 @@ final protected static function assertClassesHaveTests(string $directory, string
return \str_replace(
$namespace,
$testNamespace,
$className
$className,
) . 'Test';
};

Expand Down Expand Up @@ -166,16 +166,16 @@ final protected static function assertClassesHaveTests(string $directory, string
\implode("\n", \array_map(static function (string $className): string {
return \sprintf(
' - %s',
$className
$className,
);
}, $classesWithoutTests)),
\implode("\n", \array_map(static function (string $className) use ($testClassNameFrom): string {
return \sprintf(
' - %s',
$testClassNameFrom($className)
$testClassNameFrom($className),
);
}, $classesWithoutTests)),
Framework\TestCase::class
Framework\TestCase::class,
));
}

Expand Down Expand Up @@ -217,7 +217,7 @@ final protected static function assertClassyConstructsSatisfySpecification(calla

$classyNames = \array_diff(
$constructs,
$excludeClassyNames
$excludeClassyNames,
);

$classyNamesNotSatisfyingSpecification = \array_filter($classyNames, static function (string $className) use ($specification): bool {
Expand All @@ -226,7 +226,7 @@ final protected static function assertClassyConstructsSatisfySpecification(calla

self::assertEmpty($classyNamesNotSatisfyingSpecification, \sprintf(
'' !== $message ? $message : "Failed asserting that the classy constructs\n\n%s\n\nsatisfy a specification.",
' - ' . \implode("\n - ", $classyNamesNotSatisfyingSpecification)
' - ' . \implode("\n - ", $classyNamesNotSatisfyingSpecification),
));
}

Expand All @@ -237,7 +237,7 @@ final protected static function assertClassExists(string $className): void
{
self::assertTrue(\class_exists($className), \sprintf(
'Failed asserting that a class "%s" exists.',
$className
$className,
));
}

Expand All @@ -261,7 +261,7 @@ final protected static function assertClassExtends(string $parentClassName, stri
self::assertTrue($reflection->isSubclassOf($parentClassName), \sprintf(
'Failed asserting that class "%s" extends "%s".',
$className,
$parentClassName
$parentClassName,
));
}

Expand All @@ -285,7 +285,7 @@ final protected static function assertClassImplementsInterface(string $interface
self::assertTrue($reflection->implementsInterface($interfaceName), \sprintf(
'Failed asserting that class "%s" implements interface "%s".',
$className,
$interfaceName
$interfaceName,
));
}

Expand All @@ -305,7 +305,7 @@ final protected static function assertClassIsAbstract(string $className): void

self::assertTrue($reflection->isAbstract(), \sprintf(
'Failed asserting that class "%s" is abstract.',
$className
$className,
));
}

Expand All @@ -327,7 +327,7 @@ final protected static function assertClassIsFinal(string $className): void

self::assertTrue($reflection->isFinal(), \sprintf(
'Failed asserting that class "%s" is final.',
$className
$className,
));
}

Expand All @@ -347,7 +347,7 @@ final protected static function assertClassSatisfiesSpecification(callable $spec

self::assertTrue($specification($className), \sprintf(
'' !== $message ? $message : 'Failed asserting that class "%s" satisfies a specification.',
$className
$className,
));
}

Expand All @@ -368,7 +368,7 @@ final protected static function assertClassUsesTrait(string $traitName, string $
self::assertContains($traitName, \class_uses($className), \sprintf(
'Failed asserting that class "%s" uses trait "%s".',
$className,
$traitName
$traitName,
));
}

Expand All @@ -379,7 +379,7 @@ final protected static function assertInterfaceExists(string $interfaceName): vo
{
self::assertTrue(\interface_exists($interfaceName), \sprintf(
'Failed asserting that an interface "%s" exists.',
$interfaceName
$interfaceName,
));
}

Expand All @@ -403,7 +403,7 @@ final protected static function assertInterfaceExtends(string $parentInterfaceNa
self::assertTrue($reflection->isSubclassOf($parentInterfaceName), \sprintf(
'Failed asserting that interface "%s" extends "%s".',
$interfaceName,
$parentInterfaceName
$parentInterfaceName,
));
}

Expand All @@ -423,7 +423,7 @@ final protected static function assertInterfaceSatisfiesSpecification(callable $

self::assertTrue($specification($interfaceName), \sprintf(
'' !== $message ? $message : 'Failed asserting that interface "%s" satisfies a specification.',
$interfaceName
$interfaceName,
));
}

Expand All @@ -434,7 +434,7 @@ final protected static function assertTraitExists(string $traitName): void
{
self::assertTrue(\trait_exists($traitName), \sprintf(
'Failed asserting that a trait "%s" exists.',
$traitName
$traitName,
));
}

Expand All @@ -454,7 +454,7 @@ final protected static function assertTraitSatisfiesSpecification(callable $spec

self::assertTrue($specification($traitName), \sprintf(
'' !== $message ? $message : 'Failed asserting that trait "%s" satisfies a specification.',
$traitName
$traitName,
));
}

Expand Down
18 changes: 9 additions & 9 deletions test/Unit/DataProvider/AbstractProviderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final protected static function assertProvidesDataSetsForValues(array $values, \
self::assertEquals(
$expectedDataSets,
$actualDataSets,
'Failed asserting that a generator yields data sets for the expected values.'
'Failed asserting that a generator yields data sets for the expected values.',
);
}

Expand All @@ -53,7 +53,7 @@ final protected static function assertProvidesDataSetsForValuesSatisfyingSpecifi
'string',
\array_keys($specifications),
true,
'Failed asserting that the keys of specifications are all strings.'
'Failed asserting that the keys of specifications are all strings.',
);

self::assertContainsOnly(
Expand All @@ -62,16 +62,16 @@ final protected static function assertProvidesDataSetsForValuesSatisfyingSpecifi
false,
\sprintf(
'Failed asserting that the values of specifications implement "%s".',
Util\Test\Util\DataProvider\Specification\Specification::class
)
Util\Test\Util\DataProvider\Specification\Specification::class,
),
);

$dataSets = \iterator_to_array($provider);

self::assertEquals(
\array_keys($specifications),
\array_keys($dataSets),
'Failed asserting that the provided data has the same keys as the specifications.'
'Failed asserting that the provided data has the same keys as the specifications.',
);

$keysForDataSetsWhereValueDoesNotSatisfySpecification = \array_filter(\array_keys($dataSets), static function (string $key) use ($dataSets, $specifications): bool {
Expand All @@ -82,12 +82,12 @@ final protected static function assertProvidesDataSetsForValuesSatisfyingSpecifi

self::assertIsArray($dataSet, \sprintf(
'Failed asserting that the data set provided for key "%s" is an array.',
$key
$key,
));

self::assertCount(1, $dataSet, \sprintf(
'Failed asserting that the data set provided for key "%s" contains only one value.',
$key
$key,
));

$value = \array_shift($dataSet);
Expand All @@ -99,8 +99,8 @@ final protected static function assertProvidesDataSetsForValuesSatisfyingSpecifi
'Failed asserting that the value for the data sets with the keys "%s" satisfy the corresponding requirements.',
\implode(
'", "',
$keysForDataSetsWhereValueDoesNotSatisfySpecification
)
$keysForDataSetsWhereValueDoesNotSatisfySpecification,
),
));
}

Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Exception/InvalidExcludeClassNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testFromClassNameReturnsException($className): void

$message = \sprintf(
'Exclude class name should be a string, got "%s" instead.',
\is_object($className) ? \get_class($className) : \gettype($className)
\is_object($className) ? \get_class($className) : \gettype($className),
);

self::assertSame($message, $exception->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Exception/NonExistentDirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testFromDirectoryReturnsException(): void

$message = \sprintf(
'Directory "%s" does not exist.',
$directory
$directory,
);

self::assertSame($message, $exception->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Exception/NonExistentExcludeClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testFromClassNameReturnsException(): void

$message = \sprintf(
'Exclude class "%s" does not exist.',
$className
$className,
);

self::assertSame($message, $exception->getMessage());
Expand Down
Loading