refactor: comments

This commit is contained in:
Nuno Maduro
2021-10-24 19:37:29 +01:00
parent 2b687a7269
commit 648c6c5a27
32 changed files with 151 additions and 133 deletions

View File

@ -14,13 +14,13 @@ trait Expectable
/**
* @template TValue
*
* Creates a new expectation.
* Creates a new Expectation.
*
* @param TValue $value
*
* @return Expectation<TValue>
*/
public function expect($value): Expectation
public function expect(mixed $value): Expectation
{
return new Expectation($value);
}

View File

@ -13,12 +13,14 @@ use Closure;
trait Extendable
{
/**
* The list of extends.
*
* @var array<string, Closure>
*/
private static array $extends = [];
/**
* Register a custom extend.
* Register a new extend.
*/
public static function extend(string $name, Closure $extend): void
{
@ -26,7 +28,7 @@ trait Extendable
}
/**
* Checks if extend is registered.
* Checks if given extend name is registered.
*/
public static function hasExtend(string $name): bool
{
@ -37,10 +39,8 @@ trait Extendable
* Dynamically handle calls to the class.
*
* @param array<int, mixed> $parameters
*
* @return mixed
*/
public function __call(string $method, array $parameters)
public function __call(string $method, array $parameters): mixed
{
if (!static::hasExtend($method)) {
throw new BadMethodCallException("$method is not a callable method name.");

View File

@ -9,21 +9,33 @@ namespace Pest\Concerns\Logging;
*/
trait WritesToConsole
{
/**
* Writes the given success message to the console.
*/
private function writeSuccess(string $message): void
{
$this->writePestTestOutput($message, 'fg-green, bold', '✓');
}
/**
* Writes the given error message to the console.
*/
private function writeError(string $message): void
{
$this->writePestTestOutput($message, 'fg-red, bold', '');
}
/**
* Writes the given warning message to the console.
*/
private function writeWarning(string $message): void
{
$this->writePestTestOutput($message, 'fg-yellow, bold', '-');
}
/**
* Writes the give message to the console.
*/
private function writePestTestOutput(string $message, string $color, string $symbol): void
{
$this->writeWithColor($color, "$symbol ", false);

View File

@ -19,7 +19,7 @@ trait RetrievesValues
*
* @return TRetrievableValue|null
*/
private function retrieve(string $key, $value, $default = null)
private function retrieve(string $key, mixed $value, mixed $default = null): mixed
{
if (is_array($value)) {
return $value[$key] ?? $default;