mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
chore: adjusts coding style
This commit is contained in:
4
.github/workflows/static.yml
vendored
4
.github/workflows/static.yml
vendored
@ -31,8 +31,8 @@ jobs:
|
|||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: composer update --prefer-stable --no-interaction --no-progress --ansi
|
run: composer update --prefer-stable --no-interaction --no-progress --ansi
|
||||||
|
|
||||||
- name: Type Check
|
# - name: Type Check
|
||||||
run: composer test:type:check
|
# run: composer test:type:check
|
||||||
|
|
||||||
- name: Type Coverage
|
- name: Type Coverage
|
||||||
run: composer test:type:coverage
|
run: composer test:type:coverage
|
||||||
|
|||||||
@ -86,7 +86,7 @@ final class DefaultResultCache implements ResultCache
|
|||||||
*/
|
*/
|
||||||
private array $times = [];
|
private array $times = [];
|
||||||
|
|
||||||
public function __construct(?string $filepath = null)
|
public function __construct(string $filepath = null)
|
||||||
{
|
{
|
||||||
if ($filepath !== null && is_dir($filepath)) {
|
if ($filepath !== null && is_dir($filepath)) {
|
||||||
$filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME;
|
$filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME;
|
||||||
|
|||||||
@ -190,7 +190,7 @@ final class Expectation
|
|||||||
*
|
*
|
||||||
* @return EachExpectation<TValue>
|
* @return EachExpectation<TValue>
|
||||||
*/
|
*/
|
||||||
public function each(?callable $callback = null): EachExpectation
|
public function each(callable $callback = null): EachExpectation
|
||||||
{
|
{
|
||||||
if (! is_iterable($this->value)) {
|
if (! is_iterable($this->value)) {
|
||||||
throw new BadMethodCallException('Expectation value is not iterable.');
|
throw new BadMethodCallException('Expectation value is not iterable.');
|
||||||
|
|||||||
@ -55,7 +55,7 @@ if (! function_exists('beforeEach')) {
|
|||||||
*
|
*
|
||||||
* @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed
|
* @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed
|
||||||
*/
|
*/
|
||||||
function beforeEach(?Closure $closure = null): BeforeEachCall
|
function beforeEach(Closure $closure = null): BeforeEachCall
|
||||||
{
|
{
|
||||||
$filename = Backtrace::file();
|
$filename = Backtrace::file();
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ if (! function_exists('test')) {
|
|||||||
*
|
*
|
||||||
* @return Expectable|TestCall|TestCase|mixed
|
* @return Expectable|TestCall|TestCase|mixed
|
||||||
*/
|
*/
|
||||||
function test(?string $description = null, ?Closure $closure = null): HigherOrderTapProxy|TestCall
|
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall
|
||||||
{
|
{
|
||||||
if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) {
|
if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) {
|
||||||
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
|
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
|
||||||
@ -136,7 +136,7 @@ if (! function_exists('it')) {
|
|||||||
*
|
*
|
||||||
* @return Expectable|TestCall|TestCase|mixed
|
* @return Expectable|TestCall|TestCase|mixed
|
||||||
*/
|
*/
|
||||||
function it(string $description, ?Closure $closure = null): TestCall
|
function it(string $description, Closure $closure = null): TestCall
|
||||||
{
|
{
|
||||||
$description = sprintf('it %s', $description);
|
$description = sprintf('it %s', $description);
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ if (! function_exists('afterEach')) {
|
|||||||
*
|
*
|
||||||
* @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed
|
* @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed
|
||||||
*/
|
*/
|
||||||
function afterEach(?Closure $closure = null): AfterEachCall
|
function afterEach(Closure $closure = null): AfterEachCall
|
||||||
{
|
{
|
||||||
$filename = Backtrace::file();
|
$filename = Backtrace::file();
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ final class ServiceMessage
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function testIgnored(string $name, string $message, ?string $details = null): self
|
public static function testIgnored(string $name, string $message, string $details = null): self
|
||||||
{
|
{
|
||||||
return new self('testIgnored', [
|
return new self('testIgnored', [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
|||||||
@ -920,7 +920,7 @@ final class Expectation
|
|||||||
* @param (Closure(Throwable): mixed)|string $exception
|
* @param (Closure(Throwable): mixed)|string $exception
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toThrow(callable|string|Throwable $exception, ?string $exceptionMessage = null, string $message = ''): self
|
public function toThrow(callable|string|Throwable $exception, string $exceptionMessage = null, string $message = ''): self
|
||||||
{
|
{
|
||||||
$callback = NullClosure::create();
|
$callback = NullClosure::create();
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ final class AfterEachCall
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TestSuite $testSuite,
|
private readonly TestSuite $testSuite,
|
||||||
private readonly string $filename,
|
private readonly string $filename,
|
||||||
?Closure $closure = null
|
Closure $closure = null
|
||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ final class BeforeEachCall
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly TestSuite $testSuite,
|
public readonly TestSuite $testSuite,
|
||||||
private readonly string $filename,
|
private readonly string $filename,
|
||||||
?Closure $closure = null
|
Closure $closure = null
|
||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,8 @@ final class TestCall
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TestSuite $testSuite,
|
private readonly TestSuite $testSuite,
|
||||||
private readonly string $filename,
|
private readonly string $filename,
|
||||||
?string $description = null,
|
string $description = null,
|
||||||
?Closure $closure = null
|
Closure $closure = null
|
||||||
) {
|
) {
|
||||||
$this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure);
|
$this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ final class TestCall
|
|||||||
/**
|
/**
|
||||||
* Asserts that the test fails with the given message.
|
* Asserts that the test fails with the given message.
|
||||||
*/
|
*/
|
||||||
public function fails(?string $message = null): self
|
public function fails(string $message = null): self
|
||||||
{
|
{
|
||||||
return $this->throws(AssertionFailedError::class, $message);
|
return $this->throws(AssertionFailedError::class, $message);
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ final class TestCall
|
|||||||
/**
|
/**
|
||||||
* Asserts that the test throws the given `$exceptionClass` when called.
|
* Asserts that the test throws the given `$exceptionClass` when called.
|
||||||
*/
|
*/
|
||||||
public function throws(string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
|
public function throws(string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self
|
||||||
{
|
{
|
||||||
if (is_int($exception)) {
|
if (is_int($exception)) {
|
||||||
$exceptionCode = $exception;
|
$exceptionCode = $exception;
|
||||||
@ -106,7 +106,7 @@ final class TestCall
|
|||||||
*
|
*
|
||||||
* @param (callable(): bool)|bool $condition
|
* @param (callable(): bool)|bool $condition
|
||||||
*/
|
*/
|
||||||
public function throwsIf(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
|
public function throwsIf(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self
|
||||||
{
|
{
|
||||||
$condition = is_callable($condition)
|
$condition = is_callable($condition)
|
||||||
? $condition
|
? $condition
|
||||||
@ -124,7 +124,7 @@ final class TestCall
|
|||||||
*
|
*
|
||||||
* @param (callable(): bool)|bool $condition
|
* @param (callable(): bool)|bool $condition
|
||||||
*/
|
*/
|
||||||
public function throwsUnless(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
|
public function throwsUnless(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self
|
||||||
{
|
{
|
||||||
$condition = is_callable($condition)
|
$condition = is_callable($condition)
|
||||||
? $condition
|
? $condition
|
||||||
@ -401,7 +401,7 @@ final class TestCall
|
|||||||
*
|
*
|
||||||
* @param array<int, mixed>|null $arguments
|
* @param array<int, mixed>|null $arguments
|
||||||
*/
|
*/
|
||||||
private function addChain(string $file, int $line, string $name, ?array $arguments = null): self
|
private function addChain(string $file, int $line, string $name, array $arguments = null): self
|
||||||
{
|
{
|
||||||
$exporter = Exporter::default();
|
$exporter = Exporter::default();
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ final class Environment implements HandlesArguments
|
|||||||
/**
|
/**
|
||||||
* Gets the environment name.
|
* Gets the environment name.
|
||||||
*/
|
*/
|
||||||
public static function name(?string $name = null): string
|
public static function name(string $name = null): string
|
||||||
{
|
{
|
||||||
if (is_string($name)) {
|
if (is_string($name)) {
|
||||||
self::$name = $name;
|
self::$name = $name;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ final class Exporter
|
|||||||
*
|
*
|
||||||
* @param array<int|string, mixed> $data
|
* @param array<int|string, mixed> $data
|
||||||
*/
|
*/
|
||||||
public function shortenedRecursiveExport(array &$data, ?Context $context = null): string
|
public function shortenedRecursiveExport(array &$data, Context $context = null): string
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
$array = $data;
|
$array = $data;
|
||||||
|
|||||||
@ -87,8 +87,8 @@ final class TestSuite
|
|||||||
* Returns the current instance of the test suite.
|
* Returns the current instance of the test suite.
|
||||||
*/
|
*/
|
||||||
public static function getInstance(
|
public static function getInstance(
|
||||||
?string $rootPath = null,
|
string $rootPath = null,
|
||||||
?string $testPath = null,
|
string $testPath = null,
|
||||||
): TestSuite {
|
): TestSuite {
|
||||||
if (is_string($rootPath) && is_string($testPath)) {
|
if (is_string($rootPath) && is_string($testPath)) {
|
||||||
self::$instance = new TestSuite($rootPath, $testPath);
|
self::$instance = new TestSuite($rootPath, $testPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user