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

Commit

Permalink
Fix: Annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Mar 11, 2020
1 parent 3a2c8d8 commit 257d495
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ trait Helper
*/
final protected static function faker(string $locale = 'en_US'): Generator
{
/**
* @var array<string, Generator>
*/
static $fakers = [];

if (!\array_key_exists($locale, $fakers)) {
Expand All @@ -51,8 +54,8 @@ final protected static function faker(string $locale = 'en_US'): Generator
*
* Useful to prevent long inheritance chains.
*
* @param string $directory
* @param string[] $excludeClassNames
* @param string $directory
* @param class-string[] $excludeClassNames
*
* @throws Exception\NonExistentDirectory
* @throws Exception\InvalidExcludeClassName
Expand Down Expand Up @@ -80,10 +83,10 @@ static function (string $className): bool {
/**
* Asserts that classes in a directory have matching test classes extending from PHPUnit\Framework\TestCase.
*
* @param string $directory
* @param string $namespace
* @param string $testNamespace
* @param string[] $excludeClassyNames
* @param string $directory
* @param string $namespace
* @param string $testNamespace
* @param class-string[] $excludeClassyNames
*
* @throws Exception\NonExistentDirectory
* @throws Exception\InvalidExcludeClassName
Expand Down Expand Up @@ -128,6 +131,7 @@ final protected static function assertClassesHaveTests(string $directory, string
};

$classesWithoutTests = \array_filter($classyNames, static function (string $className) use ($testClassNameFrom): bool {
/** @var class-string $className */
$reflection = new \ReflectionClass($className);

/**
Expand All @@ -147,6 +151,7 @@ final protected static function assertClassesHaveTests(string $directory, string
$testClassName = $testClassNameFrom($className);

if (\class_exists($testClassName)) {
/** @var class-string $testClassName */
$testReflection = new \ReflectionClass($testClassName);

if ($testReflection->isSubclassOf(Framework\TestCase::class) && $testReflection->isInstantiable()) {
Expand Down Expand Up @@ -182,10 +187,10 @@ final protected static function assertClassesHaveTests(string $directory, string
*
* The specification will be invoked with a single argument, the class name, and should return true or false.
*
* @param callable $specification
* @param string $directory
* @param string[] $excludeClassyNames
* @param string $message
* @param callable $specification
* @param string $directory
* @param class-string[] $excludeClassyNames
* @param string $message
*
* @throws Exception\NonExistentDirectory
* @throws Exception\InvalidExcludeClassName
Expand Down Expand Up @@ -241,8 +246,8 @@ final protected static function assertClassExists(string $className): void
/**
* Asserts that a class extends from a parent class.
*
* @param string $parentClassName
* @param string $className
* @param class-string $parentClassName
* @param class-string $className
*/
final protected static function assertClassExtends(string $parentClassName, string $className): void
{
Expand All @@ -262,8 +267,8 @@ final protected static function assertClassExtends(string $parentClassName, stri
/**
* Asserts that a class implements an interface.
*
* @param string $interfaceName
* @param string $className
* @param class-string $interfaceName
* @param class-string $className
*/
final protected static function assertClassImplementsInterface(string $interfaceName, string $className): void
{
Expand All @@ -283,7 +288,7 @@ final protected static function assertClassImplementsInterface(string $interface
/**
* Asserts that a class is abstract.
*
* @param string $className
* @param class-string $className
*/
final protected static function assertClassIsAbstract(string $className): void
{
Expand All @@ -303,7 +308,7 @@ final protected static function assertClassIsAbstract(string $className): void
*
* Useful to prevent long inheritance chains.
*
* @param string $className
* @param class-string $className
*/
final protected static function assertClassIsFinal(string $className): void
{
Expand All @@ -323,9 +328,9 @@ final protected static function assertClassIsFinal(string $className): void
*
* The specification will be invoked with a single argument, the class name, and should return true or false.
*
* @param callable $specification
* @param string $className
* @param string $message
* @param callable(class-string):bool $specification
* @param class-string $className
* @param string $message
*/
final protected static function assertClassSatisfiesSpecification(callable $specification, string $className, string $message = ''): void
{
Expand All @@ -340,8 +345,8 @@ final protected static function assertClassSatisfiesSpecification(callable $spec
/**
* Asserts that a class uses a trait.
*
* @param string $traitName
* @param string $className
* @param class-string $traitName
* @param class-string $className
*/
final protected static function assertClassUsesTrait(string $traitName, string $className): void
{
Expand Down Expand Up @@ -371,8 +376,8 @@ final protected static function assertInterfaceExists(string $interfaceName): vo
/**
* Asserts that an interface extends a parent interface.
*
* @param string $parentInterfaceName
* @param string $interfaceName
* @param class-string $parentInterfaceName
* @param class-string $interfaceName
*/
final protected static function assertInterfaceExtends(string $parentInterfaceName, string $interfaceName): void
{
Expand All @@ -394,9 +399,9 @@ final protected static function assertInterfaceExtends(string $parentInterfaceNa
*
* The specification will be invoked with a single argument, the class name, and should return true or false.
*
* @param callable $specification
* @param string $interfaceName
* @param string $message
* @param callable(class-string):bool $specification
* @param class-string $interfaceName
* @param string $message
*/
final protected static function assertInterfaceSatisfiesSpecification(callable $specification, string $interfaceName, string $message = ''): void
{
Expand Down Expand Up @@ -426,9 +431,9 @@ final protected static function assertTraitExists(string $traitName): void
*
* The specification will be invoked with a single argument, the class name, and should return true or false.
*
* @param callable $specification
* @param string $traitName
* @param string $message
* @param callable(class-string):bool $specification
* @param class-string $traitName
* @param string $message
*/
final protected static function assertTraitSatisfiesSpecification(callable $specification, string $traitName, string $message = ''): void
{
Expand Down

0 comments on commit 257d495

Please sign in to comment.