From e9564febaf071a6c293e37b64556b1685de96b3d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 16 Sep 2022 10:45:53 +0100 Subject: [PATCH] Migrates to Pint --- .github/workflows/static.yml | 10 ++- .github/workflows/tests.yml | 6 +- .php-cs-fixer.dist.php | 31 --------- composer.json | 17 +++-- .../Runner/Filter/NameFilterIterator.php | 10 +-- overrides/Runner/TestSuiteLoader.php | 12 ++-- rector.php | 28 ++++++++ src/Bootstrappers/BootFiles.php | 10 ++- src/Concerns/Expectable.php | 3 +- src/Concerns/Retrievable.php | 5 +- src/Concerns/Testable.php | 20 +++--- src/ConfigLoader.php | 10 +-- src/Contracts/Plugins/HandlesArguments.php | 3 +- src/Exceptions/DatasetMissing.php | 2 +- src/Expectation.php | 36 +++++----- src/Expectations/EachExpectation.php | 9 +-- src/Expectations/HigherOrderExpectation.php | 27 ++++---- src/Expectations/OppositeExpectation.php | 13 ++-- src/Factories/Annotations/CoversNothing.php | 3 +- src/Factories/Annotations/Depends.php | 3 +- src/Factories/Annotations/Groups.php | 3 +- src/Factories/Attributes/Attribute.php | 3 +- src/Factories/Attributes/Covers.php | 5 +- src/Factories/Concerns/HigherOrderable.php | 4 +- src/Factories/TestCaseFactory.php | 24 +++---- src/Factories/TestCaseMethodFactory.php | 18 ++--- src/Functions.php | 27 ++++---- src/Kernel.php | 4 +- src/Laravel/Commands/PestDatasetCommand.php | 8 +-- src/Laravel/Commands/PestInstallCommand.php | 6 +- src/Laravel/Commands/PestTestCommand.php | 6 +- src/Mixins/Expectation.php | 66 ++++++++----------- src/PendingCalls/AfterEachCall.php | 2 +- src/PendingCalls/BeforeEachCall.php | 2 +- src/PendingCalls/TestCall.php | 12 ++-- src/PendingCalls/UsesCall.php | 4 +- src/Pest.php | 2 +- src/Plugin.php | 4 +- src/Plugins/Actions/HandleArguments.php | 3 +- src/Plugins/Concerns/HandleArguments.php | 8 +-- src/Plugins/Coverage.php | 8 +-- src/Plugins/Init.php | 20 +++--- src/Plugins/Printer.php | 2 +- src/Plugins/Version.php | 2 - src/Repositories/DatasetsRepository.php | 35 +++++----- src/Repositories/TempRepository.php | 10 +-- src/Repositories/TestRepository.php | 16 ++--- src/Support/Arr.php | 13 ++-- src/Support/ChainableClosure.php | 2 +- src/Support/Container.php | 9 ++- src/Support/Coverage.php | 16 ++--- src/Support/ExceptionTrace.php | 2 +- src/Support/ExpectationPipeline.php | 2 +- src/Support/HigherOrderCallables.php | 4 +- src/Support/HigherOrderMessage.php | 6 +- src/Support/HigherOrderMessageCollection.php | 6 +- src/Support/HigherOrderTapProxy.php | 7 +- src/Support/Printer.php | 2 +- src/Support/Reflection.php | 18 +++-- src/Support/Str.php | 2 +- src/TestSuite.php | 10 +-- tests/Features/AfterAll.php | 2 +- tests/Features/BeforeAll.php | 2 +- tests/Features/Coverage.php | 15 +++-- tests/Features/Datasets.php | 18 ++--- tests/Features/Expect/HigherOrder/methods.php | 6 +- .../HigherOrder/methodsAndProperties.php | 8 +-- .../Expect/HigherOrder/properties.php | 4 +- tests/Features/Expect/matchExpectation.php | 2 +- tests/Features/Expect/pipes.php | 54 +++++++-------- tests/Features/Expect/toBe.php | 2 +- tests/Features/Expect/toBeFile.php | 2 +- tests/Features/Expect/toBeReadableFile.php | 2 +- tests/Features/Expect/toBeWritableFile.php | 2 +- tests/Features/Expect/toHaveProperties.php | 10 +-- tests/Features/Expect/toHaveProperty.php | 4 +- tests/Features/Expect/toMatchArray.php | 8 +-- tests/Features/Expect/toMatchObject.php | 13 ++-- tests/Features/Expect/toThrow.php | 4 +- tests/Features/Expect/unless.php | 4 +- tests/Features/Expect/when.php | 4 +- tests/Features/TestCycle.php | 8 +-- tests/Hooks/BeforeAllTest.php | 2 +- .../PHPUnit/CustomTestCase/CustomTestCase.php | 1 - tests/PHPUnit/CustomTestCase/ExecutedTest.php | 1 - tests/Unit/Datasets.php | 2 +- tests/Unit/Plugins/Version.php | 4 +- tests/Unit/Support/Reflection.php | 3 +- tests/Unit/TestSuite.php | 6 +- tests/Visual/Help.php | 6 +- tests/Visual/JUnit.php | 6 +- tests/Visual/SingleTestOrDirectory.php | 4 +- tests/Visual/Success.php | 8 +-- tests/Visual/TeamCity.php | 6 +- 94 files changed, 413 insertions(+), 471 deletions(-) delete mode 100644 .php-cs-fixer.dist.php create mode 100644 rector.php diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index fc8eb823..e7f03450 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -47,5 +47,11 @@ jobs: - name: Install Dependencies run: composer update --prefer-stable --no-interaction --no-progress --ansi - - name: Run PHPStan - run: vendor/bin/phpstan analyse --no-progress --debug --ansi + - name: Types + run: composer test:types + + - name: Style + run: composer test:lint + + - name: Recfato + run: composer test:refacto diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index badffb71..2a855c50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,11 +34,11 @@ jobs: run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi - name: Unit Tests - run: php bin/pest --colors=always --exclude-group=integration + run: composer test:unit - name: Unit Tests - run: php bin/pest --colors=always --exclude-group=integration ${{ matrix.parallel }} + run: test:parallel if: ${{ false }} # 2.x-dev is under development - name: Integration Tests - run: php bin/pest --colors=always --group=integration -v + run: composer test:integration diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 3454e972..00000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,31 +0,0 @@ -in(__DIR__ . DIRECTORY_SEPARATOR . 'tests') - ->in(__DIR__ . DIRECTORY_SEPARATOR . 'bin') - ->in(__DIR__ . DIRECTORY_SEPARATOR . 'overrides') - ->in(__DIR__ . DIRECTORY_SEPARATOR . 'stubs') - ->in(__DIR__ . DIRECTORY_SEPARATOR . 'src') - ->append(['.php-cs-fixer.dist.php']); - -$rules = [ - '@Symfony' => true, - 'phpdoc_no_empty_return' => false, - 'array_syntax' => ['syntax' => 'short'], - 'yoda_style' => false, - 'binary_operator_spaces' => [ - 'operators' => [ - '=>' => 'align', - '=' => 'align', - ], - ], - 'concat_space' => ['spacing' => 'one'], - 'not_operator_with_space' => false, -]; - -$rules['increment_style'] = ['style' => 'post']; - -return (new PhpCsFixer\Config()) - ->setUsingCache(true) - ->setRules($rules) - ->setFinder($finder); diff --git a/composer.json b/composer.json index 948acc3d..14852736 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,13 @@ "illuminate/console": "^9.30.1", "illuminate/support": "^9.30.1", "laravel/dusk": "^6.25.1", - "pestphp/pest-dev-tools": "dev-master" + "ergebnis/phpstan-rules": "^1.0.0", + "laravel/pint": "^1.2.0", + "phpstan/phpstan": "^1.8.5", + "phpstan/phpstan-strict-rules": "^1.4.3", + "symfony/var-dumper": "^6.2.0", + "thecodingmachine/phpstan-strict-rules": "^1.0.0", + "rector/rector": "^0.14.2" }, "minimum-stability": "dev", "prefer-stable": true, @@ -66,8 +72,10 @@ "bin/pest" ], "scripts": { - "lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v", - "test:lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v --dry-run", + "lint": "pint --test", + "refactor": "rector", + "test:lint": "pint --test", + "test:refactor": "rector --dry-run", "test:types": "phpstan analyse --ansi --memory-limit=-1 --debug", "test:unit": "php bin/pest --colors=always --exclude-group=integration", "test:parallel": "exit 1", @@ -77,7 +85,8 @@ "@test:lint", "@test:types", "@test:unit", - "@test:integration" + "@test:integration", + "@test:refactor" ] }, "extra": { diff --git a/overrides/Runner/Filter/NameFilterIterator.php b/overrides/Runner/Filter/NameFilterIterator.php index 69909b51..be5151aa 100644 --- a/overrides/Runner/Filter/NameFilterIterator.php +++ b/overrides/Runner/Filter/NameFilterIterator.php @@ -37,22 +37,16 @@ namespace PHPUnit\Runner\Filter; use function end; - use Exception; - use function implode; - use Pest\Contracts\HasPrintableTestCaseName; use PHPUnit\Framework\SelfDescribing; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; - use function preg_match; - use RecursiveFilterIterator; use RecursiveIterator; - use function sprintf; use function str_replace; @@ -62,7 +56,9 @@ use function str_replace; final class NameFilterIterator extends RecursiveFilterIterator { private ?string $filter = null; + private ?int $filterMin = null; + private ?int $filterMax = null; /** @@ -94,7 +90,7 @@ final class NameFilterIterator extends RecursiveFilterIterator $accepted = @preg_match($this->filter, $name, $matches); if ($accepted && isset($this->filterMax)) { - $set = end($matches); + $set = end($matches); $accepted = $set >= $this->filterMin && $set <= $this->filterMax; } diff --git a/overrides/Runner/TestSuiteLoader.php b/overrides/Runner/TestSuiteLoader.php index 9b4b1209..0719288b 100644 --- a/overrides/Runner/TestSuiteLoader.php +++ b/overrides/Runner/TestSuiteLoader.php @@ -43,14 +43,12 @@ use function array_values; use function basename; use function class_exists; use function get_declared_classes; - use Pest\Contracts\HasPrintableTestCaseName; use Pest\TestCases\IgnorableTest; use Pest\TestSuite; use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionException; - use function substr; /** @@ -116,7 +114,7 @@ final class TestSuiteLoader } } - if (!$testCaseFound) { + if (! $testCaseFound) { foreach (self::$loadedClasses as $loadedClass) { if (is_subclass_of($loadedClass, TestCase::class)) { $suiteClassName = $loadedClass; @@ -126,7 +124,7 @@ final class TestSuiteLoader } } - if (!class_exists($suiteClassName, false)) { + if (! class_exists($suiteClassName, false)) { return $this->exceptionFor($suiteClassName, $suiteClassFile); } @@ -138,7 +136,7 @@ final class TestSuiteLoader } // @codeCoverageIgnoreEnd - if ($class->isSubclassOf(TestCase::class) && !$class->isAbstract()) { + if ($class->isSubclassOf(TestCase::class) && ! $class->isAbstract()) { return $class; } @@ -151,7 +149,7 @@ final class TestSuiteLoader } // @codeCoverageIgnoreEnd - if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) { + if (! $method->isAbstract() && $method->isPublic() && $method->isStatic()) { return $class; } } @@ -167,7 +165,7 @@ final class TestSuiteLoader private function classNameFromFileName(string $suiteClassFile): string { $className = basename($suiteClassFile, '.php'); - $dotPos = strpos($className, '.'); + $dotPos = strpos($className, '.'); if ($dotPos !== false) { $className = substr($className, 0, $dotPos); diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..7300adcd --- /dev/null +++ b/rector.php @@ -0,0 +1,28 @@ +paths([ + __DIR__.'/bin', + __DIR__.'/src', + ]); + + $rectorConfig->rules([ + InlineConstructorDefaultToPropertyRector::class, + ]); + + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_81, + SetList::CODE_QUALITY, + SetList::DEAD_CODE, + SetList::EARLY_RETURN, + SetList::TYPE_DECLARATION, + SetList::PRIVATIZATION, + ]); +}; diff --git a/src/Bootstrappers/BootFiles.php b/src/Bootstrappers/BootFiles.php index a3d1ee9d..6f8d2c02 100644 --- a/src/Bootstrappers/BootFiles.php +++ b/src/Bootstrappers/BootFiles.php @@ -5,9 +5,7 @@ declare(strict_types=1); namespace Pest\Bootstrappers; use Pest\Support\Str; - use function Pest\testDirectory; - use Pest\TestSuite; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -37,19 +35,19 @@ final class BootFiles */ public function __invoke(): void { - $rootPath = TestSuite::getInstance()->rootPath; - $testsPath = $rootPath . DIRECTORY_SEPARATOR . testDirectory(); + $rootPath = TestSuite::getInstance()->rootPath; + $testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory(); foreach (self::STRUCTURE as $filename) { $filename = sprintf('%s%s%s', $testsPath, DIRECTORY_SEPARATOR, $filename); - if (!file_exists($filename)) { + if (! file_exists($filename)) { continue; } if (is_dir($filename)) { $directory = new RecursiveDirectoryIterator($filename); - $iterator = new RecursiveIteratorIterator($directory); + $iterator = new RecursiveIteratorIterator($directory); /** @var \DirectoryIterator $file */ foreach ($iterator as $file) { $this->load($file->__toString()); diff --git a/src/Concerns/Expectable.php b/src/Concerns/Expectable.php index 474a900f..d8e02538 100644 --- a/src/Concerns/Expectable.php +++ b/src/Concerns/Expectable.php @@ -16,8 +16,7 @@ trait Expectable * * Creates a new Expectation. * - * @param TValue $value - * + * @param TValue $value * @return Expectation */ public function expect(mixed $value): Expectation diff --git a/src/Concerns/Retrievable.php b/src/Concerns/Retrievable.php index 81dd75a3..a2716887 100644 --- a/src/Concerns/Retrievable.php +++ b/src/Concerns/Retrievable.php @@ -16,9 +16,8 @@ trait Retrievable * * @template TRetrievableValue * - * @param array|object $value - * @param TRetrievableValue|null $default - * + * @param array|object $value + * @param TRetrievableValue|null $default * @return TRetrievableValue|null */ private function retrieve(string $key, mixed $value, mixed $default = null): mixed diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 858c2876..9d20d895 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -55,7 +55,7 @@ trait Testable public static function flush(): void { self::$__beforeAll = null; - self::$__afterAll = null; + self::$__afterAll = null; } /** @@ -68,9 +68,9 @@ trait Testable $test = TestSuite::getInstance()->tests->get(self::$__filename); if ($test->hasMethod($name)) { - $method = $test->getMethod($name); + $method = $test->getMethod($name); self::$__description = $method->description; - $this->__test = $method->getClosure($this); + $this->__test = $method->getClosure($this); } } @@ -79,7 +79,7 @@ trait Testable */ public function __addBeforeAll(?Closure $hook): void { - if (!$hook) { + if (! $hook) { return; } @@ -93,7 +93,7 @@ trait Testable */ public function __addAfterAll(?Closure $hook): void { - if (!$hook) { + if (! $hook) { return; } @@ -123,7 +123,7 @@ trait Testable */ private function __addHook(string $property, ?Closure $hook): void { - if (!$hook) { + if (! $hook) { return; } @@ -222,7 +222,7 @@ trait Testable $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); if ($this->dataName()) { - self::$__description = $method->description . ' with ' . $this->dataName(); + self::$__description = $method->description.' with '.$this->dataName(); } else { self::$__description = $method->description; } @@ -231,11 +231,11 @@ trait Testable return $arguments; } - if (!$arguments[0] instanceof Closure) { + if (! $arguments[0] instanceof Closure) { return $arguments; } - $underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure'); + $underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure'); $testParameterTypes = array_values(Reflection::getFunctionArguments($underlyingTest)); if (in_array($testParameterTypes[0], ['Closure', 'callable'])) { @@ -244,7 +244,7 @@ trait Testable $boundDatasetResult = $this->__callClosure($arguments[0], []); - if (count($testParameterTypes) === 1 || !is_array($boundDatasetResult)) { + if (count($testParameterTypes) === 1 || ! is_array($boundDatasetResult)) { return [$boundDatasetResult]; } diff --git a/src/ConfigLoader.php b/src/ConfigLoader.php index b3af2c0d..b2def1d2 100644 --- a/src/ConfigLoader.php +++ b/src/ConfigLoader.php @@ -45,7 +45,7 @@ final class ConfigLoader $suiteDirectory = $this->config->xpath('/phpunit/testsuites/testsuite/directory'); // @phpstan-ignore-next-line - if (!$suiteDirectory || count($suiteDirectory) === 0) { + if (! $suiteDirectory || count($suiteDirectory) === 0) { return self::DEFAULT_TESTS_PATH; } @@ -71,9 +71,9 @@ final class ConfigLoader public function getConfigurationFilePath(): string|false { $candidates = [ - $this->rootPath . '/phpunit.xml', - $this->rootPath . '/phpunit.dist.xml', - $this->rootPath . '/phpunit.xml.dist', + $this->rootPath.'/phpunit.xml', + $this->rootPath.'/phpunit.dist.xml', + $this->rootPath.'/phpunit.xml.dist', ]; foreach ($candidates as $candidate) { @@ -97,7 +97,7 @@ final class ConfigLoader } $oldReportingLevel = error_reporting(0); - $content = file_get_contents($configPath); + $content = file_get_contents($configPath); if ($content !== false) { try { diff --git a/src/Contracts/Plugins/HandlesArguments.php b/src/Contracts/Plugins/HandlesArguments.php index c58c4e2d..72c9d722 100644 --- a/src/Contracts/Plugins/HandlesArguments.php +++ b/src/Contracts/Plugins/HandlesArguments.php @@ -12,8 +12,7 @@ interface HandlesArguments /** * Adds arguments before of the Test Suite execution. * - * @param array $arguments - * + * @param array $arguments * @return array */ public function handleArguments(array $arguments): array; diff --git a/src/Exceptions/DatasetMissing.php b/src/Exceptions/DatasetMissing.php index 8d3a7cd9..dff80373 100644 --- a/src/Exceptions/DatasetMissing.php +++ b/src/Exceptions/DatasetMissing.php @@ -17,7 +17,7 @@ final class DatasetMissing extends BadFunctionCallException implements Exception /** * Creates a new Exception instance. * - * @param array $arguments + * @param array $arguments */ public function __construct(string $file, string $name, array $arguments) { diff --git a/src/Expectation.php b/src/Expectation.php index 2a9ea05c..179becf1 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -37,7 +37,7 @@ final class Expectation /** * Creates a new expectation. * - * @param TValue $value + * @param TValue $value */ public function __construct( public mixed $value @@ -50,8 +50,7 @@ final class Expectation * * @template TAndValue * - * @param TAndValue $value - * + * @param TAndValue $value * @return self */ public function and(mixed $value): Expectation @@ -66,7 +65,7 @@ final class Expectation */ public function json(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -139,7 +138,7 @@ final class Expectation */ 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.'); } @@ -158,25 +157,24 @@ final class Expectation * @template TSequenceValue * * @param (callable(self, self): void)|TSequenceValue ...$callbacks - * * @return self */ public function sequence(mixed ...$callbacks): Expectation { - if (!is_iterable($this->value)) { + if (! is_iterable($this->value)) { throw new BadMethodCallException('Expectation value is not iterable.'); } - $value = is_array($this->value) ? $this->value : iterator_to_array($this->value); - $keys = array_keys($value); - $values = array_values($value); + $value = is_array($this->value) ? $this->value : iterator_to_array($this->value); + $keys = array_keys($value); + $values = array_values($value); $callbacksCount = count($callbacks); $index = 0; while (count($callbacks) < count($values)) { $callbacks[] = $callbacks[$index]; - $index = $index < count($values) - 1 ? $index + 1 : 0; + $index = $index < count($values) - 1 ? $index + 1 : 0; } if ($callbacksCount > count($values)) { @@ -203,7 +201,6 @@ final class Expectation * * @param (callable(): TMatchSubject)|TMatchSubject $subject * @param array): mixed)|TValue> $expressions - * * @return self */ public function match(mixed $subject, array $expressions): Expectation @@ -241,8 +238,7 @@ final class Expectation * Apply the callback if the given "condition" is falsy. * * @param (callable(): bool)|bool $condition - * @param callable(Expectation): mixed $callback - * + * @param callable(Expectation): mixed $callback * @return self */ public function unless(callable|bool $condition, callable $callback): Expectation @@ -253,15 +249,14 @@ final class Expectation return $condition; }; - return $this->when(!$condition(), $callback); + return $this->when(! $condition(), $callback); } /** * Apply the callback if the given "condition" is truthy. * * @param (callable(): bool)|bool $condition - * @param callable(self): mixed $callback - * + * @param callable(self): mixed $callback * @return self */ public function when(callable|bool $condition, callable $callback): Expectation @@ -282,13 +277,12 @@ final class Expectation /** * Dynamically calls methods on the class or creates a new higher order expectation. * - * @param array $parameters - * + * @param array $parameters * @return Expectation|HigherOrderExpectation, TValue> */ public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation { - if (!self::hasMethod($method)) { + if (! self::hasMethod($method)) { /* @phpstan-ignore-next-line */ return new HigherOrderExpectation($this, $this->value->$method(...$parameters)); } @@ -331,7 +325,7 @@ final class Expectation */ public function __get(string $name) { - if (!self::hasMethod($name)) { + if (! self::hasMethod($name)) { /* @phpstan-ignore-next-line */ return new HigherOrderExpectation($this, $this->retrieve($name, $this->value)); } diff --git a/src/Expectations/EachExpectation.php b/src/Expectations/EachExpectation.php index c14b4c12..9fa53355 100644 --- a/src/Expectations/EachExpectation.php +++ b/src/Expectations/EachExpectation.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Pest\Expectations; use function expect; - use Pest\Expectation; /** @@ -22,7 +21,7 @@ final class EachExpectation /** * Creates an expectation on each item of the iterable "value". * - * @param Expectation $original + * @param Expectation $original */ public function __construct(private Expectation $original) { @@ -33,8 +32,7 @@ final class EachExpectation * * @template TAndValue * - * @param TAndValue $value - * + * @param TAndValue $value * @return Expectation */ public function and(mixed $value): Expectation @@ -57,8 +55,7 @@ final class EachExpectation /** * Dynamically calls methods on the class with the given arguments on each item. * - * @param array $arguments - * + * @param array $arguments * @return self */ public function __call(string $name, array $arguments): EachExpectation diff --git a/src/Expectations/HigherOrderExpectation.php b/src/Expectations/HigherOrderExpectation.php index 5d194cdb..df2dfc2d 100644 --- a/src/Expectations/HigherOrderExpectation.php +++ b/src/Expectations/HigherOrderExpectation.php @@ -32,8 +32,8 @@ final class HigherOrderExpectation /** * Creates a new higher order expectation. * - * @param Expectation $original - * @param TValue $value + * @param Expectation $original + * @param TValue $value */ public function __construct(private Expectation $original, mixed $value) { @@ -47,7 +47,7 @@ final class HigherOrderExpectation */ public function not(): HigherOrderExpectation { - $this->opposite = !$this->opposite; + $this->opposite = ! $this->opposite; return $this; } @@ -57,8 +57,7 @@ final class HigherOrderExpectation * * @template TExpectValue * - * @param TExpectValue $value - * + * @param TExpectValue $value * @return Expectation */ public function expect(mixed $value): Expectation @@ -71,8 +70,7 @@ final class HigherOrderExpectation * * @template TExpectValue * - * @param TExpectValue $value - * + * @param TExpectValue $value * @return Expectation */ public function and(mixed $value): Expectation @@ -84,8 +82,7 @@ final class HigherOrderExpectation * Scope an expectation callback to the current value in * the HigherOrderExpectation chain. * - * @param Closure(Expectation): void $expectation - * + * @param Closure(Expectation): void $expectation * @return HigherOrderExpectation */ public function scoped(Closure $expectation): self @@ -108,13 +105,12 @@ final class HigherOrderExpectation /** * Dynamically calls methods on the class with the given arguments. * - * @param array $arguments - * + * @param array $arguments * @return self|self */ public function __call(string $name, array $arguments): self { - if (!$this->expectationHasMethod($name)) { + if (! $this->expectationHasMethod($name)) { /* @phpstan-ignore-next-line */ return new self($this->original, $this->getValue()->$name(...$arguments)); } @@ -133,7 +129,7 @@ final class HigherOrderExpectation return $this->not(); } - if (!$this->expectationHasMethod($name)) { + if (! $this->expectationHasMethod($name)) { /** @var array|object $value */ $value = $this->getValue(); @@ -165,8 +161,7 @@ final class HigherOrderExpectation /** * Performs the given assertion with the current expectation. * - * @param array $arguments - * + * @param array $arguments * @return self */ private function performAssertion(string $name, array $arguments): self @@ -174,7 +169,7 @@ final class HigherOrderExpectation /* @phpstan-ignore-next-line */ $this->expectation = ($this->opposite ? $this->expectation->not() : $this->expectation)->{$name}(...$arguments); - $this->opposite = false; + $this->opposite = false; $this->shouldReset = true; return $this; diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index a5b9b480..36d89d56 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -21,7 +21,7 @@ final class OppositeExpectation /** * Creates a new opposite expectation. * - * @param Expectation $original + * @param Expectation $original */ public function __construct(private Expectation $original) { @@ -30,8 +30,7 @@ final class OppositeExpectation /** * Asserts that the value array not has the provided $keys. * - * @param array> $keys - * + * @param array> $keys * @return Expectation */ public function toHaveKeys(array $keys): Expectation @@ -39,7 +38,7 @@ final class OppositeExpectation foreach ($keys as $k => $key) { try { if (is_array($key)) { - $this->toHaveKeys(array_keys(Arr::dot($key, $k . '.'))); + $this->toHaveKeys(array_keys(Arr::dot($key, $k.'.'))); } else { $this->original->toHaveKey($key); } @@ -56,8 +55,7 @@ final class OppositeExpectation /** * Handle dynamic method calls into the original expectation. * - * @param array $arguments - * + * @param array $arguments * @return Expectation|Expectation|never */ public function __call(string $name, array $arguments): Expectation @@ -91,8 +89,7 @@ final class OppositeExpectation /** * Creates a new expectation failed exception with a nice readable message. * - * @param array $arguments - * + * @param array $arguments * @return never */ private function throwExpectationFailedException(string $name, array $arguments = []): void diff --git a/src/Factories/Annotations/CoversNothing.php b/src/Factories/Annotations/CoversNothing.php index 8faaca1f..956a639f 100644 --- a/src/Factories/Annotations/CoversNothing.php +++ b/src/Factories/Annotations/CoversNothing.php @@ -15,8 +15,7 @@ final class CoversNothing /** * Adds annotations regarding the "depends" feature. * - * @param array $annotations - * + * @param array $annotations * @return array */ public function __invoke(TestCaseMethodFactory $method, array $annotations): array diff --git a/src/Factories/Annotations/Depends.php b/src/Factories/Annotations/Depends.php index f41076d9..5647081f 100644 --- a/src/Factories/Annotations/Depends.php +++ b/src/Factories/Annotations/Depends.php @@ -15,8 +15,7 @@ final class Depends /** * Adds annotations regarding the "depends" feature. * - * @param array $annotations - * + * @param array $annotations * @return array */ public function __invoke(TestCaseMethodFactory $method, array $annotations): array diff --git a/src/Factories/Annotations/Groups.php b/src/Factories/Annotations/Groups.php index 0876ff5c..9fb61f8a 100644 --- a/src/Factories/Annotations/Groups.php +++ b/src/Factories/Annotations/Groups.php @@ -14,8 +14,7 @@ final class Groups /** * Adds annotations regarding the "groups" feature. * - * @param array $annotations - * + * @param array $annotations * @return array */ public function __invoke(TestCaseMethodFactory $method, array $annotations): array diff --git a/src/Factories/Attributes/Attribute.php b/src/Factories/Attributes/Attribute.php index e53fbe13..70dae523 100644 --- a/src/Factories/Attributes/Attribute.php +++ b/src/Factories/Attributes/Attribute.php @@ -19,8 +19,7 @@ abstract class Attribute public const ABOVE_CLASS = false; /** - * @param array $attributes - * + * @param array $attributes * @return array */ public function __invoke(TestCaseMethodFactory $method, array $attributes): array // @phpstan-ignore-line diff --git a/src/Factories/Attributes/Covers.php b/src/Factories/Attributes/Covers.php index d6d41c4a..da07b2a1 100644 --- a/src/Factories/Attributes/Covers.php +++ b/src/Factories/Attributes/Covers.php @@ -23,8 +23,7 @@ final class Covers extends Attribute /** * Adds attributes regarding the "covers" feature. * - * @param array $attributes - * + * @param array $attributes * @return array */ public function __invoke(TestCaseMethodFactory $method, array $attributes): array @@ -33,7 +32,7 @@ final class Covers extends Attribute if ($covering instanceof CoversClass) { // Prepend a backslash for FQN classes if (str_contains($covering->class, '\\')) { - $covering->class = '\\' . $covering->class; + $covering->class = '\\'.$covering->class; } $attributes[] = "#[\PHPUnit\Framework\Attributes\CoversClass({$covering->class}::class)]"; diff --git a/src/Factories/Concerns/HigherOrderable.php b/src/Factories/Concerns/HigherOrderable.php index 160d8684..94d425b4 100644 --- a/src/Factories/Concerns/HigherOrderable.php +++ b/src/Factories/Concerns/HigherOrderable.php @@ -28,8 +28,8 @@ trait HigherOrderable */ private function bootHigherOrderable(): void { - $this->chains = new HigherOrderMessageCollection(); + $this->chains = new HigherOrderMessageCollection(); $this->factoryProxies = new HigherOrderMessageCollection(); - $this->proxies = new HigherOrderMessageCollection(); + $this->proxies = new HigherOrderMessageCollection(); } } diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index a6542250..c0df72c6 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -109,7 +109,7 @@ final class TestCaseFactory /** * Creates a Test Case class using a runtime evaluate. * - * @param array $methods + * @param array $methods */ public function evaluate(string $filename, array $methods): void { @@ -118,9 +118,9 @@ final class TestCaseFactory $filename = (string) preg_replace_callback('~^(?P[a-z]+:\\\)~i', static fn ($match): string => strtolower($match['drive']), $filename); } - $filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename))); - $rootPath = TestSuite::getInstance()->rootPath; - $relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename); + $filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename))); + $rootPath = TestSuite::getInstance()->rootPath; + $relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename); $basename = basename($relativePath, '.php'); @@ -130,7 +130,7 @@ final class TestCaseFactory $basename = substr($basename, 0, $dotPos); } - $relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . $basename; + $relativePath = dirname(ucfirst($relativePath)).DIRECTORY_SEPARATOR.$basename; $relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath); @@ -141,29 +141,29 @@ final class TestCaseFactory // Limit to A-Z, a-z, 0-9, '_', '-'. $relativePath = (string) preg_replace('/[^A-Za-z0-9\\\\]/', '', $relativePath); - $classFQN = 'P\\' . $relativePath; + $classFQN = 'P\\'.$relativePath; if (class_exists($classFQN)) { return; } $hasPrintableTestCaseClassFQN = sprintf('\%s', HasPrintableTestCaseName::class); - $traitsCode = sprintf('use %s;', implode(', ', array_map( + $traitsCode = sprintf('use %s;', implode(', ', array_map( static fn ($trait): string => sprintf('\%s', $trait), $this->traits)) ); - $partsFQN = explode('\\', $classFQN); + $partsFQN = explode('\\', $classFQN); $className = array_pop($partsFQN); $namespace = implode('\\', $partsFQN); $baseClass = sprintf('\%s', $this->class); if ('' === trim($className)) { - $className = 'InvalidTestName' . Str::random(); + $className = 'InvalidTestName'.Str::random(); $classFQN .= $className; } - $classAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => $attribute::ABOVE_CLASS); - $methodAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => !$attribute::ABOVE_CLASS); + $classAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => $attribute::ABOVE_CLASS); + $methodAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => ! $attribute::ABOVE_CLASS); $classAttributes = []; @@ -225,7 +225,7 @@ final class TestCaseFactory throw new TestAlreadyExist($method->filename, $method->description); } - if (!$method->receivesArguments()) { + if (! $method->receivesArguments()) { if ($method->closure === null) { throw ShouldNotHappen::fromMessage('The test closure may not be empty.'); } diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index 3c45320f..b1666227 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -90,7 +90,7 @@ final class TestCaseMethodFactory $method = $this; return function () use ($testCase, $method, $closure): mixed { // @phpstan-ignore-line - /* @var TestCase $this */ + /* @var TestCase $this */ $testCase->proxies->proxy($this); $method->proxies->proxy($this); @@ -112,8 +112,8 @@ final class TestCaseMethodFactory /** * Creates a PHPUnit method as a string ready for evaluation. * - * @param array $annotationsToUse - * @param array> $attributesToUse + * @param array $annotationsToUse + * @param array> $attributesToUse */ public function buildForEvaluation(string $classFQN, array $annotationsToUse, array $attributesToUse): string { @@ -123,13 +123,13 @@ final class TestCaseMethodFactory $methodName = Str::evaluable($this->description); - if (Retry::$retrying && !TestSuite::getInstance()->retryTempRepository->exists(sprintf('%s::%s', $classFQN, $methodName))) { + if (Retry::$retrying && ! TestSuite::getInstance()->retryTempRepository->exists(sprintf('%s::%s', $classFQN, $methodName))) { return ''; } $datasetsCode = ''; - $annotations = ['@test']; - $attributes = []; + $annotations = ['@test']; + $attributes = []; foreach ($annotationsToUse as $annotation) { /** @phpstan-ignore-next-line */ @@ -141,9 +141,9 @@ final class TestCaseMethodFactory } if (count($this->datasets) > 0) { - $dataProviderName = $methodName . '_dataset'; - $annotations[] = "@dataProvider $dataProviderName"; - $datasetsCode = $this->buildDatasetForEvaluation($methodName, $dataProviderName); + $dataProviderName = $methodName.'_dataset'; + $annotations[] = "@dataProvider $dataProviderName"; + $datasetsCode = $this->buildDatasetForEvaluation($methodName, $dataProviderName); } $annotations = implode('', array_map( diff --git a/src/Functions.php b/src/Functions.php index 66bd4c2f..c270528a 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -13,14 +13,13 @@ use Pest\Support\HigherOrderTapProxy; use Pest\TestSuite; use PHPUnit\Framework\TestCase; -if (!function_exists('expect')) { +if (! function_exists('expect')) { /** * Creates a new expectation. * * @template TValue * - * @param TValue $value - * + * @param TValue $value * @return Expectation */ function expect(mixed $value = null): Expectation @@ -29,7 +28,7 @@ if (!function_exists('expect')) { } } -if (!function_exists('beforeAll')) { +if (! function_exists('beforeAll')) { /** * Runs the given closure before all tests in the current file. */ @@ -39,7 +38,7 @@ if (!function_exists('beforeAll')) { } } -if (!function_exists('beforeEach')) { +if (! function_exists('beforeEach')) { /** * Runs the given closure before each test in the current file. * @@ -53,11 +52,11 @@ if (!function_exists('beforeEach')) { } } -if (!function_exists('dataset')) { +if (! function_exists('dataset')) { /** * Registers the given dataset. * - * @param Closure|iterable $dataset + * @param Closure|iterable $dataset */ function dataset(string $name, Closure|iterable $dataset): void { @@ -65,12 +64,12 @@ if (!function_exists('dataset')) { } } -if (!function_exists('uses')) { +if (! function_exists('uses')) { /** * The uses function binds the given * arguments to test closures. * - * @param class-string ...$classAndTraits + * @param class-string ...$classAndTraits */ function uses(string ...$classAndTraits): UsesCall { @@ -80,7 +79,7 @@ if (!function_exists('uses')) { } } -if (!function_exists('test')) { +if (! function_exists('test')) { /** * Adds the given closure as a test. The first argument * is the test description; the second argument is @@ -100,7 +99,7 @@ if (!function_exists('test')) { } } -if (!function_exists('it')) { +if (! function_exists('it')) { /** * Adds the given closure as a test. The first argument * is the test description; the second argument is @@ -119,7 +118,7 @@ if (!function_exists('it')) { } } -if (!function_exists('todo')) { +if (! function_exists('todo')) { /** * Adds the given todo test. Internally, this test * is marked as incomplete. Yet, Collision, Pest's @@ -136,7 +135,7 @@ if (!function_exists('todo')) { } } -if (!function_exists('afterEach')) { +if (! function_exists('afterEach')) { /** * Runs the given closure after each test in the current file. * @@ -150,7 +149,7 @@ if (!function_exists('afterEach')) { } } -if (!function_exists('afterAll')) { +if (! function_exists('afterAll')) { /** * Runs the given closure after all tests in the current file. */ diff --git a/src/Kernel.php b/src/Kernel.php index ff43090c..334e7def 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -55,7 +55,7 @@ final class Kernel /** * Handles the given argv. * - * @param array $argv + * @param array $argv */ public function handle(array $argv): int { @@ -90,7 +90,7 @@ final class Kernel $returnCode = self::FAILURE_EXIT; if ($result->wasSuccessfulIgnoringPhpunitWarnings() - && !$result->hasTestTriggeredPhpunitWarningEvents()) { + && ! $result->hasTestTriggeredPhpunitWarningEvents()) { $returnCode = self::SUCCESS_EXIT; } diff --git a/src/Laravel/Commands/PestDatasetCommand.php b/src/Laravel/Commands/PestDatasetCommand.php index 67a75e4b..8c088d41 100644 --- a/src/Laravel/Commands/PestDatasetCommand.php +++ b/src/Laravel/Commands/PestDatasetCommand.php @@ -8,9 +8,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Pest\Exceptions\InvalidConsoleArgument; - use function Pest\testDirectory; - use Pest\TestSuite; /** @@ -53,7 +51,7 @@ final class PestDatasetCommand extends Command throw new InvalidConsoleArgument(sprintf('%s already exist', $target)); } - if (!File::exists(dirname($relativePath))) { + if (! File::exists(dirname($relativePath))) { File::makeDirectory(dirname($relativePath)); } @@ -63,10 +61,10 @@ final class PestDatasetCommand extends Command 'Dataset.php', ])); - $name = mb_strtolower($name); + $name = mb_strtolower($name); $contents = str_replace('{dataset_name}', $name, $contents); - $element = Str::singular($name); + $element = Str::singular($name); $contents = str_replace('{dataset_element}', $element, $contents); File::put($target, str_replace('{dataset_name}', $name, $contents)); $message = sprintf('`%s` created successfully.', $relativePath); diff --git a/src/Laravel/Commands/PestInstallCommand.php b/src/Laravel/Commands/PestInstallCommand.php index 36bfc2d2..1f73faf3 100644 --- a/src/Laravel/Commands/PestInstallCommand.php +++ b/src/Laravel/Commands/PestInstallCommand.php @@ -8,9 +8,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Pest\Console\Thanks; use Pest\Exceptions\InvalidConsoleArgument; - use function Pest\testDirectory; - use Pest\TestSuite; /** @@ -41,7 +39,7 @@ final class PestInstallCommand extends Command TestSuite::getInstance(base_path(), $this->option('test-directory')); /* @phpstan-ignore-next-line */ - $pest = base_path(testDirectory('Pest.php')); + $pest = base_path(testDirectory('Pest.php')); $stubs = 'stubs/Laravel'; if (File::exists($pest)) { @@ -56,7 +54,7 @@ final class PestInstallCommand extends Command $this->output->success('`tests/Pest.php` created successfully.'); - if (!(bool) $this->option('no-interaction')) { + if (! (bool) $this->option('no-interaction')) { (new Thanks($this->output))(); } } diff --git a/src/Laravel/Commands/PestTestCommand.php b/src/Laravel/Commands/PestTestCommand.php index aa67459e..efcbe698 100644 --- a/src/Laravel/Commands/PestTestCommand.php +++ b/src/Laravel/Commands/PestTestCommand.php @@ -8,9 +8,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Pest\Exceptions\InvalidConsoleArgument; use Pest\Support\Str; - use function Pest\testDirectory; - use Pest\TestSuite; /** @@ -54,11 +52,11 @@ final class PestTestCommand extends Command /* @phpstan-ignore-next-line */ $target = base_path($relativePath); - if (!File::isDirectory(dirname($target))) { + if (! File::isDirectory(dirname($target))) { File::makeDirectory(dirname($target), 0777, true, true); } - if (File::exists($target) && !(bool) $this->option('force')) { + if (File::exists($target) && ! (bool) $this->option('force')) { throw new InvalidConsoleArgument(sprintf('%s already exist', $target)); } diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index d1020cae..7876499d 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -38,7 +38,7 @@ final class Expectation /** * Creates a new expectation. * - * @param TValue $value + * @param TValue $value */ public function __construct( public mixed $value @@ -180,7 +180,7 @@ final class Expectation // @phpstan-ignore-next-line Assert::assertStringContainsString((string) $needle, $this->value); } else { - if (!is_iterable($this->value)) { + if (! is_iterable($this->value)) { InvalidExpectationValue::expected('iterable'); } Assert::assertContains($needle, $this->value); @@ -193,13 +193,12 @@ final class Expectation /** * Asserts that the value starts with $expected. * - * @param non-empty-string $expected - * + * @param non-empty-string $expected *@return Expectation */ public function toStartWith(string $expected): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -211,13 +210,12 @@ final class Expectation /** * Asserts that the value ends with $expected. * - * @param non-empty-string $expected - * + * @param non-empty-string $expected *@return Expectation */ public function toEndWith(string $expected): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -265,7 +263,7 @@ final class Expectation */ public function toHaveCount(int $count): Expectation { - if (!is_countable($this->value) && !is_iterable($this->value)) { + if (! is_countable($this->value) && ! is_iterable($this->value)) { InvalidExpectationValue::expected('string'); } @@ -297,8 +295,7 @@ final class Expectation /** * Asserts that the value contains the provided properties $names. * - * @param iterable $names - * + * @param iterable $names *@return Expectation */ public function toHaveProperties(iterable $names): Expectation @@ -356,8 +353,7 @@ final class Expectation /** * Asserts that the value is one of the given values. * - * @param iterable $values - * + * @param iterable $values * @return Expectation */ public function toBeIn(iterable $values): Expectation @@ -382,8 +378,7 @@ final class Expectation /** * Asserts that the value is an instance of $class. * - * @param class-string $class - * + * @param class-string $class * @return Expectation */ public function toBeInstanceOf(string $class): Expectation @@ -595,15 +590,14 @@ final class Expectation /** * Asserts that the value array has the provided $keys. * - * @param array> $keys - * + * @param array> $keys * @return Expectation */ public function toHaveKeys(array $keys): Expectation { foreach ($keys as $k => $key) { if (is_array($key)) { - $this->toHaveKeys(array_keys(Arr::dot($key, $k . '.'))); + $this->toHaveKeys(array_keys(Arr::dot($key, $k.'.'))); } else { $this->toHaveKey($key); } @@ -619,7 +613,7 @@ final class Expectation */ public function toBeDirectory(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -635,7 +629,7 @@ final class Expectation */ public function toBeReadableDirectory(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -651,7 +645,7 @@ final class Expectation */ public function toBeWritableDirectory(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -667,7 +661,7 @@ final class Expectation */ public function toBeFile(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -683,7 +677,7 @@ final class Expectation */ public function toBeReadableFile(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } @@ -699,7 +693,7 @@ final class Expectation */ public function toBeWritableFile(): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } Assert::assertFileIsWritable($this->value); @@ -710,8 +704,7 @@ final class Expectation /** * Asserts that the value array matches the given array subset. * - * @param iterable $array - * + * @param iterable $array * @return Expectation */ public function toMatchArray(iterable $array): Expectation @@ -743,14 +736,13 @@ final class Expectation * Asserts that the value object matches a subset * of the properties of an given object. * - * @param iterable $object - * + * @param iterable $object * @return Expectation */ public function toMatchObject(iterable $object): Expectation { foreach ((array) $object as $property => $value) { - if (!is_object($this->value) && !is_string($this->value)) { + if (! is_object($this->value) && ! is_string($this->value)) { InvalidExpectationValue::expected('object|string'); } @@ -779,7 +771,7 @@ final class Expectation */ public function toMatch(string $expression): Expectation { - if (!is_string($this->value)) { + if (! is_string($this->value)) { InvalidExpectationValue::expected('string'); } Assert::assertMatchesRegularExpression($expression, $this->value); @@ -800,13 +792,12 @@ final class Expectation } /** - * @param class-string $class - * + * @param class-string $class * @return Expectation */ public function toContainOnlyInstancesOf(string $class): Expectation { - if (!is_iterable($this->value)) { + if (! is_iterable($this->value)) { InvalidExpectationValue::expected('iterable'); } @@ -819,7 +810,6 @@ final class Expectation * Asserts that executing value throws an exception. * * @param (Closure(Throwable): mixed)|string $exception - * * @return Expectation */ public function toThrow(callable|string $exception, string $exceptionMessage = null): Expectation @@ -827,14 +817,14 @@ final class Expectation $callback = NullClosure::create(); if ($exception instanceof Closure) { - $callback = $exception; + $callback = $exception; $parameters = (new ReflectionFunction($exception))->getParameters(); if (1 !== count($parameters)) { throw new InvalidArgumentException('The given closure must have a single parameter type-hinted as the class string.'); } - if (!($type = $parameters[0]->getType()) instanceof ReflectionNamedType) { + if (! ($type = $parameters[0]->getType()) instanceof ReflectionNamedType) { throw new InvalidArgumentException('The given closure\'s parameter must be type-hinted as the class string.'); } @@ -844,7 +834,7 @@ final class Expectation try { ($this->value)(); } catch (Throwable $e) { - if (!class_exists($exception)) { + if (! class_exists($exception)) { if ($e instanceof Error && $e->getMessage() === "Class \"$exception\" not found") { throw $e; } @@ -864,7 +854,7 @@ final class Expectation return $this; } - if (!class_exists($exception)) { + if (! class_exists($exception)) { throw new ExpectationFailedException("Exception with message \"$exception\" not thrown."); } diff --git a/src/PendingCalls/AfterEachCall.php b/src/PendingCalls/AfterEachCall.php index 2bf0b16a..084d5b6d 100644 --- a/src/PendingCalls/AfterEachCall.php +++ b/src/PendingCalls/AfterEachCall.php @@ -57,7 +57,7 @@ final class AfterEachCall /** * Saves the calls to be used on the target. * - * @param array $arguments + * @param array $arguments */ public function __call(string $name, array $arguments): self { diff --git a/src/PendingCalls/BeforeEachCall.php b/src/PendingCalls/BeforeEachCall.php index 8fc5a08f..7a8cf589 100644 --- a/src/PendingCalls/BeforeEachCall.php +++ b/src/PendingCalls/BeforeEachCall.php @@ -57,7 +57,7 @@ final class BeforeEachCall /** * Saves the calls to be used on the target. * - * @param array $arguments + * @param array $arguments */ public function __call(string $name, array $arguments): self { diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 19daf85d..49511443 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -42,7 +42,7 @@ final class TestCall string $description = null, Closure $closure = null ) { - $this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure); + $this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure); $this->descriptionLess = $description === null; } @@ -100,7 +100,7 @@ final class TestCall * Runs the current test multiple times with * each item of the given `iterable`. * - * @param array<\Closure|iterable|string> $data + * @param array<\Closure|iterable|string> $data */ public function with(Closure|iterable|string ...$data): TestCall { @@ -178,10 +178,10 @@ final class TestCall public function covers(string ...$classesOrFunctions): TestCall { foreach ($classesOrFunctions as $classOrFunction) { - $isClass = class_exists($classOrFunction); + $isClass = class_exists($classOrFunction); $isMethod = function_exists($classOrFunction); - if (!$isClass && !$isMethod) { + if (! $isClass && ! $isMethod) { throw new InvalidArgumentException(sprintf('No class or method named "%s" has been found.', $classOrFunction)); } @@ -252,7 +252,7 @@ final class TestCall /** * Saves the calls to be used on the target. * - * @param array $arguments + * @param array $arguments */ public function __call(string $name, array $arguments): self { @@ -262,7 +262,7 @@ final class TestCall /** * Add a chain to the test case factory. Omitting the arguments will treat it as a property accessor. * - * @param array|null $arguments + * @param array|null $arguments */ private function addChain(string $file, int $line, string $name, array $arguments = null): self { diff --git a/src/PendingCalls/UsesCall.php b/src/PendingCalls/UsesCall.php index df6b6dcb..47a26c6c 100644 --- a/src/PendingCalls/UsesCall.php +++ b/src/PendingCalls/UsesCall.php @@ -43,7 +43,7 @@ final class UsesCall /** * Creates a new Pending Call. * - * @param array $classAndTraits + * @param array $classAndTraits */ public function __construct( private string $filename, @@ -58,7 +58,7 @@ final class UsesCall */ public function in(string ...$targets): void { - $targets = array_map(function ($path): string { + $targets = array_map(function ($path): string { $startChar = DIRECTORY_SEPARATOR; if ('\\' === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $path) > 0) { diff --git a/src/Pest.php b/src/Pest.php index e6b0e1f7..b56ceb0b 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -11,5 +11,5 @@ function version(): string function testDirectory(string $file = ''): string { - return TestSuite::getInstance()->testPath . '/' . $file; + return TestSuite::getInstance()->testPath.'/'.$file; } diff --git a/src/Plugin.php b/src/Plugin.php index 6e73d59c..55c91134 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -18,12 +18,12 @@ final class Plugin /** * Lazy loads an `uses` call on the context of plugins. * - * @param class-string ...$traits + * @param class-string ...$traits */ public static function uses(string ...$traits): void { self::$callables[] = function () use ($traits): void { - uses(...$traits)->in(TestSuite::getInstance()->rootPath . DIRECTORY_SEPARATOR . testDirectory()); + uses(...$traits)->in(TestSuite::getInstance()->rootPath.DIRECTORY_SEPARATOR.testDirectory()); }; } } diff --git a/src/Plugins/Actions/HandleArguments.php b/src/Plugins/Actions/HandleArguments.php index e26a9baa..6b466e45 100644 --- a/src/Plugins/Actions/HandleArguments.php +++ b/src/Plugins/Actions/HandleArguments.php @@ -17,8 +17,7 @@ final class HandleArguments * * Transform the input arguments by passing it to the relevant plugins. * - * @param array $argv - * + * @param array $argv * @return array */ public function __invoke(array $argv): array diff --git a/src/Plugins/Concerns/HandleArguments.php b/src/Plugins/Concerns/HandleArguments.php index 6ff49496..4734a045 100644 --- a/src/Plugins/Concerns/HandleArguments.php +++ b/src/Plugins/Concerns/HandleArguments.php @@ -12,7 +12,7 @@ trait HandleArguments /** * Checks if the given argument exists on the arguments. * - * @param array $arguments + * @param array $arguments */ public function hasArgument(string $argument, array $arguments): bool { @@ -22,8 +22,7 @@ trait HandleArguments /** * Adds the given argument and value to the list of arguments. * - * @param array $arguments - * + * @param array $arguments * @return array */ public function pushArgument(string $argument, array $arguments): array @@ -36,8 +35,7 @@ trait HandleArguments /** * Pops the given argument from the arguments. * - * @param array $arguments - * + * @param array $arguments * @return array */ public function popArgument(string $argument, array $arguments): array diff --git a/src/Plugins/Coverage.php b/src/Plugins/Coverage.php index 75a0e18c..2e6cdcf1 100644 --- a/src/Plugins/Coverage.php +++ b/src/Plugins/Coverage.php @@ -66,15 +66,15 @@ final class Coverage implements AddsOutput, HandlesArguments } $originals = array_flip($originals); - $inputs = []; + $inputs = []; $inputs[] = new InputOption(self::COVERAGE_OPTION, null, InputOption::VALUE_NONE); $inputs[] = new InputOption(self::MIN_OPTION, null, InputOption::VALUE_REQUIRED); $input = new ArgvInput($arguments, new InputDefinition($inputs)); if ((bool) $input->getOption(self::COVERAGE_OPTION)) { $this->coverage = true; - $originals[] = '--coverage-php'; - $originals[] = \Pest\Support\Coverage::getPath(); + $originals[] = '--coverage-php'; + $originals[] = \Pest\Support\Coverage::getPath(); } if ($input->getOption(self::MIN_OPTION) !== null) { @@ -93,7 +93,7 @@ final class Coverage implements AddsOutput, HandlesArguments public function addOutput(int $exitCode): int { if ($exitCode === 0 && $this->coverage) { - if (!\Pest\Support\Coverage::isAvailable()) { + if (! \Pest\Support\Coverage::isAvailable()) { $this->output->writeln( "\n ERROR No code coverage driver is available.", ); diff --git a/src/Plugins/Init.php b/src/Plugins/Init.php index 331f2a99..1a6ecf88 100644 --- a/src/Plugins/Init.php +++ b/src/Plugins/Init.php @@ -23,8 +23,8 @@ final class Init implements HandlesArguments * The files that will be created. */ private const STUBS = [ - 'phpunit.xml' => 'phpunit.xml', - 'Pest.php' => 'tests/Pest.php', + 'phpunit.xml' => 'phpunit.xml', + 'Pest.php' => 'tests/Pest.php', 'ExampleTest.php' => 'tests/ExampleTest.php', ]; @@ -43,7 +43,7 @@ final class Init implements HandlesArguments */ public function handleArguments(array $arguments): array { - if (!array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) { + if (! array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) { return $arguments; } @@ -58,8 +58,8 @@ final class Init implements HandlesArguments { $testsBaseDir = "{$this->testSuite->rootPath}/tests"; - if (!is_dir($testsBaseDir)) { - if (!mkdir($testsBaseDir) && !is_dir($testsBaseDir)) { + if (! is_dir($testsBaseDir)) { + if (! mkdir($testsBaseDir) && ! is_dir($testsBaseDir)) { $this->output->writeln(sprintf( "\n ERROR Directory `%s` was not created.", $testsBaseDir @@ -74,8 +74,8 @@ final class Init implements HandlesArguments } foreach (self::STUBS as $from => $to) { - $fromPath = __DIR__ . "/../../stubs/init/{$from}"; - $toPath = "{$this->testSuite->rootPath}/{$to}"; + $fromPath = __DIR__."/../../stubs/init/{$from}"; + $toPath = "{$this->testSuite->rootPath}/{$to}"; if (file_exists($toPath)) { $this->output->writeln(sprintf( @@ -86,16 +86,16 @@ final class Init implements HandlesArguments continue; } - if ($from === 'phpunit.xml' && file_exists($toPath . '.dist')) { + if ($from === 'phpunit.xml' && file_exists($toPath.'.dist')) { $this->output->writeln(sprintf( ' INFO File `%s` already exists, skipped.', - $to . '.dist' + $to.'.dist' )); continue; } - if (!copy($fromPath, $toPath)) { + if (! copy($fromPath, $toPath)) { $this->output->writeln(sprintf( '[WARNING] Failed to copy stub `%s` to `%s`', $from, diff --git a/src/Plugins/Printer.php b/src/Plugins/Printer.php index d594031d..b4f4bee3 100644 --- a/src/Plugins/Printer.php +++ b/src/Plugins/Printer.php @@ -18,7 +18,7 @@ final class Printer implements HandlesArguments */ public function handleArguments(array $arguments): array { - if (!array_key_exists('COLLISION_PRINTER', $_SERVER)) { + if (! array_key_exists('COLLISION_PRINTER', $_SERVER)) { return $arguments; } diff --git a/src/Plugins/Version.php b/src/Plugins/Version.php index e70e22b5..5452237a 100644 --- a/src/Plugins/Version.php +++ b/src/Plugins/Version.php @@ -5,9 +5,7 @@ declare(strict_types=1); namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; - use function Pest\version; - use Symfony\Component\Console\Output\OutputInterface; /** diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index c4597fd3..58866d7d 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -9,9 +9,7 @@ use Pest\Exceptions\DatasetAlreadyExist; use Pest\Exceptions\DatasetDoesNotExist; use Pest\Exceptions\ShouldNotHappen; use SebastianBergmann\Exporter\Exporter; - use function sprintf; - use Traversable; /** @@ -36,7 +34,7 @@ final class DatasetsRepository /** * Sets the given. * - * @param Closure|iterable $data + * @param Closure|iterable $data */ public static function set(string $name, Closure|iterable $data): void { @@ -50,16 +48,16 @@ final class DatasetsRepository /** * Sets the given "with". * - * @param array|string> $with + * @param array|string> $with */ public static function with(string $filename, string $description, array $with): void { - self::$withs[$filename . '>>>' . $description] = $with; + self::$withs[$filename.'>>>'.$description] = $with; } public static function has(string $filename, string $description): bool { - return array_key_exists($filename . '>>>' . $description, self::$withs); + return array_key_exists($filename.'>>>'.$description, self::$withs); } /** @@ -69,7 +67,7 @@ final class DatasetsRepository */ public static function get(string $filename, string $description): Closure|iterable { - $dataset = self::$withs[$filename . '>>>' . $description]; + $dataset = self::$withs[$filename.'>>>'.$description]; $dataset = self::resolve($description, $dataset); @@ -83,8 +81,7 @@ final class DatasetsRepository /** * Resolves the current dataset to an array value. * - * @param array|string> $dataset - * + * @param array|string> $dataset * @return array|null */ public static function resolve(string $description, array $dataset): array|null @@ -99,11 +96,11 @@ final class DatasetsRepository $datasetCombinations = self::getDatasetsCombinations($dataset); $datasetDescriptions = []; - $datasetValues = []; + $datasetValues = []; foreach ($datasetCombinations as $datasetCombination) { $partialDescriptions = []; - $values = []; + $values = []; foreach ($datasetCombination as $datasetCombinationElement) { $partialDescriptions[] = $datasetCombinationElement['label']; @@ -113,7 +110,7 @@ final class DatasetsRepository } $datasetDescriptions[] = implode(' / ', $partialDescriptions); - $datasetValues[] = $values; + $datasetValues[] = $values; } foreach (array_count_values($datasetDescriptions) as $descriptionToCheck => $count) { @@ -136,8 +133,7 @@ final class DatasetsRepository } /** - * @param array|string> $datasets - * + * @param array|string> $datasets * @return array> */ private static function processDatasets(array $datasets): array @@ -148,7 +144,7 @@ final class DatasetsRepository $processedDataset = []; if (is_string($data)) { - if (!array_key_exists($data, self::$datasets)) { + if (! array_key_exists($data, self::$datasets)) { throw new DatasetDoesNotExist($data); } @@ -165,9 +161,9 @@ final class DatasetsRepository // @phpstan-ignore-next-line foreach ($datasets[$index] as $key => $values) { - $values = is_array($values) ? $values : [$values]; + $values = is_array($values) ? $values : [$values]; $processedDataset[] = [ - 'label' => self::getDatasetDescription($key, $values), // @phpstan-ignore-line + 'label' => self::getDatasetDescription($key, $values), // @phpstan-ignore-line 'values' => $values, ]; } @@ -179,8 +175,7 @@ final class DatasetsRepository } /** - * @param array> $combinations - * + * @param array> $combinations * @return array>> */ private static function getDatasetsCombinations(array $combinations): array @@ -201,7 +196,7 @@ final class DatasetsRepository } /** - * @param array $data + * @param array $data */ private static function getDatasetDescription(int|string $key, array $data): string { diff --git a/src/Repositories/TempRepository.php b/src/Repositories/TempRepository.php index a8e21bb4..57e3c9a7 100644 --- a/src/Repositories/TempRepository.php +++ b/src/Repositories/TempRepository.php @@ -9,7 +9,7 @@ namespace Pest\Repositories; */ final class TempRepository { - private const FOLDER = __DIR__ . '/../../.temp'; + private const FOLDER = __DIR__.'/../../.temp'; /** * Creates a new Temp Repository instance. @@ -35,7 +35,7 @@ final class TempRepository */ public function boot(): void { - @unlink(self::FOLDER . '/' . $this->filename . '.json'); // @phpstan-ignore-line + @unlink(self::FOLDER.'/'.$this->filename.'.json'); // @phpstan-ignore-line $this->save([]); } @@ -55,7 +55,7 @@ final class TempRepository */ private function all(): array { - $contents = file_get_contents(self::FOLDER . '/' . $this->filename . '.json'); + $contents = file_get_contents(self::FOLDER.'/'.$this->filename.'.json'); assert(is_string($contents)); @@ -67,12 +67,12 @@ final class TempRepository /** * Save the given elements. * - * @param array $elements + * @param array $elements */ private function save(array $elements): void { $contents = json_encode($elements); - file_put_contents(self::FOLDER . '/' . $this->filename . '.json', $contents); + file_put_contents(self::FOLDER.'/'.$this->filename.'.json', $contents); } } diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index 94ffd17a..80e4b19b 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -54,15 +54,15 @@ final class TestRepository /** * Uses the given `$testCaseClass` on the given `$paths`. * - * @param array $classOrTraits - * @param array $groups - * @param array $paths - * @param array $hooks + * @param array $classOrTraits + * @param array $groups + * @param array $paths + * @param array $hooks */ public function use(array $classOrTraits, array $groups, array $paths, array $hooks): void { foreach ($classOrTraits as $classOrTrait) { - if (!class_exists($classOrTrait) && !trait_exists($classOrTrait)) { + if (! class_exists($classOrTrait) && ! trait_exists($classOrTrait)) { throw new TestCaseClassOrTraitNotFound($classOrTrait); } } @@ -90,7 +90,7 @@ final class TestRepository */ public function set(TestCaseMethodFactory $method): void { - if (!array_key_exists($method->filename, $this->testCases)) { + if (! array_key_exists($method->filename, $this->testCases)) { $this->testCases[$method->filename] = new TestCaseFactory($method->filename); } @@ -112,12 +112,12 @@ final class TestRepository */ private function make(TestCaseFactory $testCase): void { - $startsWith = static fn (string $target, string $directory): bool => Str::startsWith($target, $directory . DIRECTORY_SEPARATOR); + $startsWith = static fn (string $target, string $directory): bool => Str::startsWith($target, $directory.DIRECTORY_SEPARATOR); foreach ($this->uses as $path => $uses) { [$classOrTraits, $groups, $hooks] = $uses; - if ((!is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) { + if ((! is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) { foreach ($classOrTraits as $class) { /** @var string $class */ if (class_exists($class)) { diff --git a/src/Support/Arr.php b/src/Support/Arr.php index f4eb19e2..337be46c 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -12,7 +12,7 @@ final class Arr /** * Checks if the given array has the given key. * - * @param array $array + * @param array $array */ public static function has(array $array, string|int $key): bool { @@ -36,7 +36,7 @@ final class Arr /** * Gets the given key value. * - * @param array $array + * @param array $array */ public static function get(array $array, string|int $key, mixed $default = null): mixed { @@ -46,7 +46,7 @@ final class Arr return $array[$key]; } - if (!str_contains($key, '.')) { + if (! str_contains($key, '.')) { return $array[$key] ?? $default; } @@ -64,8 +64,7 @@ final class Arr /** * Flatten a multi-dimensional associative array with dots. * - * @param array $array - * + * @param array $array * @return array */ public static function dot(array $array, string $prepend = ''): array @@ -74,9 +73,9 @@ final class Arr foreach ($array as $key => $value) { if (is_array($value) && count($value) > 0) { - $results = array_merge($results, static::dot($value, $prepend . $key . '.')); + $results = array_merge($results, static::dot($value, $prepend.$key.'.')); } else { - $results[$prepend . $value] = $value; + $results[$prepend.$value] = $value; } } diff --git a/src/Support/ChainableClosure.php b/src/Support/ChainableClosure.php index 5c92e6fd..3c228872 100644 --- a/src/Support/ChainableClosure.php +++ b/src/Support/ChainableClosure.php @@ -18,7 +18,7 @@ final class ChainableClosure public static function from(Closure $closure, Closure $next): Closure { return function () use ($closure, $next): void { - if (!is_object($this)) { // @phpstan-ignore-line + if (! is_object($this)) { // @phpstan-ignore-line throw ShouldNotHappen::fromMessage('$this not bound to chainable closure.'); } diff --git a/src/Support/Container.php b/src/Support/Container.php index 67cd4e39..c2314875 100644 --- a/src/Support/Container.php +++ b/src/Support/Container.php @@ -35,13 +35,12 @@ final class Container /** * Gets a dependency from the container. * - * @param class-string $id - * + * @param class-string $id * @return mixed */ public function get(string $id) { - if (!array_key_exists($id, $this->instances)) { + if (! array_key_exists($id, $this->instances)) { $this->instances[$id] = $this->build($id); } @@ -51,7 +50,7 @@ final class Container /** * Adds the given instance to the container. * - * @param mixed $instance + * @param mixed $instance */ public function add(string $id, $instance): void { @@ -61,7 +60,7 @@ final class Container /** * Tries to build the given instance. * - * @param class-string $id + * @param class-string $id */ private function build(string $id): object { diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index 7d0ae034..681a4cf1 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -11,7 +11,6 @@ use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\Environment\Runtime; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Terminal; - use function Termwind\render; use function Termwind\renderUsing; @@ -54,7 +53,7 @@ final class Coverage */ public static function report(OutputInterface $output): float { - if (!file_exists($reportPath = self::getPath())) { + if (! file_exists($reportPath = self::getPath())) { if (self::usingXdebug()) { $output->writeln( " WARN Unable to get coverage using Xdebug. Did you set Xdebug's coverage mode?", @@ -80,10 +79,10 @@ final class Coverage $report = $codeCoverage->getReport(); foreach ($report->getIterator() as $file) { - if (!$file instanceof File) { + if (! $file instanceof File) { continue; } - $dirname = dirname($file->id()); + $dirname = dirname($file->id()); $basename = basename($file->id(), '.php'); $name = $dirname === '.' ? $basename : implode(DIRECTORY_SEPARATOR, [ @@ -106,7 +105,7 @@ final class Coverage ? '100.0' : number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', ''); - $takenSize = strlen($rawName . $percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign + $takenSize = strlen($rawName.$percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign $percentage = sprintf( '%s', @@ -146,8 +145,7 @@ final class Coverage * ['11', '20..25', '50', '60..80']; * ``` * - * @param File $file - * + * @param File $file * @return array */ public static function getMissingCoverage($file): array @@ -162,7 +160,7 @@ final class Coverage } if ($shouldBeNewLine) { - $array[] = (string) $line; + $array[] = (string) $line; $shouldBeNewLine = false; return $array; @@ -171,7 +169,7 @@ final class Coverage $lastKey = count($array) - 1; if (array_key_exists($lastKey, $array) && str_contains($array[$lastKey], '..')) { - [$from] = explode('..', $array[$lastKey]); + [$from] = explode('..', $array[$lastKey]); $array[$lastKey] = $line > $from ? sprintf('%s..%s', $from, $line) : sprintf('%s..%s', $line, $from); return $array; diff --git a/src/Support/ExceptionTrace.php b/src/Support/ExceptionTrace.php index 28c5d43b..faa5080b 100644 --- a/src/Support/ExceptionTrace.php +++ b/src/Support/ExceptionTrace.php @@ -44,7 +44,7 @@ final class ExceptionTrace */ public static function removePestReferences(Throwable $t): void { - if (!property_exists($t, 'serializableTrace')) { + if (! property_exists($t, 'serializableTrace')) { return; } diff --git a/src/Support/ExpectationPipeline.php b/src/Support/ExpectationPipeline.php index 11481576..e39251e0 100644 --- a/src/Support/ExpectationPipeline.php +++ b/src/Support/ExpectationPipeline.php @@ -59,7 +59,7 @@ final class ExpectationPipeline /** * Sets the list of pipes. * - * @param array $pipes + * @param array $pipes */ public function through(array $pipes): self { diff --git a/src/Support/HigherOrderCallables.php b/src/Support/HigherOrderCallables.php index 1ccf1f9f..de4fee59 100644 --- a/src/Support/HigherOrderCallables.php +++ b/src/Support/HigherOrderCallables.php @@ -26,7 +26,6 @@ final class HigherOrderCallables * Create a new expectation. Callable values will be executed prior to returning the new expectation. * * @param (Closure():TValue)|TValue $value - * * @return Expectation */ public function expect(mixed $value): Expectation @@ -42,8 +41,7 @@ final class HigherOrderCallables * * Create a new expectation. Callable values will be executed prior to returning the new expectation. * - * @param callable|TValue $value - * + * @param callable|TValue $value * @return Expectation<(callable(): mixed)|TValue> */ public function and(mixed $value) diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index 766a9743..75cfe66e 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -25,7 +25,7 @@ final class HigherOrderMessage /** * Creates a new higher order message. * - * @param array $arguments + * @param array $arguments */ public function __construct( public string $filename, @@ -41,7 +41,7 @@ final class HigherOrderMessage * * @template TValue of object * - * @param TValue $target + * @param TValue $target */ public function call(object $target): mixed { @@ -77,7 +77,7 @@ final class HigherOrderMessage /** * Indicates that this message should only be called when the given condition is true. * - * @param callable(): bool $condition + * @param callable(): bool $condition */ public function when(callable $condition): self { diff --git a/src/Support/HigherOrderMessageCollection.php b/src/Support/HigherOrderMessageCollection.php index 6d4bca2b..8f5be734 100644 --- a/src/Support/HigherOrderMessageCollection.php +++ b/src/Support/HigherOrderMessageCollection.php @@ -17,7 +17,7 @@ final class HigherOrderMessageCollection /** * Adds a new higher order message to the collection. * - * @param array|null $arguments + * @param array|null $arguments */ public function add(string $filename, int $line, string $name, ?array $arguments): void { @@ -27,7 +27,7 @@ final class HigherOrderMessageCollection /** * Adds a new higher order message to the collection if the callable condition is does not return false. * - * @param array|null $arguments + * @param array|null $arguments */ public function addWhen(callable $condition, string $filename, int $line, string $name, ?array $arguments): void { @@ -58,7 +58,7 @@ final class HigherOrderMessageCollection /** * Count the number of messages with the given name. * - * @param string $name A higher order message name (usually a method name) + * @param string $name A higher order message name (usually a method name) */ public function count(string $name): int { diff --git a/src/Support/HigherOrderTapProxy.php b/src/Support/HigherOrderTapProxy.php index 9bcfb479..d11dba28 100644 --- a/src/Support/HigherOrderTapProxy.php +++ b/src/Support/HigherOrderTapProxy.php @@ -27,7 +27,7 @@ final class HigherOrderTapProxy /** * Dynamically sets properties on the target. * - * @param mixed $value + * @param mixed $value */ public function __set(string $property, $value): void { @@ -60,14 +60,13 @@ final class HigherOrderTapProxy /** * Dynamically pass method calls to the target. * - * @param array $arguments - * + * @param array $arguments * @return mixed */ public function __call(string $methodName, array $arguments) { $filename = Backtrace::file(); - $line = Backtrace::line(); + $line = Backtrace::line(); return (new HigherOrderMessage($filename, $line, $methodName, $arguments)) ->call($this->target); diff --git a/src/Support/Printer.php b/src/Support/Printer.php index b321391c..4d3863ce 100644 --- a/src/Support/Printer.php +++ b/src/Support/Printer.php @@ -33,7 +33,7 @@ abstract class Printer implements \PHPUnit\Util\Printer $this->isPhpStream = str_starts_with($out, 'php://'); - if (!$this->isPhpStream && !Filesystem::createDirectory(dirname($out))) { + if (! $this->isPhpStream && ! Filesystem::createDirectory(dirname($out))) { throw new Exception(sprintf('Directory "%s" was not created', dirname($out))); } diff --git a/src/Support/Reflection.php b/src/Support/Reflection.php index c4b2572e..d961a401 100644 --- a/src/Support/Reflection.php +++ b/src/Support/Reflection.php @@ -22,8 +22,7 @@ final class Reflection /** * Calls the given method with args on the given object. * - * @param array $args - * + * @param array $args * @return mixed */ public static function call(object $object, string $method, array $args = []) @@ -52,8 +51,7 @@ final class Reflection /** * Bind a callable to the TestCase and return the result. * - * @param array $args - * + * @param array $args * @return mixed */ public static function bindCallable(callable $callable, array $args = []) @@ -104,7 +102,7 @@ final class Reflection } catch (ReflectionException $reflectionException) { $reflectionClass = $reflectionClass->getParentClass(); - if (!$reflectionClass instanceof ReflectionClass) { + if (! $reflectionClass instanceof ReflectionClass) { throw new ShouldNotHappen($reflectionException); } } @@ -120,8 +118,8 @@ final class Reflection * * @template TValue of object * - * @param TValue $object - * @param mixed $value + * @param TValue $object + * @param mixed $value */ public static function setPropertyValue(object $object, string $property, $value): void { @@ -137,7 +135,7 @@ final class Reflection } catch (ReflectionException $reflectionException) { $reflectionClass = $reflectionClass->getParentClass(); - if (!$reflectionClass instanceof ReflectionClass) { + if (! $reflectionClass instanceof ReflectionClass) { throw new ShouldNotHappen($reflectionException); } } @@ -156,7 +154,7 @@ final class Reflection { $type = $parameter->getType(); - if (!$type instanceof ReflectionNamedType || $type->isBuiltin()) { + if (! $type instanceof ReflectionNamedType || $type->isBuiltin()) { return null; } @@ -183,7 +181,7 @@ final class Reflection public static function getFunctionArguments(Closure $function): array { $parameters = (new ReflectionFunction($function))->getParameters(); - $arguments = []; + $arguments = []; foreach ($parameters as $parameter) { /** @var ReflectionNamedType|ReflectionUnionType|null $types */ diff --git a/src/Support/Str.php b/src/Support/Str.php index 0314e11f..69522b6a 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -19,7 +19,7 @@ final class Str * Create a (unsecure & non-cryptographically safe) random alpha-numeric * string value. * - * @param int $length the length of the resulting randomized string + * @param int $length the length of the resulting randomized string * * @see https://github.com/laravel/framework/blob/4.2/src/Illuminate/Support/Str.php#L240-L242 */ diff --git a/src/TestSuite.php b/src/TestSuite.php index 7ff5c130..c460f532 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -70,11 +70,11 @@ final class TestSuite string $rootPath, public string $testPath) { - $this->beforeAll = new BeforeAllRepository(); - $this->beforeEach = new BeforeEachRepository(); - $this->tests = new TestRepository(); - $this->afterEach = new AfterEachRepository(); - $this->afterAll = new AfterAllRepository(); + $this->beforeAll = new BeforeAllRepository(); + $this->beforeEach = new BeforeEachRepository(); + $this->tests = new TestRepository(); + $this->afterEach = new AfterEachRepository(); + $this->afterAll = new AfterAllRepository(); $this->retryTempRepository = new TempRepository('retry'); $this->rootPath = (string) realpath($rootPath); diff --git a/tests/Features/AfterAll.php b/tests/Features/AfterAll.php index 8a018079..1be6eaf1 100644 --- a/tests/Features/AfterAll.php +++ b/tests/Features/AfterAll.php @@ -1,6 +1,6 @@ bar = 0; beforeAll(function () use ($foo) { diff --git a/tests/Features/Coverage.php b/tests/Features/Coverage.php index 22d58a47..48dba8cc 100644 --- a/tests/Features/Coverage.php +++ b/tests/Features/Coverage.php @@ -35,16 +35,17 @@ it('adds coverage if --min exist', function () { }); it('generates coverage based on file input', function () { - expect(Coverage::getMissingCoverage(new class() { + expect(Coverage::getMissingCoverage(new class() + { public function lineCoverageData(): array { return [ - 1 => ['foo'], - 2 => ['bar'], - 4 => [], - 5 => [], - 6 => [], - 7 => null, + 1 => ['foo'], + 2 => ['bar'], + 4 => [], + 5 => [], + 6 => [], + 7 => null, 100 => null, 101 => ['foo'], 102 => [], diff --git a/tests/Features/Datasets.php b/tests/Features/Datasets.php index 1fc3bd43..183b2d3b 100644 --- a/tests/Features/Datasets.php +++ b/tests/Features/Datasets.php @@ -46,7 +46,7 @@ test('it truncates the description', function () { // it gets tested by the integration test })->with([str_repeat('Fooo', 10)]); -$state = new stdClass(); +$state = new stdClass(); $state->text = ''; $datasets = [[1], [2]]; @@ -148,7 +148,7 @@ $datasets_a = [[1], [2]]; $datasets_b = [[3], [4]]; test('lazy multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets_a)->toContain([$text_a]); expect($datasets_b)->toContain([$text_b]); })->with($datasets_a, $datasets_b); @@ -160,7 +160,7 @@ test('lazy multiple datasets did the job right', function () use ($state) { $state->text = ''; test('eager multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets_a)->toContain([$text_a]); expect($datasets_b)->toContain([$text_b]); })->with(function () use ($datasets_a) { @@ -174,7 +174,7 @@ test('eager multiple datasets did the job right', function () use ($state) { }); test('lazy registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets)->toContain([$text_a]); expect($datasets)->toContain([$text_b]); })->with('numbers.array')->with('numbers.array'); @@ -184,7 +184,7 @@ test('lazy registered multiple datasets did the job right', function () use ($st }); test('eager registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets)->toContain([$text_a]); expect($datasets)->toContain([$text_b]); })->with('numbers.array')->with('numbers.closure'); @@ -194,7 +194,7 @@ test('eager registered multiple datasets did the job right', function () use ($s }); test('eager wrapped registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets)->toContain([$text_a]); expect($datasets)->toContain([$text_b]); })->with('numbers.closure.wrapped')->with('numbers.closure'); @@ -204,7 +204,7 @@ test('eager wrapped registered multiple datasets did the job right', function () }); test('named multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) { - $state->text .= $text_a . $text_b; + $state->text .= $text_a.$text_b; expect($datasets_a)->toContain([$text_a]); expect($datasets_b)->toContain([$text_b]); })->with([ @@ -212,7 +212,7 @@ test('named multiple datasets', function ($text_a, $text_b) use ($state, $datase 'two' => [2], ])->with([ 'three' => [3], - 'four' => [4], + 'four' => [4], ]); test('named multiple datasets did the job right', function () use ($state) { @@ -220,7 +220,7 @@ test('named multiple datasets did the job right', function () use ($state) { }); test('more than two datasets', function ($text_a, $text_b, $text_c) use ($state, $datasets_a, $datasets_b) { - $state->text .= $text_a . $text_b . $text_c; + $state->text .= $text_a.$text_b.$text_c; expect($datasets_a)->toContain([$text_a]); expect($datasets_b)->toContain([$text_b]); expect([5, 6])->toContain($text_c); diff --git a/tests/Features/Expect/HigherOrder/methods.php b/tests/Features/Expect/HigherOrder/methods.php index 5cac3fa9..85942c46 100644 --- a/tests/Features/Expect/HigherOrder/methods.php +++ b/tests/Features/Expect/HigherOrder/methods.php @@ -131,7 +131,7 @@ class HasMethods public function attributes() { return [ - 'name' => $this->name(), + 'name' => $this->name(), 'quantity' => $this->quantity(), ]; } @@ -141,11 +141,11 @@ class HasMethods return [ [ 'title' => 'Foo', - 'cost' => 20, + 'cost' => 20, ], [ 'title' => 'Bar', - 'cost' => 30, + 'cost' => 30, ], ]; } diff --git a/tests/Features/Expect/HigherOrder/methodsAndProperties.php b/tests/Features/Expect/HigherOrder/methodsAndProperties.php index 97e94187..61ab58e4 100644 --- a/tests/Features/Expect/HigherOrder/methodsAndProperties.php +++ b/tests/Features/Expect/HigherOrder/methodsAndProperties.php @@ -72,11 +72,11 @@ class HasMethodsAndProperties public $posts = [ [ 'is_published' => true, - 'title' => 'Foo', + 'title' => 'Foo', ], [ 'is_published' => true, - 'title' => 'Bar', + 'title' => 'Bar', ], ]; @@ -85,11 +85,11 @@ class HasMethodsAndProperties return [ [ 'title' => 'Foo', - 'cost' => 20, + 'cost' => 20, ], [ 'title' => 'Bar', - 'cost' => 30, + 'cost' => 30, ], ]; } diff --git a/tests/Features/Expect/HigherOrder/properties.php b/tests/Features/Expect/HigherOrder/properties.php index 7c15c6cc..016b1c4f 100644 --- a/tests/Features/Expect/HigherOrder/properties.php +++ b/tests/Features/Expect/HigherOrder/properties.php @@ -86,11 +86,11 @@ class HasProperties public $posts = [ [ 'is_published' => true, - 'title' => 'Foo', + 'title' => 'Foo', ], [ 'is_published' => true, - 'title' => 'Bar', + 'title' => 'Bar', ], ]; diff --git a/tests/Features/Expect/matchExpectation.php b/tests/Features/Expect/matchExpectation.php index a5b1cba8..7328cdb9 100644 --- a/tests/Features/Expect/matchExpectation.php +++ b/tests/Features/Expect/matchExpectation.php @@ -128,7 +128,7 @@ it('runs with falsy closure condition', function () { it('can be passed non-callable values', function () { expect('foo') ->match('pest', [ - 'bar' => 'foo', + 'bar' => 'foo', 'pest' => 'baz', ] ); diff --git a/tests/Features/Expect/pipes.php b/tests/Features/Expect/pipes.php index 90c00aa0..81fecd6a 100644 --- a/tests/Features/Expect/pipes.php +++ b/tests/Features/Expect/pipes.php @@ -48,10 +48,10 @@ class State public function reset(): void { $this->appliedCount = $this->runCount = [ - 'char' => 0, - 'number' => 0, + 'char' => 0, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]; } } @@ -133,16 +133,16 @@ test('pipe is applied and can stop pipeline', function () use ($state) { expect($char)->toBe(new Char('A')) ->and($state) ->runCount->toMatchArray([ - 'char' => 1, - 'number' => 0, + 'char' => 1, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]) ->appliedCount->toMatchArray([ - 'char' => 1, - 'number' => 0, + 'char' => 1, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]); }); @@ -152,16 +152,16 @@ test('pipe is run and can let the pipeline keep going', function () use ($state) expect(3)->toBe(3) ->and($state) ->runCount->toMatchArray([ - 'char' => 1, - 'number' => 0, + 'char' => 1, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 1, + 'symbol' => 1, ]) ->appliedCount->toMatchArray([ - 'char' => 0, - 'number' => 0, + 'char' => 0, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]); }); @@ -173,16 +173,16 @@ test('pipe works with negated expectation', function () use ($state) { expect($char)->not->toBe(new Char('B')) ->and($state) ->runCount->toMatchArray([ - 'char' => 1, - 'number' => 0, + 'char' => 1, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]) ->appliedCount->toMatchArray([ - 'char' => 1, - 'number' => 0, + 'char' => 1, + 'number' => 0, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]); }); @@ -205,16 +205,16 @@ test('interceptor stops the pipeline', function () use ($state) { expect($number)->toBe(new Number(1)) ->and($state) ->runCount->toMatchArray([ - 'char' => 1, - 'number' => 1, + 'char' => 1, + 'number' => 1, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]) ->appliedCount->toMatchArray([ - 'char' => 0, - 'number' => 1, + 'char' => 0, + 'number' => 1, 'wildcard' => 0, - 'symbol' => 0, + 'symbol' => 0, ]); }); diff --git a/tests/Features/Expect/toBe.php b/tests/Features/Expect/toBe.php index d73760b3..ef2bce5a 100644 --- a/tests/Features/Expect/toBe.php +++ b/tests/Features/Expect/toBe.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\ExpectationFailedException; expect(true)->toBeTrue()->and(false)->toBeFalse(); test('strict comparisons', function () { - $nuno = new stdClass(); + $nuno = new stdClass(); $dries = new stdClass(); expect($nuno)->toBe($nuno)->not->toBe($dries); diff --git a/tests/Features/Expect/toBeFile.php b/tests/Features/Expect/toBeFile.php index e8bc59d1..0bd5081a 100644 --- a/tests/Features/Expect/toBeFile.php +++ b/tests/Features/Expect/toBeFile.php @@ -3,7 +3,7 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { - touch($this->tempFile = sys_get_temp_dir() . '/fake.file'); + touch($this->tempFile = sys_get_temp_dir().'/fake.file'); }); afterEach(function () { diff --git a/tests/Features/Expect/toBeReadableFile.php b/tests/Features/Expect/toBeReadableFile.php index 756046fa..1c4794d0 100644 --- a/tests/Features/Expect/toBeReadableFile.php +++ b/tests/Features/Expect/toBeReadableFile.php @@ -3,7 +3,7 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { - touch($this->tempFile = sys_get_temp_dir() . '/fake.file'); + touch($this->tempFile = sys_get_temp_dir().'/fake.file'); }); afterEach(function () { diff --git a/tests/Features/Expect/toBeWritableFile.php b/tests/Features/Expect/toBeWritableFile.php index 96fe05c3..b265a250 100644 --- a/tests/Features/Expect/toBeWritableFile.php +++ b/tests/Features/Expect/toBeWritableFile.php @@ -3,7 +3,7 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { - touch($this->tempFile = sys_get_temp_dir() . '/fake.file'); + touch($this->tempFile = sys_get_temp_dir().'/fake.file'); }); afterEach(function () { diff --git a/tests/Features/Expect/toHaveProperties.php b/tests/Features/Expect/toHaveProperties.php index aae1303c..ad3da1b0 100644 --- a/tests/Features/Expect/toHaveProperties.php +++ b/tests/Features/Expect/toHaveProperties.php @@ -3,24 +3,24 @@ use PHPUnit\Framework\ExpectationFailedException; test('pass', function () { - $object = new stdClass(); + $object = new stdClass(); $object->name = 'Jhon'; - $object->age = 21; + $object->age = 21; expect($object)->toHaveProperties(['name', 'age']); }); test('failures', function () { - $object = new stdClass(); + $object = new stdClass(); $object->name = 'Jhon'; expect($object)->toHaveProperties(['name', 'age']); })->throws(ExpectationFailedException::class); test('not failures', function () { - $object = new stdClass(); + $object = new stdClass(); $object->name = 'Jhon'; - $object->age = 21; + $object->age = 21; expect($object)->not->toHaveProperties(['name', 'age']); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toHaveProperty.php b/tests/Features/Expect/toHaveProperty.php index 19b4c92e..951f3c2d 100644 --- a/tests/Features/Expect/toHaveProperty.php +++ b/tests/Features/Expect/toHaveProperty.php @@ -2,8 +2,8 @@ use PHPUnit\Framework\ExpectationFailedException; -$obj = new stdClass(); -$obj->foo = 'bar'; +$obj = new stdClass(); +$obj->foo = 'bar'; $obj->fooNull = null; test('pass', function () use ($obj) { diff --git a/tests/Features/Expect/toMatchArray.php b/tests/Features/Expect/toMatchArray.php index b1646b9e..324d11c7 100644 --- a/tests/Features/Expect/toMatchArray.php +++ b/tests/Features/Expect/toMatchArray.php @@ -4,22 +4,22 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { $this->user = [ - 'id' => 1, - 'name' => 'Nuno', + 'id' => 1, + 'name' => 'Nuno', 'email' => 'enunomaduro@gmail.com', ]; }); test('pass', function () { expect($this->user)->toMatchArray([ - 'name' => 'Nuno', + 'name' => 'Nuno', 'email' => 'enunomaduro@gmail.com', ]); }); test('failures', function () { expect($this->user)->toMatchArray([ - 'name' => 'Not the same name', + 'name' => 'Not the same name', 'email' => 'enunomaduro@gmail.com', ]); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toMatchObject.php b/tests/Features/Expect/toMatchObject.php index 18d0e668..9108d5b4 100644 --- a/tests/Features/Expect/toMatchObject.php +++ b/tests/Features/Expect/toMatchObject.php @@ -4,33 +4,34 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { $this->user = (object) [ - 'id' => 1, - 'name' => 'Nuno', + 'id' => 1, + 'name' => 'Nuno', 'email' => 'enunomaduro@gmail.com', ]; }); test('pass', function () { expect($this->user)->toMatchObject([ - 'name' => 'Nuno', + 'name' => 'Nuno', 'email' => 'enunomaduro@gmail.com', ]); }); test('pass with class', function () { - expect(new class() { + expect(new class() + { public $name = 'Nuno'; public $email = 'enunomaduro@gmail.com'; })->toMatchObject([ - 'name' => 'Nuno', + 'name' => 'Nuno', 'email' => 'enunomaduro@gmail.com', ]); }); test('failures', function () { expect($this->user)->toMatchObject([ - 'name' => 'Not the same name', + 'name' => 'Not the same name', 'email' => 'enunomaduro@gmail.com', ]); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toThrow.php b/tests/Features/Expect/toThrow.php index 6f8b72d3..26291cde 100644 --- a/tests/Features/Expect/toThrow.php +++ b/tests/Features/Expect/toThrow.php @@ -38,13 +38,13 @@ test('passes', function () { test('failures 1', function () { expect(function () { })->toThrow(RuntimeException::class); -})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.'); +})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.'); test('failures 2', function () { expect(function () { })->toThrow(function (RuntimeException $e) { }); -})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.'); +})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.'); test('failures 3', function () { expect(function () { diff --git a/tests/Features/Expect/unless.php b/tests/Features/Expect/unless.php index 92c56d2e..5f78c0cd 100644 --- a/tests/Features/Expect/unless.php +++ b/tests/Features/Expect/unless.php @@ -3,9 +3,9 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { - $this->unlessObject = new stdClass(); + $this->unlessObject = new stdClass(); $this->unlessObject->trueValue = true; - $this->unlessObject->foo = 'foo'; + $this->unlessObject->foo = 'foo'; }); it('pass', function () { diff --git a/tests/Features/Expect/when.php b/tests/Features/Expect/when.php index 5e327b88..1a40bf12 100644 --- a/tests/Features/Expect/when.php +++ b/tests/Features/Expect/when.php @@ -3,9 +3,9 @@ use PHPUnit\Framework\ExpectationFailedException; beforeEach(function () { - $this->whenObject = new stdClass(); + $this->whenObject = new stdClass(); $this->whenObject->trueValue = true; - $this->whenObject->foo = 'foo'; + $this->whenObject->foo = 'foo'; }); it('pass', function () { diff --git a/tests/Features/TestCycle.php b/tests/Features/TestCycle.php index 7d3b785d..37b6d092 100644 --- a/tests/Features/TestCycle.php +++ b/tests/Features/TestCycle.php @@ -2,11 +2,11 @@ use function PHPUnit\Framework\assertFalse; -$foo = new stdClass(); -$foo->beforeAll = false; +$foo = new stdClass(); +$foo->beforeAll = false; $foo->beforeEach = false; -$foo->afterEach = false; -$foo->afterAll = false; +$foo->afterEach = false; +$foo->afterAll = false; beforeAll(function () { $foo->beforeAll = true; diff --git a/tests/Hooks/BeforeAllTest.php b/tests/Hooks/BeforeAllTest.php index 4cea5faa..12524554 100644 --- a/tests/Hooks/BeforeAllTest.php +++ b/tests/Hooks/BeforeAllTest.php @@ -4,7 +4,7 @@ use Pest\Support\Str; // HACK: we have to determine our $_SERVER['globalHook-]>calls baseline. This is because // two other tests are executed before this one due to filename ordering. -$args = $_SERVER['argv'] ?? []; +$args = $_SERVER['argv'] ?? []; $single = (isset($args[1]) && Str::endsWith(__FILE__, $args[1])) || ($_SERVER['PEST_PARALLEL'] ?? false); $offset = $single ? 0 : 2; diff --git a/tests/PHPUnit/CustomTestCase/CustomTestCase.php b/tests/PHPUnit/CustomTestCase/CustomTestCase.php index 6de89808..8a71327b 100644 --- a/tests/PHPUnit/CustomTestCase/CustomTestCase.php +++ b/tests/PHPUnit/CustomTestCase/CustomTestCase.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Tests\CustomTestCase; use function PHPUnit\Framework\assertTrue; - use PHPUnit\Framework\TestCase; abstract class CustomTestCase extends TestCase diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 00e759bb..71a32980 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Tests\CustomTestCase; use function PHPUnit\Framework\assertTrue; - use PHPUnit\Framework\TestCase; class ExecutedTest extends TestCase diff --git a/tests/Unit/Datasets.php b/tests/Unit/Datasets.php index 3f1224d6..83b33b04 100644 --- a/tests/Unit/Datasets.php +++ b/tests/Unit/Datasets.php @@ -34,7 +34,7 @@ it('show only the names of multiple named datasets in their description', functi ], [ 'three' => [3], - 'four' => [[4]], + 'four' => [[4]], ], ])); diff --git a/tests/Unit/Plugins/Version.php b/tests/Unit/Plugins/Version.php index ffb076c7..d79fe7c8 100644 --- a/tests/Unit/Plugins/Version.php +++ b/tests/Unit/Plugins/Version.php @@ -1,9 +1,7 @@ handleArguments(['foo', '--version']); - expect($output->fetch())->toContain('Pest ' . version()); + expect($output->fetch())->toContain('Pest '.version()); }); it('do not outputs version when --version is not used', function () { diff --git a/tests/Unit/Support/Reflection.php b/tests/Unit/Support/Reflection.php index 7e98bd76..759473c4 100644 --- a/tests/Unit/Support/Reflection.php +++ b/tests/Unit/Support/Reflection.php @@ -10,7 +10,8 @@ it('gets file name from closure', function () { }); it('gets property values', function () { - $class = new class() { + $class = new class() + { private $foo = 'bar'; }; diff --git a/tests/Unit/TestSuite.php b/tests/Unit/TestSuite.php index ca7afa83..c25830f0 100644 --- a/tests/Unit/TestSuite.php +++ b/tests/Unit/TestSuite.php @@ -8,7 +8,7 @@ use Pest\TestSuite; it('does not allow to add the same test description twice', function () { $testSuite = new TestSuite(getcwd(), 'tests'); - $method = new TestCaseMethodFactory('foo', 'bar', null); + $method = new TestCaseMethodFactory('foo', 'bar', null); $testSuite->tests->set($method); $testSuite->tests->set($method); @@ -44,7 +44,7 @@ it('can return an array of all test suite filenames', function () { it('can filter the test suite filenames to those with the only method', function () { $testSuite = new TestSuite(getcwd(), 'tests'); - $testWithOnly = new TestCaseMethodFactory('a', 'b', null); + $testWithOnly = new TestCaseMethodFactory('a', 'b', null); $testWithOnly->only = true; $testSuite->tests->set($testWithOnly); @@ -63,7 +63,7 @@ it('does not filter the test suite filenames to those with the only method when $test = function () { }; - $testWithOnly = new TestCaseMethodFactory('a', 'b', null); + $testWithOnly = new TestCaseMethodFactory('a', 'b', null); $testWithOnly->only = true; $testSuite->tests->set($testWithOnly); diff --git a/tests/Visual/Help.php b/tests/Visual/Help.php index 642c9ae8..3b0463f7 100644 --- a/tests/Visual/Help.php +++ b/tests/Visual/Help.php @@ -4,18 +4,18 @@ use Pest\Console\Help; use Symfony\Component\Console\Output\BufferedOutput; test('visual snapshot of help command output', function () { - $snapshot = __DIR__ . '/../.snapshots/help-command.txt'; + $snapshot = __DIR__.'/../.snapshots/help-command.txt'; if (getenv('REBUILD_SNAPSHOTS')) { $outputBuffer = new BufferedOutput(); - $plugin = new Help($outputBuffer); + $plugin = new Help($outputBuffer); $plugin(); file_put_contents($snapshot, $outputBuffer->fetch()); } - $output = function () { + $output = function () { $process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'])); $process->run(); diff --git a/tests/Visual/JUnit.php b/tests/Visual/JUnit.php index 27c6c68d..41481b4d 100644 --- a/tests/Visual/JUnit.php +++ b/tests/Visual/JUnit.php @@ -6,11 +6,11 @@ use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; beforeEach(function () { - file_put_contents(__DIR__ . '/junit.html', ''); + file_put_contents(__DIR__.'/junit.html', ''); }); it('is can successfully call all public methods', function () { - $junit = new JUnit(__DIR__ . '/junit.html'); + $junit = new JUnit(__DIR__.'/junit.html'); $junit->startTestSuite(new TestSuite()); $junit->startTest($this); $junit->addError($this, new Exception(), 0); @@ -25,5 +25,5 @@ it('is can successfully call all public methods', function () { })->skip('Not supported yet.'); afterEach(function () { - unlink(__DIR__ . '/junit.html'); + unlink(__DIR__.'/junit.html'); }); diff --git a/tests/Visual/SingleTestOrDirectory.php b/tests/Visual/SingleTestOrDirectory.php index 5e69736e..a8405475 100644 --- a/tests/Visual/SingleTestOrDirectory.php +++ b/tests/Visual/SingleTestOrDirectory.php @@ -2,7 +2,7 @@ use Symfony\Component\Process\Process; -$run = function (string $target, $decorated = false) { +$run = function (string $target, $decorated = false) { $process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'], ); @@ -12,7 +12,7 @@ $run = function (string $target, $decorated = false) { return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput()); }; -$snapshot = function ($name) { +$snapshot = function ($name) { $testsPath = dirname(__DIR__); return file_get_contents(implode(DIRECTORY_SEPARATOR, [ diff --git a/tests/Visual/Success.php b/tests/Visual/Success.php index 391c8d7b..d8928552 100644 --- a/tests/Visual/Success.php +++ b/tests/Visual/Success.php @@ -2,13 +2,13 @@ test('visual snapshot of test suite on success', function () { $testsPath = dirname(__DIR__); - $snapshot = implode(DIRECTORY_SEPARATOR, [ + $snapshot = implode(DIRECTORY_SEPARATOR, [ $testsPath, '.snapshots', 'success.txt', ]); - $output = function () use ($testsPath) { + $output = function () use ($testsPath) { $process = (new Symfony\Component\Process\Process( ['php', 'bin/pest'], dirname($testsPath), @@ -31,12 +31,12 @@ test('visual snapshot of test suite on success', function () { $outputContent = preg_replace('/Time\: \s+\d+\.\d+s\s+/m', '', $output()); file_put_contents($snapshot, $outputContent); - } elseif (!getenv('EXCLUDE')) { + } elseif (! getenv('EXCLUDE')) { $output = explode("\n", $output()); array_pop($output); array_pop($output); expect(implode("\n", $output))->toContain(file_get_contents($snapshot)); } -})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE')) +})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE')) ->skip(PHP_OS_FAMILY === 'Windows'); diff --git a/tests/Visual/TeamCity.php b/tests/Visual/TeamCity.php index 378b81b9..a3f9e7b2 100644 --- a/tests/Visual/TeamCity.php +++ b/tests/Visual/TeamCity.php @@ -8,11 +8,11 @@ use PHPUnit\Framework\Warning; use PHPUnit\TextUI\DefaultResultPrinter; beforeEach(function () { - file_put_contents(__DIR__ . '/output.txt', ''); + file_put_contents(__DIR__.'/output.txt', ''); }); it('is can successfully call all public methods', function () { - $teamCity = new TeamCity(__DIR__ . '/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS); + $teamCity = new TeamCity(__DIR__.'/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS); expect($teamCity::isPestTest($this))->toBeTrue(); $teamCity->startTestSuite(new TestSuite()); $teamCity->startTest($this); @@ -28,5 +28,5 @@ it('is can successfully call all public methods', function () { })->skip('Not supported yet.'); afterEach(function () { - unlink(__DIR__ . '/output.txt'); + unlink(__DIR__.'/output.txt'); });