From 42d9b777bfab71298ec289bfedb458d64b3a23f7 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Fri, 7 Aug 2026 14:52:56 +0100 Subject: [PATCH] chore: coding style changes --- bin/worker.php | 1 - composer.json | 2 +- overrides/Event/Value/ThrowableBuilder.php | 32 --- overrides/Logging/JUnit/JunitXmlLogger.php | 64 ++---- .../WrapperRunner/ProgressPrinterOutput.php | 29 --- .../Runner/Filter/NameFilterIterator.php | 39 +--- .../Runner/ResultCache/DefaultResultCache.php | 35 --- overrides/Runner/TestSuiteLoader.php | 32 --- overrides/Runner/TestSuiteSorter.php | 70 ------ .../Commands/WarmCodeCoverageCacheCommand.php | 32 --- .../Subscriber/TestSkippedSubscriber.php | 39 ---- overrides/TextUI/TestSuiteFilterProcessor.php | 32 --- pint.json | 5 +- rector.php | 6 - src/ArchPresets/AbstractPreset.php | 13 -- src/ArchPresets/Custom.php | 8 - src/ArchPresets/Laravel.php | 3 - src/ArchPresets/Php.php | 3 - src/ArchPresets/Relaxed.php | 3 - src/ArchPresets/Security.php | 3 - src/ArchPresets/Strict.php | 3 - src/Bootstrappers/BootExcludeList.php | 5 - src/Bootstrappers/BootFiles.php | 8 - src/Bootstrappers/BootKernelDump.php | 8 +- src/Bootstrappers/BootOverrides.php | 5 - src/Bootstrappers/BootSubscribers.php | 8 - src/Bootstrappers/BootView.php | 8 +- src/Collision/Events.php | 12 -- src/Concerns/Expectable.php | 2 - src/Concerns/Extendable.php | 7 - src/Concerns/Logging/WritesToConsole.php | 12 -- src/Concerns/Pipeable.php | 11 - src/Concerns/Retrievable.php | 2 - src/Concerns/Testable.php | 114 ---------- src/Configuration.php | 47 ----- src/Configuration/Presets.php | 3 - src/Configuration/Printer.php | 3 - src/Configuration/Project.php | 28 --- src/Console/Help.php | 10 +- src/Console/Thanks.php | 10 +- src/Contracts/Bootstrapper.php | 3 - src/Contracts/HasPrintableTestCaseName.php | 2 +- src/Contracts/Panicable.php | 6 - src/Contracts/Plugins/AddsOutput.php | 3 - src/Contracts/Plugins/Bootable.php | 3 - src/Contracts/Plugins/HandlesArguments.php | 2 - .../Plugins/HandlesOriginalArguments.php | 2 - src/Contracts/Plugins/Terminable.php | 3 - src/Contracts/TestCaseFilter.php | 3 - src/Contracts/TestCaseMethodFilter.php | 3 - src/Evaluators/Attributes.php | 2 - src/Exceptions/AfterAllAlreadyExist.php | 3 - src/Exceptions/AfterAllWithinDescribe.php | 3 - src/Exceptions/AfterBeforeTestFunction.php | 3 - src/Exceptions/BeforeAllAlreadyExist.php | 3 - src/Exceptions/BeforeAllWithinDescribe.php | 3 - src/Exceptions/DatasetAlreadyExists.php | 3 - src/Exceptions/DatasetArgumentsMismatch.php | 2 - src/Exceptions/DatasetDoesNotExist.php | 3 - src/Exceptions/DatasetMissing.php | 2 - src/Exceptions/ExpectationNotFound.php | 3 - src/Exceptions/FileOrFolderNotFound.php | 3 - src/Exceptions/InvalidArgumentException.php | 3 - src/Exceptions/InvalidOption.php | 3 - src/Exceptions/InvalidPestCommand.php | 3 - src/Exceptions/InvalidTestClassName.php | 6 - src/Exceptions/MissingDependency.php | 3 - src/Exceptions/NoDirtyTestsFound.php | 6 - src/Exceptions/ShouldNotHappen.php | 6 - src/Exceptions/TestAlreadyExist.php | 3 - src/Exceptions/TestCaseAlreadyInUse.php | 3 - .../TestCaseClassOrTraitNotFound.php | 3 - src/Exceptions/TestClosureMustNotBeStatic.php | 3 - src/Exceptions/TestDescriptionMissing.php | 3 - src/Expectation.php | 199 +----------------- src/Expectations/EachExpectation.php | 13 -- src/Expectations/HigherOrderExpectation.php | 30 --- src/Expectations/OppositeExpectation.php | 152 ------------- src/Factories/Concerns/HigherOrderable.php | 12 -- src/Factories/TestCaseFactory.php | 29 --- src/Factories/TestCaseMethodFactory.php | 51 ----- src/Functions.php | 45 ---- src/Kernel.php | 23 -- src/KernelDump.php | 26 +-- src/Logging/Converter.php | 57 ----- src/Logging/TeamCity/ServiceMessage.php | 3 - .../TeamCity/Subscriber/Subscriber.php | 6 - .../Subscriber/TestSkippedSubscriber.php | 2 +- src/Logging/TeamCity/TeamCityLogger.php | 18 -- src/Mixins/Expectation.php | 170 +-------------- .../HigherOrderExpectationTypeExtension.php | 6 - src/Panic.php | 11 +- src/PendingCalls/AfterEachCall.php | 14 -- src/PendingCalls/BeforeEachCall.php | 20 -- src/PendingCalls/Concerns/Describable.php | 4 - src/PendingCalls/DescribeCall.php | 20 +- src/PendingCalls/TestCall.php | 126 ----------- src/PendingCalls/UsesCall.php | 41 ---- src/Pest.php | 2 +- src/Plugin.php | 4 - src/Plugins/Actions/CallsAddsOutput.php | 5 - src/Plugins/Actions/CallsBoot.php | 5 - src/Plugins/Actions/CallsHandleArguments.php | 4 - .../Actions/CallsHandleOriginalArguments.php | 4 - src/Plugins/Actions/CallsTerminable.php | 5 - src/Plugins/Bail.php | 3 - src/Plugins/Cache.php | 6 - src/Plugins/Concerns/HandleArguments.php | 8 - src/Plugins/Configuration.php | 18 -- src/Plugins/Coverage.php | 23 +- src/Plugins/Environment.php | 12 -- src/Plugins/Help.php | 8 +- src/Plugins/Init.php | 17 +- src/Plugins/Memory.php | 8 +- src/Plugins/Only.php | 12 -- src/Plugins/Parallel.php | 25 --- src/Plugins/Parallel/Handlers/Laravel.php | 9 - src/Plugins/Parallel/Handlers/Parallel.php | 6 - src/Plugins/Parallel/Handlers/Pest.php | 3 - .../Parallel/Paratest/CleanConsoleOutput.php | 3 - .../Parallel/Paratest/ResultPrinter.php | 12 -- .../Parallel/Paratest/WrapperRunner.php | 23 -- .../Parallel/Support/CompactPrinter.php | 23 +- src/Plugins/Shard.php | 64 ------ src/Plugins/Snapshot.php | 7 - src/Plugins/Tia.php | 14 -- src/Plugins/Tia/ChangedFiles.php | 5 - src/Plugins/Tia/Contracts/Ci.php | 4 - src/Plugins/Tia/CoverageMerger.php | 5 - src/Plugins/Tia/Fingerprint.php | 13 -- src/Plugins/Tia/Graph.php | 60 ------ src/Plugins/Tia/JsModuleGraph.php | 3 - src/Plugins/Tia/Recorder.php | 5 - src/Plugins/Tia/SourceScope.php | 2 +- src/Plugins/Tia/TableExtractor.php | 8 - src/Plugins/Tia/TestPaths.php | 6 +- src/Plugins/Verbose.php | 3 - src/Preset.php | 36 ---- src/Repositories/AfterAllRepository.php | 9 - src/Repositories/AfterEachRepository.php | 6 - src/Repositories/BeforeAllRepository.php | 9 - src/Repositories/BeforeEachRepository.php | 5 - src/Repositories/DatasetsRepository.php | 10 - src/Repositories/SnapshotRepository.php | 22 -- src/Repositories/TestRepository.php | 27 --- src/Result.php | 9 - .../EnsureConfigurationIsAvailable.php | 3 - .../EnsureIgnorableTestCasesAreIgnored.php | 3 - src/Subscribers/EnsureKernelDumpIsFlushed.php | 3 - src/Subscribers/EnsureShardTimingFinished.php | 3 - src/Subscribers/EnsureShardTimingStarted.php | 3 - .../EnsureShardTimingsAreCollected.php | 12 -- src/Subscribers/EnsureTeamCityEnabled.php | 9 - src/Support/Arr.php | 8 - src/Support/Backtrace.php | 15 -- src/Support/ChainableClosure.php | 12 -- src/Support/Closure.php | 2 - src/Support/Container.php | 13 -- src/Support/Coverage.php | 20 -- src/Support/Description.php | 6 - src/Support/ExceptionTrace.php | 2 - src/Support/ExpectationPipeline.php | 21 -- src/Support/Exporter.php | 19 +- src/Support/HigherOrderCallables.php | 12 +- src/Support/HigherOrderMessage.php | 13 +- src/Support/HigherOrderMessageCollection.php | 12 -- src/Support/HigherOrderTapProxy.php | 13 +- src/Support/NullClosure.php | 3 - src/Support/Reflection.php | 30 +-- src/Support/Shell.php | 8 - src/Support/StateGenerator.php | 6 - src/Support/Str.php | 51 ----- src/Support/View.php | 10 - .../GitDirtyTestCaseFilter.php | 8 +- .../AssigneeTestCaseFilter.php | 6 - .../FlakyTestCaseFilter.php | 3 - .../IssueTestCaseFilter.php | 6 - .../NotesTestCaseFilter.php | 3 - .../PrTestCaseFilter.php | 6 - .../TodoTestCaseFilter.php | 3 - src/TestCases/IgnorableTestCase.php | 2 +- src/TestSuite.php | 33 --- ...isual_snapshot_of_help_command_output.snap | 2 +- ...isual_snapshot_of_help_command_output.snap | 2 +- tests/.snapshots/success.txt | 11 +- tests/Features/AfterAll.php | 2 +- ...eEachProxiesToTestCallWithExpectations.php | 6 +- tests/Features/DatasetMethodChaining.php | 47 ----- tests/Features/DatasetsTests.php | 5 +- tests/Features/Depends.php | 1 - tests/Features/DescriptionLess.php | 4 +- tests/Features/Expect/each.php | 33 +-- tests/Features/Expect/pipes.php | 23 +- tests/Features/Expect/toBeBase64.php | 10 +- tests/Features/Expect/toBeDomain.php | 8 +- tests/Features/Expect/toBeHexadecimal.php | 10 +- tests/Features/Expect/toBeHostname.php | 8 +- tests/Features/Expect/toBeMacAddress.php | 4 +- tests/Features/Expect/toBeUuid.php | 16 +- .../Expect/toHaveFileSystemPermissions.php | 2 - .../Expect/toHaveMethodsDocumented.php | 4 +- tests/Features/Expect/unless.php | 12 +- tests/Features/Expect/when.php | 12 +- tests/Features/Flaky.php | 12 +- tests/Features/Tia.php | 2 - tests/Features/Tia/LivewireComponents.php | 15 +- .../HasStrictTypeWithCommentsAbove.php | 2 - .../overlays/livewire-watch/tests/Pest.php | 4 - tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php | 7 - tests/PHPUnit/CustomTestCase/ExecutedTest.php | 2 - tests/Pest.php | 7 +- tests/Unit/Plugins/Tia/FileState.php | 1 - tests/Unit/Plugins/Tia/Graph.php | 21 +- tests/Unit/Plugins/Tia/IsEnabledForRun.php | 5 - tests/Unit/Plugins/Tia/Recorder.php | 1 - tests/Unit/Plugins/Tia/ResultKey.php | 3 - tests/Unit/Plugins/Tia/TableExtractor.php | 7 - tests/Unit/Plugins/Tia/TestPaths.php | 3 - tests/Visual/Collision.php | 1 - tests/Visual/JUnit.php | 1 - tests/Visual/Parallel.php | 4 +- 221 files changed, 139 insertions(+), 3086 deletions(-) diff --git a/bin/worker.php b/bin/worker.php index 7b374785..8a4574db 100644 --- a/bin/worker.php +++ b/bin/worker.php @@ -111,7 +111,6 @@ $bootPest = (static function (): void { exit; } - // It must be a 1 byte string to ensure filesize() is equal to the number of tests executed $exitCode = $application->runTest(realpath(trim($testPath))); fwrite($statusFile, (string) $exitCode); diff --git a/composer.json b/composer.json index 41e3d01c..4eab89c0 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "pestphp/pest-dev-tools": "^5.0.0", "pestphp/pest-plugin-browser": "^5.0.0", "pestphp/pest-plugin-phpstan": "^5.0.0", - "pestphp/pest-plugin-rector": "^5.0.2", + "pestphp/pest-plugin-rector": "^5.0.3", "pestphp/pest-plugin-type-coverage": "^5.0.2", "psy/psysh": "^0.12.24" }, diff --git a/overrides/Event/Value/ThrowableBuilder.php b/overrides/Event/Value/ThrowableBuilder.php index d446d03c..053fc8e2 100644 --- a/overrides/Event/Value/ThrowableBuilder.php +++ b/overrides/Event/Value/ThrowableBuilder.php @@ -1,37 +1,5 @@ printer = $printer; - $this->converter = new Converter(Container::getInstance()->get(TestSuite::class)->rootPath); // pest-added - + $this->converter = new Converter(Container::getInstance()->get(TestSuite::class)->rootPath); $this->registerSubscribers($facade); $this->createDocument(); } @@ -160,10 +127,9 @@ final class JunitXmlLogger public function testSuiteStarted(Started $event): void { $testSuite = $this->document->createElement('testsuite'); - $testSuite->setAttribute('name', $this->converter->getTestSuiteName($event->testSuite())); // pest-changed - + $testSuite->setAttribute('name', $this->converter->getTestSuiteName($event->testSuite())); if ($event->testSuite()->isForTestClass()) { - $testSuite->setAttribute('file', $this->converter->getTestSuiteLocation($event->testSuite()) ?? ''); // pest-changed + $testSuite->setAttribute('file', $this->converter->getTestSuiteLocation($event->testSuite()) ?? ''); } if ($this->testSuiteLevel > 0) { @@ -380,12 +346,11 @@ final class JunitXmlLogger assert($this->currentTestCase !== null); - $buffer = $this->converter->getTestCaseMethodName($event->test()); // pest-changed - + $buffer = $this->converter->getTestCaseMethodName($event->test()); $throwable = $event->throwable(); $buffer .= trim( - $this->converter->getExceptionMessage($throwable).PHP_EOL. // pest-changed - $this->converter->getExceptionDetails($throwable), // pest-changed + $this->converter->getExceptionMessage($throwable).PHP_EOL. + $this->converter->getExceptionDetails($throwable), ); $fault = $this->document->createElement( @@ -485,18 +450,15 @@ final class JunitXmlLogger $testCase = $this->document->createElement('testcase'); $test = $event->test(); - $file = $this->converter->getTestCaseLocation($test); // pest-added - - $testCase->setAttribute('name', $this->converter->getTestCaseMethodName($test)); // pest-changed - $testCase->setAttribute('file', $file); // pest-changed - + $file = $this->converter->getTestCaseLocation($test); + $testCase->setAttribute('name', $this->converter->getTestCaseMethodName($test)); + $testCase->setAttribute('file', $file); if ($test->isTestMethod()) { assert($test instanceof TestMethod); - // $testCase->setAttribute('line', (string) $test->line()); // pest-removed - $className = $this->converter->getTrimmedTestClassName($test); // pest-added - $testCase->setAttribute('class', $className); // pest-changed - $testCase->setAttribute('classname', str_replace('\\', '.', $className)); // pest-changed + $className = $this->converter->getTrimmedTestClassName($test); + $testCase->setAttribute('class', $className); + $testCase->setAttribute('classname', str_replace('\\', '.', $className)); } $this->currentTestCase = $testCase; diff --git a/overrides/ParaTest/WrapperRunner/ProgressPrinterOutput.php b/overrides/ParaTest/WrapperRunner/ProgressPrinterOutput.php index a5c4183a..144df0b5 100644 --- a/overrides/ParaTest/WrapperRunner/ProgressPrinterOutput.php +++ b/overrides/ParaTest/WrapperRunner/ProgressPrinterOutput.php @@ -1,29 +1,5 @@ defectSortOrder[$b->sortId()] ?? 0; if ($priorityA !== $priorityB) { - // Sort defect weight descending return $priorityB <=> $priorityA; } @@ -280,13 +240,9 @@ final class TestSuiteSorter return $this->cmpDuration($a, $b); } - // do not change execution order return 0; } - /** - * Compares test duration for sorting tests by duration ascending. - */ private function cmpDuration(Test $a, Test $b): int { if (! ($a instanceof Reorderable && $b instanceof Reorderable)) { @@ -296,9 +252,6 @@ final class TestSuiteSorter return $this->cache->time(ResultCacheId::fromReorderable($a)) <=> $this->cache->time(ResultCacheId::fromReorderable($b)); } - /** - * Compares test size for sorting tests small->medium->large->unknown. - */ private function cmpSize(Test $a, Test $b): int { $sizeA = ($a instanceof TestCase || $a instanceof DataProviderTestSuite) @@ -312,30 +265,11 @@ final class TestSuiteSorter } /** - * Reorder Tests within a TestCase in such a way as to resolve as many dependencies as possible. - * The algorithm will leave the tests in original running order when it can. - * For more details see the documentation for test dependencies. - * - * Short description of algorithm: - * 1. Pick the next Test from remaining tests to be checked for dependencies. - * 2. If the test has no dependencies: mark done, start again from the top - * 3. If the test has dependencies but none left to do: mark done, start again from the top - * 4. When we reach the end add any leftover tests to the end. These will be marked 'skipped' during execution. - * * @param array $tests * @return array */ private function resolveDependencies(array $tests): array { - // Pest: Fast-path. If no test in this suite declares dependencies, the - // original O(N^2) algorithm is wasted work — it would splice each test - // one-by-one back into the same order. The check deliberately walks - // TestCase instances directly instead of calling TestSuite::requires(), - // because the latter lazily builds TestSuite::provides() via - // ExecutionOrderDependency::mergeUnique, which is O(N^2) in the total - // number of tests. With thousands of tests that single call alone can - // burn several seconds before the sort even begins. Reading the - // cached TestCase::$dependencies property stays O(N) and costs nothing // when no test uses `->depends()` / PHPUnit `@depends`. if (! $this->anyTestHasDependencies($tests)) { return $tests; @@ -361,10 +295,6 @@ final class TestSuiteSorter /** * Cheaply determines whether any test in the tree declares @depends. * - * Walks `TestSuite` containers recursively and inspects each `TestCase` - * directly so it never triggers `TestSuite::provides()`, which is O(N^2) - * in the total number of aggregated tests. - * * @param iterable $tests */ private function anyTestHasDependencies(iterable $tests): bool diff --git a/overrides/TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php b/overrides/TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php index ad301b54..02f093f3 100644 --- a/overrides/TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php +++ b/overrides/TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php @@ -1,37 +1,5 @@ printer()->testSkipped(); } - /** - * Prints a "T" to the standard PHPUnit output to indicate a todo item. - */ private function printTodoItem(): void { $mirror = new ReflectionClass($this->printer()); diff --git a/overrides/TextUI/TestSuiteFilterProcessor.php b/overrides/TextUI/TestSuiteFilterProcessor.php index e13d5c98..c0e6dd70 100644 --- a/overrides/TextUI/TestSuiteFilterProcessor.php +++ b/overrides/TextUI/TestSuiteFilterProcessor.php @@ -1,37 +1,5 @@ [ __DIR__.'/src/Expectations/HigherOrderExpectation.php', ], - // Merges unrelated expectations into a single `toMatchArray()`, turning - // `toContain()` into exact matches, dropping `->not`, and mistaking a - // `toBeTrue()` failure message for an expected value. Unsafe here. UseToMatchArrayRector::class, - // Test fixtures rely on "unused" constructors, params and properties - // (resolved via the container or read through reflection), so the - // dead-code and return-type rules below must not touch the test suite. RemoveEmptyClassMethodRector::class => [ __DIR__.'/tests', ], diff --git a/src/ArchPresets/AbstractPreset.php b/src/ArchPresets/AbstractPreset.php index 0dc9ce30..a2f52fe5 100644 --- a/src/ArchPresets/AbstractPreset.php +++ b/src/ArchPresets/AbstractPreset.php @@ -13,15 +13,11 @@ use Pest\Expectation; abstract class AbstractPreset // @pest-arch-ignore-line { /** - * The expectations. - * * @var array|ArchExpectation> */ protected array $expectations = []; /** - * Creates a new preset instance. - * * @param array $userNamespaces */ public function __construct( @@ -31,15 +27,11 @@ abstract class AbstractPreset // @pest-arch-ignore-line } /** - * Executes the arch preset. - * * @internal */ abstract public function execute(): void; /** - * Ignores the given "targets" or "dependencies". - * * @param array|string $targetsOrDependencies */ final public function ignoring(array|string $targetsOrDependencies): void @@ -51,8 +43,6 @@ abstract class AbstractPreset // @pest-arch-ignore-line } /** - * Runs the given callback for each namespace. - * * @param callable(Expectation): ArchExpectation ...$callbacks */ final public function eachUserNamespace(callable ...$callbacks): void @@ -64,9 +54,6 @@ abstract class AbstractPreset // @pest-arch-ignore-line } } - /** - * Flushes the expectations. - */ final public function flush(): void { $this->expectations = []; diff --git a/src/ArchPresets/Custom.php b/src/ArchPresets/Custom.php index 6c811afe..4db74772 100644 --- a/src/ArchPresets/Custom.php +++ b/src/ArchPresets/Custom.php @@ -14,8 +14,6 @@ use Pest\Expectation; final class Custom extends AbstractPreset { /** - * Creates a new preset instance. - * * @param array $userNamespaces * @param Closure(array): array|ArchExpectation> $execute */ @@ -27,17 +25,11 @@ final class Custom extends AbstractPreset parent::__construct($userNamespaces); } - /** - * Returns the name of the preset. - */ public function name(): string { return $this->name; } - /** - * Executes the arch preset. - */ public function execute(): void { $this->expectations = ($this->execute)($this->userNamespaces); diff --git a/src/ArchPresets/Laravel.php b/src/ArchPresets/Laravel.php index 3b727340..5ba3e23a 100644 --- a/src/ArchPresets/Laravel.php +++ b/src/ArchPresets/Laravel.php @@ -11,9 +11,6 @@ use Throwable; */ final class Laravel extends AbstractPreset { - /** - * Executes the arch preset. - */ public function execute(): void { $this->expectations[] = expect('App\Traits') diff --git a/src/ArchPresets/Php.php b/src/ArchPresets/Php.php index 22b409b6..1fdd323c 100644 --- a/src/ArchPresets/Php.php +++ b/src/ArchPresets/Php.php @@ -9,9 +9,6 @@ namespace Pest\ArchPresets; */ final class Php extends AbstractPreset { - /** - * Executes the arch preset. - */ public function execute(): void { $this->expectations[] = expect([ diff --git a/src/ArchPresets/Relaxed.php b/src/ArchPresets/Relaxed.php index 14269cbd..59248f7e 100644 --- a/src/ArchPresets/Relaxed.php +++ b/src/ArchPresets/Relaxed.php @@ -12,9 +12,6 @@ use Pest\Expectation; */ final class Relaxed extends AbstractPreset { - /** - * Executes the arch preset. - */ public function execute(): void { $this->eachUserNamespace( diff --git a/src/ArchPresets/Security.php b/src/ArchPresets/Security.php index 40b4f59d..fe2b7090 100644 --- a/src/ArchPresets/Security.php +++ b/src/ArchPresets/Security.php @@ -9,9 +9,6 @@ namespace Pest\ArchPresets; */ final class Security extends AbstractPreset { - /** - * Executes the arch preset. - */ public function execute(): void { $this->expectations[] = expect([ diff --git a/src/ArchPresets/Strict.php b/src/ArchPresets/Strict.php index e85627cd..e7f6a595 100644 --- a/src/ArchPresets/Strict.php +++ b/src/ArchPresets/Strict.php @@ -12,9 +12,6 @@ use Pest\Expectation; */ final class Strict extends AbstractPreset { - /** - * Executes the arch preset. - */ public function execute(): void { $this->eachUserNamespace( diff --git a/src/Bootstrappers/BootExcludeList.php b/src/Bootstrappers/BootExcludeList.php index 69d9dce1..8fee213b 100644 --- a/src/Bootstrappers/BootExcludeList.php +++ b/src/Bootstrappers/BootExcludeList.php @@ -13,8 +13,6 @@ use PHPUnit\Util\ExcludeList; final class BootExcludeList implements Bootstrapper { /** - * The directories to exclude. - * * @var array */ private const array EXCLUDE_LIST = [ @@ -25,9 +23,6 @@ final class BootExcludeList implements Bootstrapper 'stubs', ]; - /** - * Boots the "exclude list" for PHPUnit to ignore Pest files. - */ public function boot(): void { $baseDirectory = dirname(__DIR__, 2); diff --git a/src/Bootstrappers/BootFiles.php b/src/Bootstrappers/BootFiles.php index 2f162eec..d8848fe0 100644 --- a/src/Bootstrappers/BootFiles.php +++ b/src/Bootstrappers/BootFiles.php @@ -21,8 +21,6 @@ use function Pest\testDirectory; final class BootFiles implements Bootstrapper { /** - * The structure of the tests directory. - * * @var array */ private const array STRUCTURE = [ @@ -33,9 +31,6 @@ final class BootFiles implements Bootstrapper 'Pest.php', ]; - /** - * Boots the structure of the tests directory. - */ public function boot(): void { $rootPath = TestSuite::getInstance()->rootPath; @@ -67,9 +62,6 @@ final class BootFiles implements Bootstrapper $this->bootDatasets($testsPath); } - /** - * Loads, if possible, the given file. - */ private function load(string $filename): void { if (! Str::endsWith($filename, '.php')) { diff --git a/src/Bootstrappers/BootKernelDump.php b/src/Bootstrappers/BootKernelDump.php index 380a1743..6e51fee9 100644 --- a/src/Bootstrappers/BootKernelDump.php +++ b/src/Bootstrappers/BootKernelDump.php @@ -14,18 +14,12 @@ use Symfony\Component\Console\Output\OutputInterface; */ final readonly class BootKernelDump implements Bootstrapper { - /** - * Creates a new Boot Kernel Dump instance. - */ public function __construct( private OutputInterface $output, ) { - // ... + // } - /** - * Boots the kernel dump. - */ public function boot(): void { Container::getInstance()->add(KernelDump::class, $kernelDump = new KernelDump( diff --git a/src/Bootstrappers/BootOverrides.php b/src/Bootstrappers/BootOverrides.php index 0d7b5d7f..a53bf330 100644 --- a/src/Bootstrappers/BootOverrides.php +++ b/src/Bootstrappers/BootOverrides.php @@ -13,8 +13,6 @@ use Pest\Exceptions\ShouldNotHappen; final class BootOverrides implements Bootstrapper { /** - * The list of files to be overridden. - * * @var array */ public const array FILES = [ @@ -30,9 +28,6 @@ final class BootOverrides implements Bootstrapper 'Logging/JUnit/JunitXmlLogger.php', ]; - /** - * Boots the list of files to be overridden. - */ public function boot(): void { foreach (self::FILES as $file) { diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index c7d33053..eec89900 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -16,8 +16,6 @@ use PHPUnit\Event\Subscriber; final readonly class BootSubscribers implements Bootstrapper { /** - * The list of Subscribers. - * * @var array> */ private const array SUBSCRIBERS = [ @@ -44,16 +42,10 @@ final readonly class BootSubscribers implements Bootstrapper Subscribers\EnsureTiaAssertionsAreRecordedOnFinished::class, ]; - /** - * Creates a new instance of the Boot Subscribers. - */ public function __construct( private Container $container, ) {} - /** - * Boots the list of Subscribers. - */ public function boot(): void { foreach (self::SUBSCRIBERS as $subscriber) { diff --git a/src/Bootstrappers/BootView.php b/src/Bootstrappers/BootView.php index db365b89..0f44eac7 100644 --- a/src/Bootstrappers/BootView.php +++ b/src/Bootstrappers/BootView.php @@ -13,18 +13,12 @@ use Symfony\Component\Console\Output\OutputInterface; */ final readonly class BootView implements Bootstrapper { - /** - * Creates a new instance of the Boot View. - */ public function __construct( private OutputInterface $output ) { - // .. + // } - /** - * Boots the view renderer. - */ public function boot(): void { View::renderUsing($this->output); diff --git a/src/Collision/Events.php b/src/Collision/Events.php index f89976ba..9cb76866 100644 --- a/src/Collision/Events.php +++ b/src/Collision/Events.php @@ -16,22 +16,13 @@ use function Termwind\renderUsing; */ final class Events { - /** - * Sets the output. - */ private static ?OutputInterface $output = null; - /** - * Sets the output. - */ public static function setOutput(OutputInterface $output): void { self::$output = $output; } - /** - * Fires before the test method description is printed. - */ public static function beforeTestMethodDescription(TestResult $result, string $description): string { if (($context = $result->context) === []) { @@ -73,9 +64,6 @@ final class Events return $description; } - /** - * Fires after the test method description is printed. - */ public static function afterTestMethodDescription(TestResult $result): void { if (($context = $result->context) === []) { diff --git a/src/Concerns/Expectable.php b/src/Concerns/Expectable.php index d8e02538..e7ac7aab 100644 --- a/src/Concerns/Expectable.php +++ b/src/Concerns/Expectable.php @@ -14,8 +14,6 @@ trait Expectable /** * @template TValue * - * Creates a new Expectation. - * * @param TValue $value * @return Expectation */ diff --git a/src/Concerns/Extendable.php b/src/Concerns/Extendable.php index 1ff6626b..add15db7 100644 --- a/src/Concerns/Extendable.php +++ b/src/Concerns/Extendable.php @@ -14,15 +14,11 @@ use Closure; trait Extendable { /** - * The list of extends. - * * @var array */ private static array $extends = []; /** - * Register a new extend. - * * @param-closure-this T $extend */ public function extend(string $name, Closure $extend): void @@ -30,9 +26,6 @@ trait Extendable static::$extends[$name] = $extend; } - /** - * Checks if given extend name is registered. - */ public static function hasExtend(string $name): bool { return array_key_exists($name, static::$extends); diff --git a/src/Concerns/Logging/WritesToConsole.php b/src/Concerns/Logging/WritesToConsole.php index 71c69754..a2965bcb 100644 --- a/src/Concerns/Logging/WritesToConsole.php +++ b/src/Concerns/Logging/WritesToConsole.php @@ -9,33 +9,21 @@ namespace Pest\Concerns\Logging; */ trait WritesToConsole { - /** - * Writes the given success message to the console. - */ private function writeSuccess(string $message): void { $this->writePestTestOutput($message, 'fg-green, bold', '✓'); } - /** - * Writes the given error message to the console. - */ private function writeError(string $message): void { $this->writePestTestOutput($message, 'fg-red, bold', '⨯'); } - /** - * Writes the given warning message to the console. - */ private function writeWarning(string $message): void { $this->writePestTestOutput($message, 'fg-yellow, bold', '-'); } - /** - * Writes the give message to the console. - */ private function writePestTestOutput(string $message, string $color, string $symbol): void { $this->writeWithColor($color, "$symbol ", false); diff --git a/src/Concerns/Pipeable.php b/src/Concerns/Pipeable.php index 4e44f8db..60a3938b 100644 --- a/src/Concerns/Pipeable.php +++ b/src/Concerns/Pipeable.php @@ -12,30 +12,21 @@ use Closure; trait Pipeable { /** - * The list of pipes. - * * @var array> */ private static array $pipes = []; /** - * The list of interceptors. - * * @var array> */ private static array $interceptors = []; - /** - * Register a pipe to be applied before an expectation is checked. - */ public function pipe(string $name, Closure $pipe): void { self::$pipes[$name][] = $pipe; } /** - * Register an interceptor that should replace an existing expectation. - * * @param string|Closure(mixed $value, mixed ...$arguments):bool $filter */ public function intercept(string $name, string|Closure $filter, Closure $handler): void @@ -60,8 +51,6 @@ trait Pipeable } /** - * Get the list of pipes by the given name. - * * @return array */ private function pipes(string $name, object $context, string $scope): array diff --git a/src/Concerns/Retrievable.php b/src/Concerns/Retrievable.php index a95031b1..5a269fa1 100644 --- a/src/Concerns/Retrievable.php +++ b/src/Concerns/Retrievable.php @@ -11,8 +11,6 @@ trait Retrievable { /** * @template TRetrievableValue - * - * Safely retrieve the value at the given key from an object or array. * @template TRetrievableValue * * @param array|object $value diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index b34e7a19..420b7026 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -37,105 +37,53 @@ use Throwable; */ trait Testable { - /** - * The test's description. - */ private string $__description; - /** - * The test's latest description. - */ private static string $__latestDescription; - /** - * The test's assignees. - */ private static array $__latestAssignees = []; - /** - * The test's notes. - */ private static array $__latestNotes = []; /** - * The test's issues. - * * @var array */ private static array $__latestIssues = []; /** - * The test's PRs. - * * @var array */ private static array $__latestPrs = []; /** - * The test's describing, if any. - * * @var array */ public array $__describing = []; - /** - * Whether the test has ran or not. - */ public bool $__ran = false; - /** - * The active replay mode for this test, set in `setUp()` and checked - * in `__runTest()` / `tearDown()` to skip the body and after-each. - */ private ReplayType $__replay = ReplayType::None; - /** - * The cached assertion count to replay, captured when entering replay mode. - */ private int $__replayAssertions = 0; - /** - * The test's test closure. - */ private Closure $__test; - /** - * The test's before each closure. - */ private ?Closure $__beforeEach = null; - /** - * The test's after each closure. - */ private ?Closure $__afterEach = null; - /** - * The test's before all closure. - */ private static ?Closure $__beforeAll = null; - /** - * The test's after all closure. - */ private static ?Closure $__afterAll = null; - /** - * The list of snapshot changes, if any. - */ private array $__snapshotChanges = []; - /** - * Resets the test case static properties. - */ public static function flush(): void { self::$__beforeAll = null; self::$__afterAll = null; } - /** - * Adds a new "note" to the Test Case. - */ public function note(array|string $note): self { $note = is_array($note) ? $note : [$note]; @@ -145,9 +93,6 @@ trait Testable return $this; } - /** - * Adds a new "setUpBeforeClass" to the Test Case. - */ public function __addBeforeAll(?Closure $hook): void { if (! $hook instanceof Closure) { @@ -159,9 +104,6 @@ trait Testable : $hook; } - /** - * Adds a new "tearDownAfterClass" to the Test Case. - */ public function __addAfterAll(?Closure $hook): void { if (! $hook instanceof Closure) { @@ -173,25 +115,16 @@ trait Testable : $hook; } - /** - * Adds a new "setUp" to the Test Case. - */ public function __addBeforeEach(?Closure $hook): void { $this->__addHook('__beforeEach', $hook); } - /** - * Adds a new "tearDown" to the Test Case. - */ public function __addAfterEach(?Closure $hook): void { $this->__addHook('__afterEach', $hook); } - /** - * Adds a new "hook" to the Test Case. - */ private function __addHook(string $property, ?Closure $hook): void { if (! $hook instanceof Closure) { @@ -203,9 +136,6 @@ trait Testable : $hook; } - /** - * This method is called before the first test of this Test Case is run. - */ public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -223,9 +153,6 @@ trait Testable } } - /** - * This method is called after the last test of this Test Case is run. - */ public static function tearDownAfterClass(): void { $afterAll = TestSuite::getInstance()->afterAll->get(self::$__filename); @@ -239,9 +166,6 @@ trait Testable parent::tearDownAfterClass(); } - /** - * Gets executed before the Test Case. - */ protected function setUp(...$arguments): void { TestSuite::getInstance()->test = $this; @@ -325,12 +249,8 @@ trait Testable $this->__ran = true; } - /** - * Initialize test case properties from TestSuite. - */ public function __initializeTestCase(): void { - // Return if the test case has already been initialized if (isset($this->__test)) { return; } @@ -352,9 +272,6 @@ trait Testable } } - /** - * Gets executed after the Test Case. - */ protected function tearDown(...$arguments): void { if ($this->__replay !== ReplayType::None) { @@ -382,8 +299,6 @@ trait Testable } /** - * Executes the Test Case current test. - * * @throws Throwable */ private function __runTest(Closure $closure, ...$args): mixed @@ -454,9 +369,6 @@ trait Testable throw $lastException; } - /** - * Determines if the given exception matches PHPUnit's expected exception. - */ private function __isExpectedException(Throwable $e): bool { $expectation = Closure::bind(fn () => $this->exceptionExpectation, $this, TestCase::class)(); @@ -491,8 +403,6 @@ trait Testable } /** - * Resolve the passed arguments. Any Closures will be bound to the testcase and resolved. - * * @throws Throwable */ private function __resolveTestArguments(array $arguments): array @@ -500,10 +410,6 @@ trait Testable $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); if ($method->repetitions > 1) { - // If the test is repeated, the first argument is the iteration number - // we need to move it to the end of the arguments list - // so that the datasets are the first n arguments - // and the iteration number is the last argument $firstArgument = array_shift($arguments); $arguments[] = $firstArgument; } @@ -552,8 +458,6 @@ trait Testable } /** - * Ensures dataset items count matches underlying test case required parameters - * * @throws ReflectionException * @throws DatasetArgumentsMismatch */ @@ -593,9 +497,6 @@ trait Testable return ExceptionTrace::ensure(fn (): mixed => call_user_func_array(Closure::bind($closure, $this, $this::class), $arguments)); } - /** - * Uses the given preset on the test. - */ public function preset(): Preset { return new Preset; @@ -611,33 +512,21 @@ trait Testable $this->markTestIncomplete(implode('. ', $this->__snapshotChanges)); } - /** - * The printable test case name. - */ public static function getPrintableTestCaseName(): string { return preg_replace('/P\\\/', '', self::class, 1); } - /** - * The printable test case method name. - */ public function getPrintableTestCaseMethodName(): string { return $this->__description; } - /** - * The latest printable test case method name. - */ public static function getLatestPrintableTestCaseMethodName(): string { return self::$__latestDescription ?? ''; } - /** - * The printable test case method context. - */ public static function getPrintableContext(): array { return [ @@ -648,9 +537,6 @@ trait Testable ]; } - /** - * Opens a shell for the test case. - */ public function shell(): void { Shell::open(); diff --git a/src/Configuration.php b/src/Configuration.php index 46f2d118..eabcb798 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -14,31 +14,19 @@ use Pest\PendingCalls\UsesCall; */ final readonly class Configuration { - /** - * The filename of the configuration. - */ private string $filename; - /** - * Creates a new configuration instance. - */ public function __construct( string $filename, ) { $this->filename = str_ends_with($filename, DIRECTORY_SEPARATOR.'Pest.php') ? dirname($filename) : $filename; } - /** - * Use the given classes and traits in the given targets. - */ public function in(string ...$targets): UsesCall { return new UsesCall($this->filename, [])->in(...$targets); } - /** - * Depending on where is called, it will extend the given classes and traits globally or locally. - */ public function extend(string ...$classAndTraits): UsesCall { return new UsesCall( @@ -47,97 +35,62 @@ final readonly class Configuration ); } - /** - * Depending on where is called, it will extend the given classes and traits globally or locally. - */ public function extends(string ...$classAndTraits): UsesCall { return $this->extend(...$classAndTraits); } - /** - * Depending on where is called, it will add the given groups globally or locally. - */ public function group(string ...$groups): UsesCall { return new UsesCall($this->filename, [])->group(...$groups); } - /** - * Marks all tests in the current file to be run exclusively. - */ public function only(): void { new BeforeEachCall(TestSuite::getInstance(), $this->filename)->only(); } - /** - * Depending on where is called, it will extend the given classes and traits globally or locally. - */ public function use(string ...$classAndTraits): UsesCall { return $this->extend(...$classAndTraits); } - /** - * Depending on where is called, it will extend the given classes and traits globally or locally. - */ public function uses(string ...$classAndTraits): UsesCall { return $this->extends(...$classAndTraits); } - /** - * Gets the printer configuration. - */ public function printer(): Configuration\Printer { return new Configuration\Printer; } - /** - * Gets the presets configuration. - */ public function presets(): Configuration\Presets { return new Configuration\Presets; } - /** - * Gets the project configuration. - */ public function project(): Configuration\Project { return Configuration\Project::getInstance(); } - /** - * Gets the browser configuration. - */ public function browser(): Browser\Configuration { return new Browser\Configuration; } - /** - * Gets the evals configuration. - */ public function evals(): Evals\Configuration // @phpstan-ignore-line { return new Evals\Configuration; // @phpstan-ignore-line } - /** - * Gets the TIA (Test Impact Analysis) configuration. - */ public function tia(): Plugins\Tia\Configuration { return new Plugins\Tia\Configuration; } /** - * Proxies calls to the uses method. - * * @param array $arguments */ public function __call(string $name, array $arguments): mixed diff --git a/src/Configuration/Presets.php b/src/Configuration/Presets.php index ad8aec68..eda545ba 100644 --- a/src/Configuration/Presets.php +++ b/src/Configuration/Presets.php @@ -9,9 +9,6 @@ use Pest\Preset; final class Presets { - /** - * Creates a custom preset instance, and adds it to the list of presets. - */ public function custom(string $name, Closure $execute): void { Preset::custom($name, $execute); diff --git a/src/Configuration/Printer.php b/src/Configuration/Printer.php index b3f9500a..acfedb8e 100644 --- a/src/Configuration/Printer.php +++ b/src/Configuration/Printer.php @@ -11,9 +11,6 @@ use NunoMaduro\Collision\Adapters\Phpunit\Printers\DefaultPrinter; */ final readonly class Printer { - /** - * Sets the theme to compact. - */ public function compact(): self { DefaultPrinter::compact(true); diff --git a/src/Configuration/Project.php b/src/Configuration/Project.php index 9a735b48..c8b6a628 100644 --- a/src/Configuration/Project.php +++ b/src/Configuration/Project.php @@ -10,42 +10,27 @@ namespace Pest\Configuration; final class Project { /** - * The assignees link. - * * @internal */ public string $assignees = ''; /** - * The issues link. - * * @internal */ public string $issues = ''; /** - * The PRs link. - * * @internal */ public string $prs = ''; - /** - * The singleton instance. - */ private static ?self $instance = null; - /** - * Creates a new instance of the project. - */ public static function getInstance(): self { return self::$instance ??= new self; } - /** - * Sets the test project to GitHub. - */ public function github(string $project): self { $this->issues = "https://github.com/{$project}/issues/%s"; @@ -56,12 +41,8 @@ final class Project return $this; } - /** - * Sets the test project to GitLab. - */ public function gitlab(string $project, string $hostname = 'gitlab.com'): self { - // Simple way to ensure only the host is used $hostname = parse_url($hostname, PHP_URL_HOST) ?? $hostname; $this->issues = "https://{$hostname}/{$project}/-/work_items/%s"; @@ -72,9 +53,6 @@ final class Project return $this; } - /** - * Sets the test project to Bitbucket. - */ public function bitbucket(string $project): self { $this->issues = "https://bitbucket.org/{$project}/issues/%s"; @@ -85,9 +63,6 @@ final class Project return $this; } - /** - * Sets the test project to Jira. - */ public function jira(string $namespace, string $project): self { $this->issues = "https://{$namespace}.atlassian.net/browse/{$project}-%s"; @@ -97,9 +72,6 @@ final class Project return $this; } - /** - * Sets the test project to custom. - */ public function custom(string $issues, string $prs, string $assignees): self { $this->issues = $issues; diff --git a/src/Console/Help.php b/src/Console/Help.php index 50823d59..2a73f01c 100644 --- a/src/Console/Help.php +++ b/src/Console/Help.php @@ -12,8 +12,6 @@ use Symfony\Component\Console\Output\OutputInterface; final readonly class Help { /** - * The Command messages. - * * @var array */ private const array HELP_MESSAGES = [ @@ -24,17 +22,11 @@ final readonly class Help ' --group= Only runs tests from the specified group(s)', ]; - /** - * Creates a new Console Command instance. - */ public function __construct(private OutputInterface $output) { - // .. + // } - /** - * Executes the Console Command. - */ public function __invoke(): void { foreach (self::HELP_MESSAGES as $message) { diff --git a/src/Console/Thanks.php b/src/Console/Thanks.php index 8b056e48..ecdd21bd 100644 --- a/src/Console/Thanks.php +++ b/src/Console/Thanks.php @@ -18,8 +18,6 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; final readonly class Thanks { /** - * The support options. - * * @var array */ private const array FUNDING_MESSAGES = [ @@ -33,19 +31,13 @@ final readonly class Thanks 'Sponsor' => 'https://github.com/sponsors/nunomaduro', ]; - /** - * Creates a new Console Command instance. - */ public function __construct( private InputInterface $input, private OutputInterface $output ) { - // .. + // } - /** - * Executes the Console Command. - */ public function __invoke(): void { $bootstrapper = new BootView($this->output); diff --git a/src/Contracts/Bootstrapper.php b/src/Contracts/Bootstrapper.php index 520aede1..64c88301 100644 --- a/src/Contracts/Bootstrapper.php +++ b/src/Contracts/Bootstrapper.php @@ -9,8 +9,5 @@ namespace Pest\Contracts; */ interface Bootstrapper { - /** - * Boots the bootstrapper. - */ public function boot(): void; } diff --git a/src/Contracts/HasPrintableTestCaseName.php b/src/Contracts/HasPrintableTestCaseName.php index e46a634d..20e9faa2 100644 --- a/src/Contracts/HasPrintableTestCaseName.php +++ b/src/Contracts/HasPrintableTestCaseName.php @@ -11,5 +11,5 @@ use NunoMaduro\Collision\Contracts\Adapters\Phpunit\HasPrintableTestCaseName as */ interface HasPrintableTestCaseName extends BaseHasPrintableTestCaseName { - // .. + // } diff --git a/src/Contracts/Panicable.php b/src/Contracts/Panicable.php index f56b4b78..eafd3497 100644 --- a/src/Contracts/Panicable.php +++ b/src/Contracts/Panicable.php @@ -11,13 +11,7 @@ use Symfony\Component\Console\Output\OutputInterface; */ interface Panicable { - /** - * Renders the panic on the given output. - */ public function render(OutputInterface $output): void; - /** - * The exit code to be used. - */ public function exitCode(): int; } diff --git a/src/Contracts/Plugins/AddsOutput.php b/src/Contracts/Plugins/AddsOutput.php index a2ab4aeb..c7c3d48b 100644 --- a/src/Contracts/Plugins/AddsOutput.php +++ b/src/Contracts/Plugins/AddsOutput.php @@ -9,8 +9,5 @@ namespace Pest\Contracts\Plugins; */ interface AddsOutput { - /** - * Adds output after the Test Suite execution. - */ public function addOutput(int $exitCode): int; } diff --git a/src/Contracts/Plugins/Bootable.php b/src/Contracts/Plugins/Bootable.php index 00cadbb6..30106842 100644 --- a/src/Contracts/Plugins/Bootable.php +++ b/src/Contracts/Plugins/Bootable.php @@ -9,8 +9,5 @@ namespace Pest\Contracts\Plugins; */ interface Bootable { - /** - * Boots the plugin. - */ public function boot(): void; } diff --git a/src/Contracts/Plugins/HandlesArguments.php b/src/Contracts/Plugins/HandlesArguments.php index 50c3a30e..39a2e25a 100644 --- a/src/Contracts/Plugins/HandlesArguments.php +++ b/src/Contracts/Plugins/HandlesArguments.php @@ -10,8 +10,6 @@ namespace Pest\Contracts\Plugins; interface HandlesArguments { /** - * Adds arguments before the Test Suite execution. - * * @param array $arguments * @return array */ diff --git a/src/Contracts/Plugins/HandlesOriginalArguments.php b/src/Contracts/Plugins/HandlesOriginalArguments.php index ae4e7a54..e9511274 100644 --- a/src/Contracts/Plugins/HandlesOriginalArguments.php +++ b/src/Contracts/Plugins/HandlesOriginalArguments.php @@ -10,8 +10,6 @@ namespace Pest\Contracts\Plugins; interface HandlesOriginalArguments { /** - * Adds original arguments before the Test Suite execution. - * * @param array $arguments */ public function handleOriginalArguments(array $arguments): void; diff --git a/src/Contracts/Plugins/Terminable.php b/src/Contracts/Plugins/Terminable.php index a53a903f..f5e09fd2 100644 --- a/src/Contracts/Plugins/Terminable.php +++ b/src/Contracts/Plugins/Terminable.php @@ -9,8 +9,5 @@ namespace Pest\Contracts\Plugins; */ interface Terminable { - /** - * Terminates the plugin. - */ public function terminate(): void; } diff --git a/src/Contracts/TestCaseFilter.php b/src/Contracts/TestCaseFilter.php index f458396e..5b7049cc 100644 --- a/src/Contracts/TestCaseFilter.php +++ b/src/Contracts/TestCaseFilter.php @@ -6,8 +6,5 @@ namespace Pest\Contracts; interface TestCaseFilter { - /** - * Whether the test case is accepted. - */ public function accept(string $testCaseFilename): bool; } diff --git a/src/Contracts/TestCaseMethodFilter.php b/src/Contracts/TestCaseMethodFilter.php index 04f2f36f..93246501 100644 --- a/src/Contracts/TestCaseMethodFilter.php +++ b/src/Contracts/TestCaseMethodFilter.php @@ -8,8 +8,5 @@ use Pest\Factories\TestCaseMethodFactory; interface TestCaseMethodFilter { - /** - * Whether the test case method is accepted. - */ public function accept(TestCaseMethodFactory $factory): bool; } diff --git a/src/Evaluators/Attributes.php b/src/Evaluators/Attributes.php index 08930a39..25865dfd 100644 --- a/src/Evaluators/Attributes.php +++ b/src/Evaluators/Attributes.php @@ -12,8 +12,6 @@ use Pest\Factories\Attribute; final class Attributes { /** - * Evaluates the given attributes and returns the code. - * * @param iterable $attributes */ public static function code(iterable $attributes): string diff --git a/src/Exceptions/AfterAllAlreadyExist.php b/src/Exceptions/AfterAllAlreadyExist.php index 74d702bd..297a97a3 100644 --- a/src/Exceptions/AfterAllAlreadyExist.php +++ b/src/Exceptions/AfterAllAlreadyExist.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class AfterAllAlreadyExist extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct(sprintf('The afterAll already exists in the filename [%s].', $filename)); diff --git a/src/Exceptions/AfterAllWithinDescribe.php b/src/Exceptions/AfterAllWithinDescribe.php index d7b58833..8addbbc4 100644 --- a/src/Exceptions/AfterAllWithinDescribe.php +++ b/src/Exceptions/AfterAllWithinDescribe.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class AfterAllWithinDescribe extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct(sprintf('The afterAll method can not be used within describe functions. Filename [%s].', $filename)); diff --git a/src/Exceptions/AfterBeforeTestFunction.php b/src/Exceptions/AfterBeforeTestFunction.php index 019d4795..e61c2a81 100644 --- a/src/Exceptions/AfterBeforeTestFunction.php +++ b/src/Exceptions/AfterBeforeTestFunction.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class AfterBeforeTestFunction extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct('After method cannot be used with before the [test|it] functions in the filename ['.$filename.'].'); diff --git a/src/Exceptions/BeforeAllAlreadyExist.php b/src/Exceptions/BeforeAllAlreadyExist.php index baf1d1c2..1239f64b 100644 --- a/src/Exceptions/BeforeAllAlreadyExist.php +++ b/src/Exceptions/BeforeAllAlreadyExist.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class BeforeAllAlreadyExist extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct(sprintf('The beforeAll already exists in the filename [%s].', $filename)); diff --git a/src/Exceptions/BeforeAllWithinDescribe.php b/src/Exceptions/BeforeAllWithinDescribe.php index 8e4bb28b..e5574963 100644 --- a/src/Exceptions/BeforeAllWithinDescribe.php +++ b/src/Exceptions/BeforeAllWithinDescribe.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class BeforeAllWithinDescribe extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct(sprintf('The beforeAll method can not be used within describe functions. Filename [%s].', $filename)); diff --git a/src/Exceptions/DatasetAlreadyExists.php b/src/Exceptions/DatasetAlreadyExists.php index ca57cd85..fba9199b 100644 --- a/src/Exceptions/DatasetAlreadyExists.php +++ b/src/Exceptions/DatasetAlreadyExists.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class DatasetAlreadyExists extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $name, string $scope) { parent::__construct(sprintf('A dataset with the name [%s] already exists in scope [%s].', $name, $scope)); diff --git a/src/Exceptions/DatasetArgumentsMismatch.php b/src/Exceptions/DatasetArgumentsMismatch.php index 65b0f0f9..2a341868 100644 --- a/src/Exceptions/DatasetArgumentsMismatch.php +++ b/src/Exceptions/DatasetArgumentsMismatch.php @@ -16,6 +16,4 @@ final class DatasetArgumentsMismatch extends Exception parent::__construct(sprintf('Test expects %d arguments but dataset only provides %d', $requiredCount, $suppliedCount)); } } - - // } diff --git a/src/Exceptions/DatasetDoesNotExist.php b/src/Exceptions/DatasetDoesNotExist.php index fa8128c6..2ea344d6 100644 --- a/src/Exceptions/DatasetDoesNotExist.php +++ b/src/Exceptions/DatasetDoesNotExist.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class DatasetDoesNotExist extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $name) { parent::__construct(sprintf("A dataset with the name [%s] does not exist. You can create it using `dataset('%s', ['a', 'b']);`.", $name, $name)); diff --git a/src/Exceptions/DatasetMissing.php b/src/Exceptions/DatasetMissing.php index da738a44..4dfa773a 100644 --- a/src/Exceptions/DatasetMissing.php +++ b/src/Exceptions/DatasetMissing.php @@ -15,8 +15,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; final class DatasetMissing extends BadFunctionCallException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { /** - * Creates a new Exception instance. - * * @param array $arguments */ public function __construct(string $file, string $name, array $arguments) diff --git a/src/Exceptions/ExpectationNotFound.php b/src/Exceptions/ExpectationNotFound.php index af47c03f..2658973f 100644 --- a/src/Exceptions/ExpectationNotFound.php +++ b/src/Exceptions/ExpectationNotFound.php @@ -11,9 +11,6 @@ use Exception; */ final class ExpectationNotFound extends Exception { - /** - * Creates a new ExpectationNotFound instance from the given name. - */ public static function fromName(string $name): ExpectationNotFound { return new self("Expectation [$name] does not exist."); diff --git a/src/Exceptions/FileOrFolderNotFound.php b/src/Exceptions/FileOrFolderNotFound.php index 28735642..6cc5c226 100644 --- a/src/Exceptions/FileOrFolderNotFound.php +++ b/src/Exceptions/FileOrFolderNotFound.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class FileOrFolderNotFound extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $filename) { parent::__construct(sprintf('The file or folder with the name [%s] could not be found.', $filename)); diff --git a/src/Exceptions/InvalidArgumentException.php b/src/Exceptions/InvalidArgumentException.php index 6ba8ffa2..b0340337 100644 --- a/src/Exceptions/InvalidArgumentException.php +++ b/src/Exceptions/InvalidArgumentException.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $message) { parent::__construct($message, 1); diff --git a/src/Exceptions/InvalidOption.php b/src/Exceptions/InvalidOption.php index 515c0a42..e345c450 100644 --- a/src/Exceptions/InvalidOption.php +++ b/src/Exceptions/InvalidOption.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class InvalidOption extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $message) { parent::__construct($message, 1); diff --git a/src/Exceptions/InvalidPestCommand.php b/src/Exceptions/InvalidPestCommand.php index 388a7b65..42e766f6 100644 --- a/src/Exceptions/InvalidPestCommand.php +++ b/src/Exceptions/InvalidPestCommand.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class InvalidPestCommand extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct() { parent::__construct('Please run [./vendor/bin/pest] instead.'); diff --git a/src/Exceptions/InvalidTestClassName.php b/src/Exceptions/InvalidTestClassName.php index 319ffbd9..2c4d9dc1 100644 --- a/src/Exceptions/InvalidTestClassName.php +++ b/src/Exceptions/InvalidTestClassName.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class InvalidTestClassName extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance for the given class name. - */ public static function fromClassName(string $filename, string $className): self { return new self(sprintf( @@ -26,9 +23,6 @@ final class InvalidTestClassName extends InvalidArgumentException implements Exc )); } - /** - * Creates a new Exception instance for the given namespace. - */ public static function fromNamespace(string $filename, string $namespace, string $part): self { return new self(sprintf( diff --git a/src/Exceptions/MissingDependency.php b/src/Exceptions/MissingDependency.php index 7e033543..5e059afe 100644 --- a/src/Exceptions/MissingDependency.php +++ b/src/Exceptions/MissingDependency.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class MissingDependency extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $feature, string $dependency) { parent::__construct(sprintf('The feature [%s] requires [%s].', $feature, $dependency)); diff --git a/src/Exceptions/NoDirtyTestsFound.php b/src/Exceptions/NoDirtyTestsFound.php index 58f2e7b5..318f4b4b 100644 --- a/src/Exceptions/NoDirtyTestsFound.php +++ b/src/Exceptions/NoDirtyTestsFound.php @@ -16,9 +16,6 @@ use Symfony\Component\Console\Output\OutputInterface; */ final class NoDirtyTestsFound extends InvalidArgumentException implements ExceptionInterface, Panicable, RenderlessEditor, RenderlessTrace { - /** - * Renders the panic on the given output. - */ public function render(OutputInterface $output): void { $output->writeln([ @@ -28,9 +25,6 @@ final class NoDirtyTestsFound extends InvalidArgumentException implements Except ]); } - /** - * The exit code to be used. - */ public function exitCode(): int { return 0; diff --git a/src/Exceptions/ShouldNotHappen.php b/src/Exceptions/ShouldNotHappen.php index 3398af09..772463c9 100644 --- a/src/Exceptions/ShouldNotHappen.php +++ b/src/Exceptions/ShouldNotHappen.php @@ -12,9 +12,6 @@ use RuntimeException; */ final class ShouldNotHappen extends RuntimeException { - /** - * Creates a new Exception instance. - */ public function __construct(Exception $exception) { $message = $exception->getMessage(); @@ -29,9 +26,6 @@ EOF , $message, phpversion(), PHP_OS), 1, $exception); } - /** - * Creates a new instance of should not happen without a specific exception. - */ public static function fromMessage(string $message): ShouldNotHappen { return new ShouldNotHappen(new Exception($message)); diff --git a/src/Exceptions/TestAlreadyExist.php b/src/Exceptions/TestAlreadyExist.php index 209b7e07..a996a652 100644 --- a/src/Exceptions/TestAlreadyExist.php +++ b/src/Exceptions/TestAlreadyExist.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class TestAlreadyExist extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $fileName, string $description) { parent::__construct(sprintf('A test with the description [%s] already exists in the filename [%s].', $description, $fileName)); diff --git a/src/Exceptions/TestCaseAlreadyInUse.php b/src/Exceptions/TestCaseAlreadyInUse.php index 926c8ea6..05f10a21 100644 --- a/src/Exceptions/TestCaseAlreadyInUse.php +++ b/src/Exceptions/TestCaseAlreadyInUse.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class TestCaseAlreadyInUse extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $inUse, string $newOne, string $folder) { parent::__construct(sprintf( diff --git a/src/Exceptions/TestCaseClassOrTraitNotFound.php b/src/Exceptions/TestCaseClassOrTraitNotFound.php index a0f6e76f..431476aa 100644 --- a/src/Exceptions/TestCaseClassOrTraitNotFound.php +++ b/src/Exceptions/TestCaseClassOrTraitNotFound.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class TestCaseClassOrTraitNotFound extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $testCaseClass) { parent::__construct(sprintf('The class [%s] was not found.', $testCaseClass)); diff --git a/src/Exceptions/TestClosureMustNotBeStatic.php b/src/Exceptions/TestClosureMustNotBeStatic.php index 5dda67c0..dda25e79 100644 --- a/src/Exceptions/TestClosureMustNotBeStatic.php +++ b/src/Exceptions/TestClosureMustNotBeStatic.php @@ -15,9 +15,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class TestClosureMustNotBeStatic extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(TestCaseMethodFactory $method) { parent::__construct( diff --git a/src/Exceptions/TestDescriptionMissing.php b/src/Exceptions/TestDescriptionMissing.php index 13957273..591020f7 100644 --- a/src/Exceptions/TestDescriptionMissing.php +++ b/src/Exceptions/TestDescriptionMissing.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Exception\ExceptionInterface; */ final class TestDescriptionMissing extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace { - /** - * Creates a new Exception instance. - */ public function __construct(string $fileName) { parent::__construct(sprintf('Test description is missing in the filename [%s].', $fileName)); diff --git a/src/Expectation.php b/src/Expectation.php index 8596615b..79e9aba0 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Pest; -use Attribute; use BadMethodCallException; use Closure; use InvalidArgumentException; @@ -60,19 +59,15 @@ final class Expectation use Retrievable; /** - * Creates a new expectation. - * * @param TValue $value */ public function __construct( public mixed $value ) { - // .. + // } /** - * Creates a new expectation. - * * @template TAndValue * * @param TAndValue $value @@ -84,8 +79,6 @@ final class Expectation } /** - * Creates a new expectation with the decoded JSON value. - * * @return self|bool> */ public function json(): Expectation @@ -103,8 +96,6 @@ final class Expectation } /** - * Dump the expectation value. - * * @return self */ public function dump(mixed ...$arguments): self @@ -118,9 +109,6 @@ final class Expectation return $this; } - /** - * Dump the expectation value and end the script. - */ public function dd(mixed ...$arguments): never { if (function_exists('dd')) { @@ -141,8 +129,6 @@ final class Expectation } /** - * Dump the expectation value when the result of the condition is truthy. - * * @param (Closure(TValue): bool)|bool $condition * @return self */ @@ -158,8 +144,6 @@ final class Expectation } /** - * Dump the expectation value when the result of the condition is falsy. - * * @param (Closure(TValue): bool)|bool $condition * @return self */ @@ -175,8 +159,6 @@ final class Expectation } /** - * Send the expectation value to Ray along with all given arguments. - * * @return self */ public function ray(mixed ...$arguments): self @@ -189,8 +171,6 @@ final class Expectation } /** - * Creates the opposite expectation for the value. - * * @return OppositeExpectation */ public function not(): OppositeExpectation @@ -199,8 +179,6 @@ final class Expectation } /** - * Creates an expectation on each item of the iterable "value". - * * @return EachExpectation */ public function each(?callable $callback = null): EachExpectation @@ -219,8 +197,6 @@ final class Expectation } /** - * Allows you to specify a sequential set of expectations for each item in a iterable "value". - * * @template TSequenceValue * * @param (callable(self, self): void)|TSequenceValue ...$callbacks @@ -258,8 +234,6 @@ final class Expectation } /** - * If the subject matches one of the given "expressions", the expression callback will run. - * * @template TMatchSubject of array-key * * @param (callable(): TMatchSubject)|TMatchSubject $subject @@ -298,8 +272,6 @@ final class Expectation } /** - * Apply the callback if the given "condition" is falsy. - * * @param (callable(): bool)|bool $condition * @param callable(Expectation): mixed $callback * @return self @@ -314,8 +286,6 @@ final class Expectation } /** - * Apply the callback if the given "condition" is truthy. - * * @param (callable(): bool)|bool $condition * @param callable(self): mixed $callback * @return self @@ -334,8 +304,6 @@ final class Expectation } /** - * Dynamically calls methods on the class or creates a new higher order expectation. - * * @param array $parameters * @return Expectation|HigherOrderExpectation, TValue> */ @@ -379,8 +347,6 @@ final class Expectation } /** - * Creates a new expectation closure from the given name. - * * @throws ExpectationNotFound */ private function getExpectationClosure(string $name): Closure @@ -402,8 +368,6 @@ final class Expectation } /** - * Dynamically calls methods on the class without any arguments or creates a new higher order expectation. - * * @return Expectation|OppositeExpectation|EachExpectation|HigherOrderExpectation, TValue|null>|TValue */ public function __get(string $name): mixed @@ -422,9 +386,6 @@ final class Expectation return $this->{$name}(); } - /** - * Checks if the given expectation method exists. - */ public static function hasMethod(string $name): bool { return method_exists(self::class, $name) @@ -432,17 +393,12 @@ final class Expectation || self::hasExtend($name); } - /** - * Matches any value. - */ public function any(): Any { return new Any; } /** - * Asserts that the given expectation target use the given dependencies. - * * @param array|string $targets */ public function toUse(array|string $targets): ArchExpectation @@ -450,9 +406,6 @@ final class Expectation return ToUse::make($this, $targets); } - /** - * Asserts that the given expectation target does have the given permissions - */ public function toHaveFileSystemPermissions(string $permissions): ArchExpectation { return Targeted::make( @@ -463,9 +416,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to have line count less than the given number. - */ public function toHaveLineCountLessThan(int $lines): ArchExpectation { return Targeted::make( @@ -476,9 +426,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target have all methods documented. - */ public function toHaveMethodsDocumented(): ArchExpectation { return Targeted::make( @@ -495,9 +442,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target have all properties documented. - */ public function toHavePropertiesDocumented(): ArchExpectation { return Targeted::make( @@ -515,9 +459,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target use the "declare(strict_types=1)" declaration. - */ public function toUseStrictTypes(): ArchExpectation { return Targeted::make( @@ -528,9 +469,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target uses strict equality. - */ public function toUseStrictEquality(): ArchExpectation { return Targeted::make( @@ -541,9 +479,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target is final. - */ public function toBeFinal(): ArchExpectation { return Targeted::make( @@ -554,9 +489,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target is readonly. - */ public function toBeReadonly(): ArchExpectation { return Targeted::make( @@ -567,9 +499,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target is trait. - */ public function toBeTrait(): ArchExpectation { return Targeted::make( @@ -580,17 +509,11 @@ final class Expectation ); } - /** - * Asserts that the given expectation targets are traits. - */ public function toBeTraits(): ArchExpectation { return $this->toBeTrait(); } - /** - * Asserts that the given expectation target is abstract. - */ public function toBeAbstract(): ArchExpectation { return Targeted::make( @@ -602,8 +525,6 @@ final class Expectation } /** - * Asserts that the given expectation target has a specific method. - * * @param array|string $method */ public function toHaveMethod(array|string $method): ArchExpectation @@ -619,8 +540,6 @@ final class Expectation } /** - * Asserts that the given expectation target has a specific methods. - * * @param array $methods */ public function toHaveMethods(array $methods): ArchExpectation @@ -628,57 +547,36 @@ final class Expectation return $this->toHaveMethod($methods); } - /** - * Not supported. - */ public function toHavePublicMethodsBesides(): void { throw InvalidExpectation::fromMethods(['toHavePublicMethodsBesides']); } - /** - * Not supported. - */ public function toHavePublicMethods(): void { throw InvalidExpectation::fromMethods(['toHavePublicMethods']); } - /** - * Not supported. - */ public function toHaveProtectedMethodsBesides(): void { throw InvalidExpectation::fromMethods(['toHaveProtectedMethodsBesides']); } - /** - * Not supported. - */ public function toHaveProtectedMethods(): void { throw InvalidExpectation::fromMethods(['toHaveProtectedMethods']); } - /** - * Not supported. - */ public function toHavePrivateMethodsBesides(): void { throw InvalidExpectation::fromMethods(['toHavePrivateMethodsBesides']); } - /** - * Not supported. - */ public function toHavePrivateMethods(): void { throw InvalidExpectation::fromMethods(['toHavePrivateMethods']); } - /** - * Asserts that the given expectation target is cased correctly. - */ public function toBeCasedCorrectly(): ArchExpectation { return Targeted::make( @@ -711,9 +609,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target is enum. - */ public function toBeEnum(): ArchExpectation { return Targeted::make( @@ -724,17 +619,11 @@ final class Expectation ); } - /** - * Asserts that the given expectation targets are enums. - */ public function toBeEnums(): ArchExpectation { return $this->toBeEnum(); } - /** - * Asserts that the given expectation target is a class. - */ public function toBeClass(): ArchExpectation { return Targeted::make( @@ -745,17 +634,11 @@ final class Expectation ); } - /** - * Asserts that the given expectation targets are classes. - */ public function toBeClasses(): ArchExpectation { return $this->toBeClass(); } - /** - * Asserts that the given expectation target is interface. - */ public function toBeInterface(): ArchExpectation { return Targeted::make( @@ -766,17 +649,11 @@ final class Expectation ); } - /** - * Asserts that the given expectation targets are interfaces. - */ public function toBeInterfaces(): ArchExpectation { return $this->toBeInterface(); } - /** - * Asserts that the given expectation target to be subclass of the given class. - */ public function toExtend(string $class): ArchExpectation { return Targeted::make( @@ -787,9 +664,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to be have a parent class. - */ public function toExtendNothing(): ArchExpectation { return Targeted::make( @@ -800,17 +674,12 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to use the given trait. - */ public function toUseTrait(string $trait): ArchExpectation { return $this->toUseTraits($trait); } /** - * Asserts that the given expectation target to use the given traits. - * * @param array|string $traits */ public function toUseTraits(array|string $traits): ArchExpectation @@ -852,9 +721,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to not implement any interfaces. - */ public function toImplementNothing(): ArchExpectation { return Targeted::make( @@ -866,8 +732,6 @@ final class Expectation } /** - * Asserts that the given expectation target to only implement the given interfaces. - * * @param array|string $interfaces */ public function toOnlyImplement(array|string $interfaces): ArchExpectation @@ -884,9 +748,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to have the given prefix. - */ public function toHavePrefix(string $prefix): ArchExpectation { return Targeted::make( @@ -897,9 +758,6 @@ final class Expectation ); } - /** - * Asserts that the given expectation target to have the given suffix. - */ public function toHaveSuffix(string $suffix): ArchExpectation { return Targeted::make( @@ -911,8 +769,6 @@ final class Expectation } /** - * Asserts that the given expectation target to implement the given interfaces. - * * @param array|string $interfaces */ public function toImplement(array|string $interfaces): ArchExpectation @@ -928,8 +784,6 @@ final class Expectation } /** - * Asserts that the given expectation target "only" use on the given dependencies. - * * @param array|string $targets */ public function toOnlyUse(array|string $targets): ArchExpectation @@ -937,33 +791,22 @@ final class Expectation return ToOnlyUse::make($this, $targets); } - /** - * Asserts that the given expectation target does not use any dependencies. - */ public function toUseNothing(): ArchExpectation { return ToUseNothing::make($this); } - /** - * Asserts that the source code of the given expectation target does not include suspicious characters. - */ public function toHaveSuspiciousCharacters(): ArchExpectation { throw InvalidExpectation::fromMethods(['toHaveSuspiciousCharacters']); } - /** - * Not supported. - */ public function toBeUsed(): void { throw InvalidExpectation::fromMethods(['toBeUsed']); } /** - * Asserts that the given expectation dependency is used by the given targets. - * * @param array|string $targets */ public function toBeUsedIn(array|string $targets): ArchExpectation @@ -972,8 +815,6 @@ final class Expectation } /** - * Asserts that the given expectation dependency is "only" used by the given targets. - * * @param array|string $targets */ public function toOnlyBeUsedIn(array|string $targets): ArchExpectation @@ -981,17 +822,11 @@ final class Expectation return ToOnlyBeUsedIn::make($this, $targets); } - /** - * Asserts that the given expectation dependency is not used. - */ public function toBeUsedInNothing(): ArchExpectation { return ToBeUsedInNothing::make($this); } - /** - * Asserts that the given expectation dependency is an invokable class. - */ public function toBeInvokable(): ArchExpectation { return Targeted::make( @@ -1003,8 +838,6 @@ final class Expectation } /** - * Asserts that the given expectation is iterable and contains snake_case keys. - * * @return self */ public function toHaveSnakeCaseKeys(string $message = ''): self @@ -1027,8 +860,6 @@ final class Expectation } /** - * Asserts that the given expectation is iterable and contains kebab-case keys. - * * @return self */ public function toHaveKebabCaseKeys(string $message = ''): self @@ -1051,8 +882,6 @@ final class Expectation } /** - * Asserts that the given expectation is iterable and contains camelCase keys. - * * @return self */ public function toHaveCamelCaseKeys(string $message = ''): self @@ -1075,8 +904,6 @@ final class Expectation } /** - * Asserts that the given expectation is iterable and contains StudlyCase keys. - * * @return self */ public function toHaveStudlyCaseKeys(string $message = ''): self @@ -1098,9 +925,6 @@ final class Expectation return $this; } - /** - * Asserts that the given expectation target to have the given attribute. - */ public function toHaveAttribute(string $attribute): ArchExpectation { return Targeted::make( @@ -1111,25 +935,16 @@ final class Expectation ); } - /** - * Asserts that the given expectation target has a constructor method. - */ public function toHaveConstructor(): ArchExpectation { return $this->toHaveMethod('__construct'); } - /** - * Asserts that the given expectation target has a destructor method. - */ public function toHaveDestructor(): ArchExpectation { return $this->toHaveMethod('__destruct'); } - /** - * Asserts that the given expectation target is a backed enum of given type. - */ private function toBeBackedEnum(string $backingType): ArchExpectation { return Targeted::make( @@ -1143,33 +958,21 @@ final class Expectation ); } - /** - * Asserts that the given expectation targets are string backed enums. - */ public function toBeStringBackedEnums(): ArchExpectation { return $this->toBeStringBackedEnum(); } - /** - * Asserts that the given expectation targets are int backed enums. - */ public function toBeIntBackedEnums(): ArchExpectation { return $this->toBeIntBackedEnum(); } - /** - * Asserts that the given expectation target is a string backed enum. - */ public function toBeStringBackedEnum(): ArchExpectation { return $this->toBeBackedEnum('string'); } - /** - * Asserts that the given expectation target is an int backed enum. - */ public function toBeIntBackedEnum(): ArchExpectation { return $this->toBeBackedEnum('int'); diff --git a/src/Expectations/EachExpectation.php b/src/Expectations/EachExpectation.php index 51a049a8..52db78e0 100644 --- a/src/Expectations/EachExpectation.php +++ b/src/Expectations/EachExpectation.php @@ -17,21 +17,14 @@ use function expect; */ final class EachExpectation { - /** - * Indicates if the expectation is the opposite. - */ private bool $opposite = false; /** - * Creates an expectation on each item of the iterable "value". - * * @param Expectation $original */ public function __construct(private readonly Expectation $original) {} /** - * Creates a new expectation. - * * @template TAndValue * * @param TAndValue $value @@ -43,8 +36,6 @@ final class EachExpectation } /** - * Creates the opposite expectation for the value. - * * @return self */ public function not(): self @@ -55,8 +46,6 @@ final class EachExpectation } /** - * Dynamically calls methods on the class with the given arguments on each item. - * * @param array $arguments * @return self */ @@ -73,8 +62,6 @@ final class EachExpectation } /** - * Dynamically calls methods on the class without any arguments on each item. - * * @return self */ public function __get(string $name): self diff --git a/src/Expectations/HigherOrderExpectation.php b/src/Expectations/HigherOrderExpectation.php index abf521de..12c5decb 100644 --- a/src/Expectations/HigherOrderExpectation.php +++ b/src/Expectations/HigherOrderExpectation.php @@ -25,19 +25,11 @@ final class HigherOrderExpectation */ private Expectation|EachExpectation $expectation; - /** - * Indicates if the expectation is the opposite. - */ private bool $opposite = false; - /** - * Indicates if the expectation should reset the value. - */ private bool $shouldReset = false; /** - * Creates a new higher order expectation. - * * @param Expectation $original * @param TValue $value */ @@ -47,8 +39,6 @@ final class HigherOrderExpectation } /** - * Creates the opposite expectation for the value. - * * @return self */ public function not(): self @@ -59,8 +49,6 @@ final class HigherOrderExpectation } /** - * Creates a new Expectation. - * * @template TExpectValue * * @param TExpectValue $value @@ -72,8 +60,6 @@ final class HigherOrderExpectation } /** - * Creates a new expectation. - * * @template TExpectValue * * @param TExpectValue $value @@ -85,9 +71,6 @@ final class HigherOrderExpectation } /** - * Scope an expectation callback to the current value in - * the HigherOrderExpectation chain. - * * @param Closure(Expectation): void $expectation * @return HigherOrderExpectation */ @@ -99,8 +82,6 @@ final class HigherOrderExpectation } /** - * Creates a new expectation with the decoded JSON value. - * * @return self|bool> */ public function json(): self @@ -109,8 +90,6 @@ final class HigherOrderExpectation } /** - * Dynamically calls methods on the class with the given arguments. - * * @param array $arguments * @return self */ @@ -125,8 +104,6 @@ final class HigherOrderExpectation } /** - * Accesses properties in the value or in the expectation. - * * @return self */ public function __get(string $name): self @@ -145,9 +122,6 @@ final class HigherOrderExpectation return $this->performAssertion($name, []); } - /** - * Determines if the original expectation has the given method name. - */ private function expectationHasMethod(string $name): bool { if (method_exists($this->original, $name)) { @@ -161,8 +135,6 @@ final class HigherOrderExpectation } /** - * Retrieve the applicable value based on the current reset condition. - * * @return TOriginalValue|TValue */ private function getValue(): mixed @@ -171,8 +143,6 @@ final class HigherOrderExpectation } /** - * Performs the given assertion with the current expectation. - * * @param array $arguments * @return self */ diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index d1693cb6..3693a352 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Pest\Expectations; -use Attribute; use Pest\Arch\Contracts\ArchExpectation; use Pest\Arch\Expectations\Targeted; use Pest\Arch\Expectations\ToBeUsedIn; @@ -38,15 +37,11 @@ use stdClass; final readonly class OppositeExpectation { /** - * Creates a new opposite expectation. - * * @param Expectation $original */ public function __construct(private Expectation $original) {} /** - * Asserts that the value array not has the provided $keys. - * * @param array> $keys * @return Expectation */ @@ -70,8 +65,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation target does not use any of the given dependencies. - * * @param array|string $targets */ public function toUse(array|string $targets): ArchExpectation @@ -84,9 +77,6 @@ final readonly class OppositeExpectation ), is_string($targets) ? [$targets] : $targets)); } - /** - * Asserts that the given expectation target does not have the given permissions - */ public function toHaveFileSystemPermissions(string $permissions): ArchExpectation { /** @var Expectation|string> $original */ @@ -100,17 +90,11 @@ final readonly class OppositeExpectation ); } - /** - * Not supported. - */ public function toHaveLineCountLessThan(): ArchExpectation { throw InvalidExpectation::fromMethods(['not', 'toHaveLineCountLessThan']); } - /** - * Not supported. - */ public function toHaveMethodsDocumented(): ArchExpectation { /** @var Expectation|string> $original */ @@ -130,9 +114,6 @@ final readonly class OppositeExpectation ); } - /** - * Not supported. - */ public function toHavePropertiesDocumented(): ArchExpectation { /** @var Expectation|string> $original */ @@ -153,9 +134,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target does not use the "declare(strict_types=1)" declaration. - */ public function toUseStrictTypes(): ArchExpectation { /** @var Expectation|string> $original */ @@ -169,9 +147,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target does not use the strict equality operator. - */ public function toUseStrictEquality(): ArchExpectation { /** @var Expectation|string> $original */ @@ -185,9 +160,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target is not final. - */ public function toBeFinal(): ArchExpectation { /** @var Expectation|string> $original */ @@ -201,9 +173,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target is not readonly. - */ public function toBeReadonly(): ArchExpectation { /** @var Expectation|string> $original */ @@ -217,9 +186,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target is not trait. - */ public function toBeTrait(): ArchExpectation { /** @var Expectation|string> $original */ @@ -233,17 +199,11 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation targets are not traits. - */ public function toBeTraits(): ArchExpectation { return $this->toBeTrait(); } - /** - * Asserts that the given expectation target is not abstract. - */ public function toBeAbstract(): ArchExpectation { /** @var Expectation|string> $original */ @@ -258,8 +218,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation target does not have a specific method. - * * @param array|string $method */ public function toHaveMethod(array|string $method): ArchExpectation @@ -280,9 +238,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target does not have suspicious characters. - */ public function toHaveSuspiciousCharacters(): ArchExpectation { if (! class_exists(Spoofchecker::class)) { @@ -303,8 +258,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation target does not have the given methods. - * * @param array $methods */ public function toHaveMethods(array $methods): ArchExpectation @@ -313,8 +266,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation target not to have the public methods besides the given methods. - * * @param array|string $methods */ public function toHavePublicMethodsBesides(array|string $methods): ArchExpectation @@ -350,17 +301,12 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target not to have the public methods. - */ public function toHavePublicMethods(): ArchExpectation { return $this->toHavePublicMethodsBesides([]); } /** - * Asserts that the given expectation target not to have the protected methods besides the given methods. - * * @param array|string $methods */ public function toHaveProtectedMethodsBesides(array|string $methods): ArchExpectation @@ -396,17 +342,12 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target not to have the protected methods. - */ public function toHaveProtectedMethods(): ArchExpectation { return $this->toHaveProtectedMethodsBesides([]); } /** - * Asserts that the given expectation target not to have the private methods besides the given methods. - * * @param array|string $methods */ public function toHavePrivateMethodsBesides(array|string $methods): ArchExpectation @@ -442,17 +383,11 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target not to have the private methods. - */ public function toHavePrivateMethods(): ArchExpectation { return $this->toHavePrivateMethodsBesides([]); } - /** - * Asserts that the given expectation target is not enum. - */ public function toBeEnum(): ArchExpectation { /** @var Expectation|string> $original */ @@ -466,17 +401,11 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation targets are not enums. - */ public function toBeEnums(): ArchExpectation { return $this->toBeEnum(); } - /** - * Asserts that the given expectation targets is not class. - */ public function toBeClass(): ArchExpectation { /** @var Expectation|string> $original */ @@ -490,17 +419,11 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation targets are not classes. - */ public function toBeClasses(): ArchExpectation { return $this->toBeClass(); } - /** - * Asserts that the given expectation target is not interface. - */ public function toBeInterface(): ArchExpectation { /** @var Expectation|string> $original */ @@ -514,17 +437,11 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation targets are not interfaces. - */ public function toBeInterfaces(): ArchExpectation { return $this->toBeInterface(); } - /** - * Asserts that the given expectation target to be not subclass of the given class. - */ public function toExtend(string $class): ArchExpectation { /** @var Expectation|string> $original */ @@ -538,9 +455,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target to be not have any parent class. - */ public function toExtendNothing(): ArchExpectation { /** @var Expectation|string> $original */ @@ -554,17 +468,12 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target not to use the given trait. - */ public function toUseTrait(string $trait): ArchExpectation { return $this->toUseTraits($trait); } /** - * Asserts that the given expectation target not to use the given traits. - * * @param array|string $traits */ public function toUseTraits(array|string $traits): ArchExpectation @@ -583,8 +492,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation target not to implement the given interfaces. - * * @param array|string $interfaces */ public function toImplement(array|string $interfaces): ArchExpectation @@ -602,9 +509,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target to not implement any interfaces. - */ public function toImplementNothing(): ArchExpectation { /** @var Expectation|string> $original */ @@ -618,17 +522,11 @@ final readonly class OppositeExpectation ); } - /** - * Not supported. - */ public function toOnlyImplement(): void { throw InvalidExpectation::fromMethods(['not', 'toOnlyImplement']); } - /** - * Asserts that the given expectation target to not have the given prefix. - */ public function toHavePrefix(string $prefix): ArchExpectation { /** @var Expectation|string> $original */ @@ -642,9 +540,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target to not have the given suffix. - */ public function toHaveSuffix(string $suffix): ArchExpectation { /** @var Expectation|string> $original */ @@ -658,25 +553,16 @@ final readonly class OppositeExpectation ); } - /** - * Not supported. - */ public function toOnlyUse(): void { throw InvalidExpectation::fromMethods(['not', 'toOnlyUse']); } - /** - * Not supported. - */ public function toUseNothing(): void { throw InvalidExpectation::fromMethods(['not', 'toUseNothing']); } - /** - * Asserts that the given expectation dependency is not used. - */ public function toBeUsed(): ArchExpectation { /** @var Expectation|string> $original */ @@ -686,8 +572,6 @@ final readonly class OppositeExpectation } /** - * Asserts that the given expectation dependency is not used by any of the given targets. - * * @param array|string $targets */ public function toBeUsedIn(array|string $targets): ArchExpectation @@ -705,17 +589,11 @@ final readonly class OppositeExpectation throw InvalidExpectation::fromMethods(['not', 'toOnlyBeUsedIn']); } - /** - * Asserts that the given expectation dependency is not used. - */ public function toBeUsedInNothing(): void { throw InvalidExpectation::fromMethods(['not', 'toBeUsedInNothing']); } - /** - * Asserts that the given expectation dependency is not an invokable class. - */ public function toBeInvokable(): ArchExpectation { /** @var Expectation|string> $original */ @@ -729,9 +607,6 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation target not to have the given attribute. - */ public function toHaveAttribute(string $attribute): ArchExpectation { /** @var Expectation|string> $original */ @@ -746,8 +621,6 @@ final readonly class OppositeExpectation } /** - * Handle dynamic method calls into the original expectation. - * * @param array $arguments * @return Expectation|Expectation|never */ @@ -768,8 +641,6 @@ final readonly class OppositeExpectation } /** - * Handle dynamic properties gets into the original expectation. - * * @return Expectation|Expectation|never */ public function __get(string $name): Expectation @@ -788,8 +659,6 @@ final readonly class OppositeExpectation } /** - * Creates a new expectation failed exception with a nice readable message. - * * @param array|string $arguments */ public function throwExpectationFailedException(string $name, array|string $arguments = []): never @@ -806,25 +675,16 @@ final readonly class OppositeExpectation )); } - /** - * Asserts that the given expectation target does not have a constructor method. - */ public function toHaveConstructor(): ArchExpectation { return $this->toHaveMethod('__construct'); } - /** - * Asserts that the given expectation target does not have a destructor method. - */ public function toHaveDestructor(): ArchExpectation { return $this->toHaveMethod('__destruct'); } - /** - * Asserts that the given expectation target is not a backed enum of given type. - */ private function toBeBackedEnum(string $backingType): ArchExpectation { /** @var Expectation|string> $original */ @@ -841,33 +701,21 @@ final readonly class OppositeExpectation ); } - /** - * Asserts that the given expectation targets are not string backed enums. - */ public function toBeStringBackedEnums(): ArchExpectation { return $this->toBeStringBackedEnum(); } - /** - * Asserts that the given expectation targets are not int backed enums. - */ public function toBeIntBackedEnums(): ArchExpectation { return $this->toBeIntBackedEnum(); } - /** - * Asserts that the given expectation target is not a string backed enum. - */ public function toBeStringBackedEnum(): ArchExpectation { return $this->toBeBackedEnum('string'); } - /** - * Asserts that the given expectation target is not an int backed enum. - */ public function toBeIntBackedEnum(): ArchExpectation { return $this->toBeBackedEnum('int'); diff --git a/src/Factories/Concerns/HigherOrderable.php b/src/Factories/Concerns/HigherOrderable.php index 1ef07b4e..ba8dc916 100644 --- a/src/Factories/Concerns/HigherOrderable.php +++ b/src/Factories/Concerns/HigherOrderable.php @@ -8,24 +8,12 @@ use Pest\Support\HigherOrderMessageCollection; trait HigherOrderable { - /** - * The higher order messages that are chainable. - */ public HigherOrderMessageCollection $chains; - /** - * The higher order messages that are "factory" proxyable. - */ public HigherOrderMessageCollection $factoryProxies; - /** - * The higher order messages that are proxyable. - */ public HigherOrderMessageCollection $proxies; - /** - * Boot the higher order properties. - */ private function bootHigherOrderable(): void { $this->chains = new HigherOrderMessageCollection; diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index c2ee64fe..dc5910de 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -30,29 +30,21 @@ final class TestCaseFactory use HigherOrderable; /** - * The list of attributes. - * * @var array */ public array $attributes = []; /** - * The FQN of the Test Case class. - * * @var class-string */ public string $class = TestCase::class; /** - * The list of class methods. - * * @var array */ public array $methods = []; /** - * The list of class traits. - * * @var array */ public array $traits = [ @@ -60,14 +52,8 @@ final class TestCaseFactory Concerns\Expectable::class, ]; - /** - * The namespace for the test case, overrides the path-based namespace when set. - */ public ?string $namespace = null; - /** - * Creates a new Factory instance. - */ public function __construct( public string $filename ) { @@ -84,14 +70,11 @@ final class TestCaseFactory } /** - * Creates a Test Case class using a runtime evaluate. - * * @param array $methods */ public function evaluate(string $filename, array $methods): void { if ('\\' === DIRECTORY_SEPARATOR) { - // In case Windows, strtolower drive name, like in UsesCall. $filename = (string) preg_replace_callback('~^(?P[a-z]+:\\\)~i', static fn (array $match): string => strtolower($match['drive']), $filename); } @@ -114,11 +97,8 @@ final class TestCaseFactory $relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath); - // Strip out any %-encoded octets. $relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath); - // Remove escaped quote sequences (maintain namespace) $relativePath = str_replace(array_map(fn (string $quote): string => sprintf('\\%s', $quote), ['\'', '"']), '', $relativePath); - // Limit to Unicode letters and numbers. $relativePath = (string) preg_replace('/[^\p{L}\p{N}\\\\]/u', '', $relativePath); $classFQN = 'P\\'.$relativePath; @@ -197,9 +177,6 @@ final class TestCaseFactory } } - /** - * Adds the given Method to the Test Case. - */ public function addMethod(TestCaseMethodFactory $method): void { if ($method->description === null) { @@ -233,9 +210,6 @@ final class TestCaseFactory $this->methods[$method->description] = $method; } - /** - * Checks if a test case has a method. - */ public function hasMethod(string $methodName): bool { foreach ($this->methods as $method) { @@ -251,9 +225,6 @@ final class TestCaseFactory return false; } - /** - * Gets a Method by the given name. - */ public function getMethod(string $methodName): TestCaseMethodFactory { foreach ($this->methods as $method) { diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index 5151a917..571e253b 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -27,84 +27,54 @@ final class TestCaseMethodFactory use HigherOrderable; /** - * The list of attributes. - * * @var array */ public array $attributes = []; /** - * The test's describing, if any. - * * @var array */ public array $describing = []; - /** - * The test's description, if any. - */ public ?string $description = null; - /** - * The test's number of repetitions. - */ public int $repetitions = 1; - /** - * The test's number of flaky retry tries. - */ public ?int $flakyTries = null; - /** - * Determines if the test is a "todo". - */ public bool $todo = false; /** - * The associated issue numbers. - * * @var array */ public array $issues = []; /** - * The test assignees. - * * @var array */ public array $assignees = []; /** - * The associated PRs numbers. - * * @var array */ public array $prs = []; /** - * The test's notes. - * * @var array */ public array $notes = []; /** - * The test's datasets. - * * @var array|string> */ public array $datasets = []; /** - * The test's dependencies. - * * @var array */ public array $depends = []; /** - * The test's groups. - * * @var array */ public array $groups = []; @@ -114,9 +84,6 @@ final class TestCaseMethodFactory */ public bool $__ran = false; - /** - * Creates a new test case method factory instance. - */ public function __construct( public string $filename, public ?Closure $closure, @@ -128,9 +95,6 @@ final class TestCaseMethodFactory $this->bootHigherOrderable(); } - /** - * Sets the test's hooks, and runs any proxy to the test case. - */ public function setUp(TestCase $concrete): void { $concrete::flush(); // @phpstan-ignore-line @@ -146,17 +110,11 @@ final class TestCaseMethodFactory $this->factoryProxies->proxy($concrete); } - /** - * Flushes the test case. - */ public function tearDown(TestCase $concrete): void { $concrete::flush(); // @phpstan-ignore-line } - /** - * Creates the test's closure. - */ public function getClosure(): Closure { $closure = $this->closure; @@ -178,17 +136,11 @@ final class TestCaseMethodFactory }; } - /** - * Determine if the test case will receive argument input from Pest, or not. - */ public function receivesArguments(): bool { return $this->datasets !== [] || $this->depends !== [] || $this->repetitions > 1; } - /** - * Creates a PHPUnit method as a string ready for evaluation. - */ public function buildForEvaluation(): string { if ($this->description === null) { @@ -248,9 +200,6 @@ final class TestCaseMethodFactory PHP; } - /** - * Creates a PHPUnit Data Provider as a string ready for evaluation. - */ private function buildDatasetForEvaluation(string $methodName, string $dataProviderName): string { $datasets = $this->datasets; diff --git a/src/Functions.php b/src/Functions.php index cce5566b..5a8dc6f0 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -27,8 +27,6 @@ use PHPUnit\Framework\TestCase; if (! function_exists('expect')) { /** - * Creates a new expectation. - * * @template TValue * * @param TValue|null $value @@ -41,9 +39,6 @@ if (! function_exists('expect')) { } if (! function_exists('beforeAll')) { - /** - * Runs the given closure before all tests in the current file. - */ function beforeAll(Closure $closure): void { if (DescribeCall::describing() !== []) { @@ -58,8 +53,6 @@ if (! function_exists('beforeAll')) { if (! function_exists('beforeEach')) { /** - * Runs the given closure before each test in the current file. - * * @param-closure-this TestCall $closure */ function beforeEach(?Closure $closure = null): BeforeEachCall @@ -72,8 +65,6 @@ if (! function_exists('beforeEach')) { if (! function_exists('dataset')) { /** - * Registers the given dataset. - * * @param Closure|iterable $dataset */ function dataset(string $name, Closure|iterable $dataset): void @@ -85,11 +76,6 @@ if (! function_exists('dataset')) { } if (! function_exists('describe')) { - /** - * Adds the given closure as a group of tests. The first argument - * is the group description; the second argument is a closure - * that contains the group tests. - */ function describe(string $description, Closure $tests): DescribeCall { $filename = Backtrace::testFile(); @@ -100,9 +86,6 @@ if (! function_exists('describe')) { if (! function_exists('uses')) { /** - * The uses function binds the given - * arguments to test closures. - * * @param class-string ...$classAndTraits */ function uses(string ...$classAndTraits): UsesCall @@ -114,9 +97,6 @@ if (! function_exists('uses')) { } if (! function_exists('pest')) { - /** - * Creates a new Pest configuration instance. - */ function pest(): Configuration { return new Configuration(Backtrace::testFile()); @@ -125,10 +105,6 @@ if (! function_exists('pest')) { if (! function_exists('test')) { /** - * Adds the given closure as a test. The first argument - * is the test description; the second argument is - * a closure that contains the test expectations. - * * @param-closure-this TestCall $closure * * @return ($description is string ? TestCall : HigherOrderTapProxy|TestCall) @@ -147,10 +123,6 @@ if (! function_exists('test')) { if (! function_exists('it')) { /** - * Adds the given closure as a test. The first argument - * is the test description; the second argument is - * a closure that contains the test expectations. - * * @param-closure-this TestCall $closure */ function it(string $description, ?Closure $closure = null): TestCall @@ -162,9 +134,6 @@ if (! function_exists('it')) { } if (! function_exists('todo')) { - /** - * Creates a new test that is marked as "todo". - */ function todo(string $description): TestCall { return test($description)->todo(); @@ -173,8 +142,6 @@ if (! function_exists('todo')) { if (! function_exists('afterEach')) { /** - * Runs the given closure after each test in the current file. - * * @param-closure-this TestCall $closure */ function afterEach(?Closure $closure = null): AfterEachCall @@ -186,9 +153,6 @@ if (! function_exists('afterEach')) { } if (! function_exists('afterAll')) { - /** - * Runs the given closure after all tests in the current file. - */ function afterAll(Closure $closure): void { if (DescribeCall::describing() !== []) { @@ -203,8 +167,6 @@ if (! function_exists('afterAll')) { if (! function_exists('covers')) { /** - * Specifies which classes, or functions, a test case covers. - * * @param array|string $classesOrFunctions */ function covers(array|string ...$classesOrFunctions): void @@ -232,8 +194,6 @@ if (! function_exists('covers')) { if (! function_exists('mutates')) { /** - * Specifies which classes, enums, or traits a test case mutates. - * * @param array|string $targets */ function mutates(array|string ...$targets): void @@ -266,9 +226,6 @@ if (! function_exists('mutates')) { } if (! function_exists('fixture')) { - /** - * Returns the absolute path to a fixture file. - */ function fixture(string $file): string { $file = implode(DIRECTORY_SEPARATOR, [ @@ -292,8 +249,6 @@ if (! function_exists('fixture')) { if (! function_exists('visit')) { /** - * Browse to the given URL. - * * @template TUrl of array|string * * @param TUrl $url diff --git a/src/Kernel.php b/src/Kernel.php index 68de228b..3abc9813 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -29,14 +29,9 @@ use Whoops\Exception\Inspector; */ final class Kernel { - /** - * Either the kernel is terminated or not. - */ private bool $terminated = false; /** - * The Kernel bootstrappers. - * * @var array */ private const array BOOTSTRAPPERS = [ @@ -51,10 +46,6 @@ final class Kernel ]; /** - * The Kernel restarters — resolved and invoked from `bin/pest` - * before any other Pest class is touched, so the list is exposed - * on the Kernel rather than driven from `bin/pest` directly. - * * @var array> */ public const array RESTARTERS = [ @@ -62,14 +53,8 @@ final class Kernel Restarters\PcovRestarter::class, ]; - /** - * Creates a new Kernel instance. - */ public function __construct(private readonly Application $application, private readonly OutputInterface $output) {} - /** - * Boots the Kernel. - */ public static function boot(TestSuite $testSuite, InputInterface $input, OutputInterface $output): self { $container = Container::getInstance(); @@ -102,8 +87,6 @@ final class Kernel } /** - * Runs the application, and returns the exit code. - * * @param array $originalArguments * @param array $arguments */ @@ -135,9 +118,6 @@ final class Kernel return $result; } - /** - * Terminate the Kernel. - */ public function terminate(): void { if ($this->terminated) { @@ -155,9 +135,6 @@ final class Kernel CallsTerminable::execute(); } - /** - * Shutdowns unexpectedly the Kernel. - */ public function shutdown(): void { $this->terminate(); diff --git a/src/KernelDump.php b/src/KernelDump.php index 383da0e6..7907b781 100644 --- a/src/KernelDump.php +++ b/src/KernelDump.php @@ -10,23 +10,14 @@ use Symfony\Component\Console\Output\OutputInterface; final class KernelDump { - /** - * The output buffer, if any. - */ private string $buffer = ''; - /** - * Creates a new Kernel Dump instance. - */ public function __construct( private readonly OutputInterface $output, ) { - // ... + // } - /** - * Enable the output buffering. - */ public function enable(): void { if (class_exists(Execution::class) && Execution::running()) { @@ -40,9 +31,6 @@ final class KernelDump }); } - /** - * Disable the output buffering. - */ public function disable(): void { @ob_clean(); @@ -52,17 +40,11 @@ final class KernelDump } } - /** - * Terminate the output buffering. - */ public function terminate(): void { $this->disable(); } - /** - * Flushes the buffer. - */ private function flush(): void { View::renderUsing($this->output); @@ -103,17 +85,11 @@ final class KernelDump $this->buffer = ''; } - /** - * Checks if the given output contains an opening headline. - */ private function isOpeningHeadline(string $output): bool { return str_contains($output, 'by Sebastian Bergmann and contributors.'); } - /** - * Checks if the given output contains an opening headline. - */ private function isInternalError(string $output): bool { return str_contains($output, 'An error occurred inside PHPUnit.'); diff --git a/src/Logging/Converter.php b/src/Logging/Converter.php index 88cdeb24..2e8a017e 100644 --- a/src/Logging/Converter.php +++ b/src/Logging/Converter.php @@ -25,28 +25,16 @@ use PHPUnit\TestRunner\TestResult\TestResult as PhpUnitTestResult; */ final readonly class Converter { - /** - * The prefix for the test suite name. - */ private const string PREFIX = 'P\\'; - /** - * The state generator. - */ private StateGenerator $stateGenerator; - /** - * Creates a new instance of the Converter. - */ public function __construct( private string $rootPath, ) { $this->stateGenerator = new StateGenerator; } - /** - * Gets the test case method name. - */ public function getTestCaseMethodName(Test $test): string { if (! $test instanceof TestMethod) { @@ -56,9 +44,6 @@ final readonly class Converter return $test->testDox()->prettifiedMethodName(); } - /** - * Gets the test case location. - */ public function getTestCaseLocation(Test $test): string { if (! $test instanceof TestMethod) { @@ -68,15 +53,11 @@ final readonly class Converter $path = $test->testDox()->prettifiedClassName(); $relativePath = $this->toRelativePath($path); - // TODO: Get the description without the dataset. $description = $test->testDox()->prettifiedMethodName(); return "$relativePath::$description"; } - /** - * Gets the exception message. - */ public function getExceptionMessage(Throwable $throwable): string { if (is_a($throwable->className(), FrameworkException::class, true)) { @@ -93,9 +74,6 @@ final readonly class Converter return $buffer; } - /** - * Gets the exception details. - */ public function getExceptionDetails(Throwable $throwable): string { $buffer = $this->getStackTrace($throwable); @@ -113,26 +91,19 @@ final readonly class Converter return $buffer; } - /** - * Gets the stack trace. - */ public function getStackTrace(Throwable $throwable): string { $stackTrace = $throwable->stackTrace(); - // Split stacktrace per frame. $frames = explode("\n", $stackTrace); - // Remove empty lines $frames = array_filter($frames); - // clean the paths of each frame. $frames = array_map( $this->toRelativePath(...), $frames ); - // Format stacktrace as `at ` $frames = array_map( fn (string $frame): string => "at $frame", $frames @@ -141,9 +112,6 @@ final readonly class Converter return implode("\n", $frames); } - /** - * Gets the test suite name. - */ public function getTestSuiteName(TestSuite $testSuite): string { if ($testSuite instanceof TestSuiteForTestMethodWithDataProvider) { @@ -162,17 +130,11 @@ final readonly class Converter return Str::after($name, self::PREFIX); } - /** - * Gets the trimmed test class name. - */ public function getTrimmedTestClassName(TestMethod $test): string { return Str::after($test->className(), self::PREFIX); } - /** - * Gets the test suite location. - */ public function getTestSuiteLocation(TestSuite $testSuite): ?string { $firstTest = $this->getFirstTest($testSuite); @@ -191,22 +153,15 @@ final readonly class Converter return $classRelativePath; } - /** - * Gets the prettified test method name without dataset-related suffix. - */ private function getTestMethodNameWithoutDatasetSuffix(TestMethod $testMethod): string { return Str::beforeLast($testMethod->testDox()->prettifiedMethodName(), ' with data set '); } - /** - * Gets the first test from the test suite. - */ private function getFirstTest(TestSuite $testSuite): ?TestMethod { $tests = $testSuite->tests()->asArray(); - // TODO: figure out how to get the file path without a test being there. if ($tests === []) { return null; } @@ -219,26 +174,16 @@ final readonly class Converter return $firstTest; } - /** - * Gets the test suite size. - */ public function getTestSuiteSize(TestSuite $testSuite): int { return $testSuite->count(); } - /** - * Transforms the given path in relative path. - */ private function toRelativePath(string $path): string { - // Remove cwd from the path. return str_replace("$this->rootPath".DIRECTORY_SEPARATOR, '', $path); } - /** - * Get the test result. - */ public function getStateFromResult(PhpUnitTestResult $result): State { $events = [ @@ -253,11 +198,9 @@ final readonly class Converter foreach ($events as $event) { if ($event instanceof AfterLastTestMethodErrored) { - // PHPUnit's collector does not count these towards `numberOfTestsRun`... continue; } if ($event instanceof AfterLastTestMethodFailed) { - // PHPUnit's collector does not count these towards `numberOfTestsRun`... continue; } if ($event instanceof BeforeFirstTestMethodErrored || $event instanceof BeforeFirstTestMethodFailed) { diff --git a/src/Logging/TeamCity/ServiceMessage.php b/src/Logging/TeamCity/ServiceMessage.php index afa18f7d..068466af 100644 --- a/src/Logging/TeamCity/ServiceMessage.php +++ b/src/Logging/TeamCity/ServiceMessage.php @@ -9,9 +9,6 @@ namespace Pest\Logging\TeamCity; */ final class ServiceMessage { - /** - * The flow ID. - */ private static ?int $flowId = null; /** diff --git a/src/Logging/TeamCity/Subscriber/Subscriber.php b/src/Logging/TeamCity/Subscriber/Subscriber.php index d5eaa1f8..d5f8dbf8 100644 --- a/src/Logging/TeamCity/Subscriber/Subscriber.php +++ b/src/Logging/TeamCity/Subscriber/Subscriber.php @@ -11,14 +11,8 @@ use Pest\Logging\TeamCity\TeamCityLogger; */ abstract class Subscriber // @pest-arch-ignore-line { - /** - * Creates a new Subscriber instance. - */ public function __construct(private readonly TeamCityLogger $logger) {} - /** - * Creates a new TeamCityLogger instance. - */ final protected function logger(): TeamCityLogger // @pest-arch-ignore-line { return $this->logger; diff --git a/src/Logging/TeamCity/Subscriber/TestSkippedSubscriber.php b/src/Logging/TeamCity/Subscriber/TestSkippedSubscriber.php index 1e70668f..20fad0d9 100644 --- a/src/Logging/TeamCity/Subscriber/TestSkippedSubscriber.php +++ b/src/Logging/TeamCity/Subscriber/TestSkippedSubscriber.php @@ -15,7 +15,7 @@ final class TestSkippedSubscriber extends Subscriber implements SkippedSubscribe public function notify(Skipped $event): void { if ($event->message() === '__TODO__') { - return; // "todo" tests are reported in the summary, not as ignored tests... + return; } $this->logger()->testSkipped($event); diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index e02ce8df..336322ce 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -43,14 +43,8 @@ use Symfony\Component\Console\Output\OutputInterface; */ final class TeamCityLogger { - /** - * The current time. - */ private ?HRTime $time = null; - /** - * Indicates if the summary test count has been printed. - */ private bool $isSummaryTestCountPrinted = false; /** @@ -129,10 +123,6 @@ final class TeamCityLogger }); } - /** - * This will trigger in the following scenarios - * - When an exception is thrown - */ public function testErrored(Errored $event): void { $this->whenFirstEventForTest($event->test(), function () use ($event): void { @@ -150,10 +140,6 @@ final class TeamCityLogger }); } - /** - * This will trigger in the following scenarios - * - When an assertion fails - */ public function testFailed(Failed $event): void { $this->whenFirstEventForTest($event->test(), function () use ($event): void { @@ -182,10 +168,6 @@ final class TeamCityLogger }); } - /** - * This will trigger in the following scenarios - * - When no assertions in a test - */ public function testConsideredRisky(ConsideredRisky $event): void { $this->whenFirstEventForTest($event->test(), function () use ($event): void { diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index fcd49604..b364431e 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -38,27 +38,18 @@ use Traversable; */ final class Expectation { - /** - * The exporter instance, if any. - */ private ?Exporter $exporter = null; /** - * Creates a new expectation. - * * @param TValue $value */ public function __construct( public mixed $value ) { - // .. + // } /** - * Asserts that two variables have the same type and - * value. Used on objects, it asserts that two - * variables reference the same object. - * * @return self */ public function toBe(mixed $expected, string $message = ''): self @@ -69,8 +60,6 @@ final class Expectation } /** - * Asserts that the value is empty. - * * @return self */ public function toBeEmpty(string $message = ''): self @@ -81,8 +70,6 @@ final class Expectation } /** - * Asserts that the value is true. - * * @return self */ public function toBeTrue(string $message = ''): self @@ -93,8 +80,6 @@ final class Expectation } /** - * Asserts that the value is truthy. - * * @return self */ public function toBeTruthy(string $message = ''): self @@ -105,8 +90,6 @@ final class Expectation } /** - * Asserts that the value is false. - * * @return self */ public function toBeFalse(string $message = ''): self @@ -117,8 +100,6 @@ final class Expectation } /** - * Asserts that the value is falsy. - * * @return self */ public function toBeFalsy(string $message = ''): self @@ -129,8 +110,6 @@ final class Expectation } /** - * Asserts that the value is greater than $expected. - * * @return self */ public function toBeGreaterThan(int|float|string|DateTimeInterface $expected, string $message = ''): self @@ -141,8 +120,6 @@ final class Expectation } /** - * Asserts that the value is greater than or equal to $expected. - * * @return self */ public function toBeGreaterThanOrEqual(int|float|string|DateTimeInterface $expected, string $message = ''): self @@ -153,8 +130,6 @@ final class Expectation } /** - * Asserts that the value is less than or equal to $expected. - * * @return self */ public function toBeLessThan(int|float|string|DateTimeInterface $expected, string $message = ''): self @@ -165,8 +140,6 @@ final class Expectation } /** - * Asserts that the value is less than $expected. - * * @return self */ public function toBeLessThanOrEqual(int|float|string|DateTimeInterface $expected, string $message = ''): self @@ -177,8 +150,6 @@ final class Expectation } /** - * Asserts that $needle is an element of the value. - * * @return self */ public function toContain(mixed ...$needles): self @@ -198,8 +169,6 @@ final class Expectation } /** - * Asserts that $needle equal an element of the value. - * * @return self */ public function toContainEqual(mixed ...$needles): self @@ -216,8 +185,6 @@ final class Expectation } /** - * Asserts that the value starts with $expected. - * * @param non-empty-string $expected * @return self */ @@ -233,8 +200,6 @@ final class Expectation } /** - * Asserts that the value ends with $expected. - * * @param non-empty-string $expected * @return self */ @@ -250,8 +215,6 @@ final class Expectation } /** - * Asserts that $number matches value's Length. - * * @return self */ public function toHaveLength(int $number, string $message = ''): self @@ -278,8 +241,6 @@ final class Expectation } /** - * Asserts that $count matches the number of elements of the value. - * * @return self */ public function toHaveCount(int $count, string $message = ''): self @@ -294,8 +255,6 @@ final class Expectation } /** - * Asserts that the size of the value and $expected are the same. - * * @param Countable|iterable $expected * @return self */ @@ -311,8 +270,6 @@ final class Expectation } /** - * Asserts that the value contains the property $name. - * * @return self */ public function toHaveProperty(string $name, mixed $value = new Any, string $message = ''): self @@ -331,8 +288,6 @@ final class Expectation } /** - * Asserts that the value contains the provided properties $names. - * * @param iterable|iterable $names * @return self */ @@ -346,8 +301,6 @@ final class Expectation } /** - * Asserts that two variables have the same value. - * * @return self */ public function toEqual(mixed $expected, string $message = ''): self @@ -358,14 +311,6 @@ final class Expectation } /** - * Asserts that two variables have the same value. - * The contents of $expected and the $this->value are - * canonicalized before they are compared. For instance, when the two - * variables $expected and $this->value are arrays, then these arrays - * are sorted before they are compared. When $expected and $this->value - * are objects, each object is converted to an array containing all - * private, protected and public attributes. - * * @return self */ public function toEqualCanonicalizing(mixed $expected, string $message = ''): self @@ -376,9 +321,6 @@ final class Expectation } /** - * Asserts that the absolute difference between the value and $expected - * is lower than $delta. - * * @return self */ public function toEqualWithDelta(mixed $expected, float $delta, string $message = ''): self @@ -389,8 +331,6 @@ final class Expectation } /** - * Asserts that the value is one of the given values. - * * @param iterable $values * @return self */ @@ -402,8 +342,6 @@ final class Expectation } /** - * Asserts that the value is infinite. - * * @return self */ public function toBeInfinite(string $message = ''): self @@ -414,8 +352,6 @@ final class Expectation } /** - * Asserts that the value is an instance of $class. - * * @param class-string $class * @return self */ @@ -427,8 +363,6 @@ final class Expectation } /** - * Asserts that the value is an array. - * * @return self */ public function toBeArray(string $message = ''): self @@ -439,8 +373,6 @@ final class Expectation } /** - * Asserts that the value is a list. - * * @return self */ public function toBeList(string $message = ''): self @@ -451,8 +383,6 @@ final class Expectation } /** - * Asserts that the value is of type bool. - * * @return self */ public function toBeBool(string $message = ''): self @@ -463,8 +393,6 @@ final class Expectation } /** - * Asserts that the value is of type callable. - * * @return self */ public function toBeCallable(string $message = ''): self @@ -475,8 +403,6 @@ final class Expectation } /** - * Asserts that the value is of type float. - * * @return self */ public function toBeFloat(string $message = ''): self @@ -487,8 +413,6 @@ final class Expectation } /** - * Asserts that the value is of type int. - * * @return self */ public function toBeInt(string $message = ''): self @@ -499,8 +423,6 @@ final class Expectation } /** - * Asserts that the value is of type iterable. - * * @return self */ public function toBeIterable(string $message = ''): self @@ -511,8 +433,6 @@ final class Expectation } /** - * Asserts that the value is of type numeric. - * * @return self */ public function toBeNumeric(string $message = ''): self @@ -523,8 +443,6 @@ final class Expectation } /** - * Asserts that the value contains only digits. - * * @return self */ public function toBeDigits(string $message = ''): self @@ -535,8 +453,6 @@ final class Expectation } /** - * Asserts that the value is of type object. - * * @return self */ public function toBeObject(string $message = ''): self @@ -547,8 +463,6 @@ final class Expectation } /** - * Asserts that the value is of type resource. - * * @return self */ public function toBeResource(string $message = ''): self @@ -559,8 +473,6 @@ final class Expectation } /** - * Asserts that the value is of type scalar. - * * @return self */ public function toBeScalar(string $message = ''): self @@ -571,8 +483,6 @@ final class Expectation } /** - * Asserts that the value is of type string. - * * @return self */ public function toBeString(string $message = ''): self @@ -583,8 +493,6 @@ final class Expectation } /** - * Asserts that the value is a JSON string. - * * @return self */ public function toBeJson(string $message = ''): self @@ -597,8 +505,6 @@ final class Expectation } /** - * Asserts that the value is NAN. - * * @return self */ public function toBeNan(string $message = ''): self @@ -609,8 +515,6 @@ final class Expectation } /** - * Asserts that the value is null. - * * @return self */ public function toBeNull(string $message = ''): self @@ -621,8 +525,6 @@ final class Expectation } /** - * Asserts that the value array has the provided $key. - * * @return self */ public function toHaveKey(string|int $key, mixed $value = new Any, string $message = ''): self @@ -653,8 +555,6 @@ final class Expectation } /** - * Asserts that the value array has the provided $keys. - * * @param array> $keys * @return self */ @@ -672,8 +572,6 @@ final class Expectation } /** - * Asserts that the value is a directory. - * * @return self */ public function toBeDirectory(string $message = ''): self @@ -688,8 +586,6 @@ final class Expectation } /** - * Asserts that the value is a directory and is readable. - * * @return self */ public function toBeReadableDirectory(string $message = ''): self @@ -704,8 +600,6 @@ final class Expectation } /** - * Asserts that the value is a directory and is writable. - * * @return self */ public function toBeWritableDirectory(string $message = ''): self @@ -720,8 +614,6 @@ final class Expectation } /** - * Asserts that the value is a file. - * * @return self */ public function toBeFile(string $message = ''): self @@ -736,8 +628,6 @@ final class Expectation } /** - * Asserts that the value is a file and is readable. - * * @return self */ public function toBeReadableFile(string $message = ''): self @@ -752,8 +642,6 @@ final class Expectation } /** - * Asserts that the value is a file and is writable. - * * @return self */ public function toBeWritableFile(string $message = ''): self @@ -767,8 +655,6 @@ final class Expectation } /** - * Asserts that the value array matches the given array subset. - * * @param iterable $array * @return self */ @@ -796,9 +682,6 @@ final class Expectation } /** - * Asserts that the value object matches a subset - * of the properties of an given object. - * * @param iterable $object * @return self */ @@ -827,8 +710,6 @@ final class Expectation } /** - * Asserts that the value "stringable" matches the given snapshot.. - * * @return self */ public function toMatchSnapshot(string $message = ''): self @@ -883,8 +764,6 @@ final class Expectation } /** - * Asserts that the value matches a regular expression. - * * @return self */ public function toMatch(string $expression, string $message = ''): self @@ -898,8 +777,6 @@ final class Expectation } /** - * Asserts that the value matches a constraint. - * * @return self */ public function toMatchConstraint(Constraint $constraint, string $message = ''): self @@ -925,8 +802,6 @@ final class Expectation } /** - * Asserts that executing value throws an exception. - * * @param (Closure(Throwable): mixed)|string $exception * @return self */ @@ -994,9 +869,6 @@ final class Expectation throw new ExpectationFailedException("Exception \"$exception\" not thrown."); } - /** - * Exports the given value. - */ private function export(mixed $value): string { if (! $this->exporter instanceof Exporter) { @@ -1007,8 +879,6 @@ final class Expectation } /** - * Asserts that the value is uppercase. - * * @return self */ public function toBeUppercase(string $message = ''): self @@ -1019,8 +889,6 @@ final class Expectation } /** - * Asserts that the value is lowercase. - * * @return self */ public function toBeLowercase(string $message = ''): self @@ -1031,8 +899,6 @@ final class Expectation } /** - * Asserts that the value is alphanumeric. - * * @return self */ public function toBeAlphaNumeric(string $message = ''): self @@ -1043,8 +909,6 @@ final class Expectation } /** - * Asserts that the value is alpha. - * * @return self */ public function toBeAlpha(string $message = ''): self @@ -1055,8 +919,6 @@ final class Expectation } /** - * Asserts that the value is snake_case. - * * @return self */ public function toBeSnakeCase(string $message = ''): self @@ -1073,8 +935,6 @@ final class Expectation } /** - * Asserts that the value is kebab-case. - * * @return self */ public function toBeKebabCase(string $message = ''): self @@ -1091,8 +951,6 @@ final class Expectation } /** - * Asserts that the value is camelCase. - * * @return self */ public function toBeCamelCase(string $message = ''): self @@ -1109,8 +967,6 @@ final class Expectation } /** - * Asserts that the value is StudlyCase. - * * @return self */ public function toBeStudlyCase(string $message = ''): self @@ -1127,8 +983,6 @@ final class Expectation } /** - * Asserts that the value is UUID. - * * @return self */ public function toBeUuid(string $message = ''): self @@ -1143,8 +997,6 @@ final class Expectation } /** - * Asserts that the value is a ULID. - * * @return self */ public function toBeUlid(string $message = ''): self @@ -1159,8 +1011,6 @@ final class Expectation } /** - * Asserts that the value is between 2 specified values - * * @return self */ public function toBeBetween(int|float|DateTimeInterface $lowestValue, int|float|DateTimeInterface $highestValue, string $message = ''): self @@ -1172,8 +1022,6 @@ final class Expectation } /** - * Asserts that the value is an email address. - * * @return self */ public function toBeEmail(string $message = ''): self @@ -1188,8 +1036,6 @@ final class Expectation } /** - * Asserts that the value is a url - * * @return self */ public function toBeUrl(string $message = ''): self @@ -1204,8 +1050,6 @@ final class Expectation } /** - * Asserts that the value can be converted to a slug - * * @return self */ public function toBeSlug(string $message = ''): self @@ -1221,8 +1065,6 @@ final class Expectation } /** - * Asserts that the value is an IP address. - * * @return self */ public function toBeIpAddress(string $message = ''): self @@ -1237,8 +1079,6 @@ final class Expectation } /** - * Asserts that the value is a MAC address. - * * @return self */ public function toBeMacAddress(string $message = ''): self @@ -1253,8 +1093,6 @@ final class Expectation } /** - * Asserts that the value is a hostname. - * * @return self */ public function toBeHostname(string $message = ''): self @@ -1269,8 +1107,6 @@ final class Expectation } /** - * Asserts that the value is a domain name. - * * @return self */ public function toBeDomain(string $message = ''): self @@ -1288,8 +1124,6 @@ final class Expectation } /** - * Asserts that the value is a base64-encoded string. - * * @return self */ public function toBeBase64(string $message = ''): self @@ -1305,8 +1139,6 @@ final class Expectation } /** - * Asserts that the value is a hexadecimal string. - * * @return self */ public function toBeHexadecimal(string $message = ''): self diff --git a/src/PHPStan/HigherOrderExpectationTypeExtension.php b/src/PHPStan/HigherOrderExpectationTypeExtension.php index 5f8268c8..35f643b7 100644 --- a/src/PHPStan/HigherOrderExpectationTypeExtension.php +++ b/src/PHPStan/HigherOrderExpectationTypeExtension.php @@ -15,12 +15,6 @@ use PHPStan\Type\ObjectType; use PHPStan\Type\Type; /** - * Prevents native declared properties of HigherOrderExpectation (like $original, - * $expectation, $opposite, $shouldReset) from being incorrectly resolved as - * higher-order value property accesses by downstream ExpressionTypeResolverExtensions. - * - * This extension must be registered BEFORE the pest-plugin-phpstan HigherOrderExpectationTypeExtension. - * * @internal */ final readonly class HigherOrderExpectationTypeExtension implements ExpressionTypeResolverExtension diff --git a/src/Panic.php b/src/Panic.php index a204472c..20334c10 100644 --- a/src/Panic.php +++ b/src/Panic.php @@ -14,18 +14,12 @@ use Whoops\Exception\Inspector; final readonly class Panic { - /** - * Creates a new Panic instance. - */ private function __construct( private Throwable $throwable ) { - // ... + // } - /** - * Creates a new Panic instance, and exits the application. - */ public static function with(Throwable $throwable): never { if ($throwable instanceof TestDescriptionMissing && ! is_null($previous = $throwable->getPrevious())) { @@ -39,9 +33,6 @@ final readonly class Panic exit(1); } - /** - * Handles the panic. - */ private function handle(): void { try { diff --git a/src/PendingCalls/AfterEachCall.php b/src/PendingCalls/AfterEachCall.php index f5fc5122..9f7f0b55 100644 --- a/src/PendingCalls/AfterEachCall.php +++ b/src/PendingCalls/AfterEachCall.php @@ -20,19 +20,10 @@ final class AfterEachCall { use Describable; - /** - * The "afterEach" closure. - */ private readonly Closure $closure; - /** - * The calls that should be proxied. - */ private readonly HigherOrderMessageCollection $proxies; - /** - * Creates a new Pending Call. - */ public function __construct( private readonly TestSuite $testSuite, private readonly string $filename, @@ -45,9 +36,6 @@ final class AfterEachCall $this->describing = DescribeCall::describing(); } - /** - * Creates the Call. - */ public function __destruct() { $describing = $this->describing; @@ -69,8 +57,6 @@ final class AfterEachCall } /** - * Saves the calls to be used on the target. - * * @param array $arguments */ public function __call(string $name, array $arguments): self diff --git a/src/PendingCalls/BeforeEachCall.php b/src/PendingCalls/BeforeEachCall.php index fa0476c3..852a1aad 100644 --- a/src/PendingCalls/BeforeEachCall.php +++ b/src/PendingCalls/BeforeEachCall.php @@ -23,24 +23,12 @@ final class BeforeEachCall { use Describable; - /** - * Holds the before each closure. - */ private readonly Closure $closure; - /** - * The test call proxies. - */ private readonly HigherOrderMessageCollection $testCallProxies; - /** - * The test case proxies. - */ private readonly HigherOrderMessageCollection $testCaseProxies; - /** - * Creates a new Pending Call. - */ public function __construct( public readonly TestSuite $testSuite, private readonly string $filename, @@ -54,9 +42,6 @@ final class BeforeEachCall $this->describing = DescribeCall::describing(); } - /** - * Creates the Call. - */ public function __destruct() { $describing = $this->describing; @@ -92,9 +77,6 @@ final class BeforeEachCall ); } - /** - * Runs the given closure after the test. - */ public function after(Closure $closure): self { if ($this->describing === []) { @@ -105,8 +87,6 @@ final class BeforeEachCall } /** - * Saves the calls to be used on the target. - * * @param array $arguments */ public function __call(string $name, array $arguments): self diff --git a/src/PendingCalls/Concerns/Describable.php b/src/PendingCalls/Concerns/Describable.php index cac2fb0b..8aec2ec4 100644 --- a/src/PendingCalls/Concerns/Describable.php +++ b/src/PendingCalls/Concerns/Describable.php @@ -12,15 +12,11 @@ use Pest\Support\Description; trait Describable { /** - * Note: this is property is not used; however, it gets added automatically by rector php. - * * @var array */ public array $__describing; /** - * The describing of the test case. - * * @var array */ public array $describing = []; diff --git a/src/PendingCalls/DescribeCall.php b/src/PendingCalls/DescribeCall.php index 0964bc65..c2741ce9 100644 --- a/src/PendingCalls/DescribeCall.php +++ b/src/PendingCalls/DescribeCall.php @@ -14,20 +14,12 @@ use Pest\TestSuite; final class DescribeCall { /** - * The current describe call. - * * @var array */ private static array $describing = []; - /** - * The describe "before each" call. - */ private ?BeforeEachCall $currentBeforeEachCall = null; - /** - * Creates a new Pending Call. - */ public function __construct( public readonly TestSuite $testSuite, public readonly string $filename, @@ -38,8 +30,6 @@ final class DescribeCall } /** - * What is the current describing. - * * @return array */ public static function describing(): array @@ -47,17 +37,11 @@ final class DescribeCall return self::$describing; } - /** - * Creates the Call. - */ public function __destruct() { - // Ensure BeforeEachCall destructs before creating tests - // by moving to local scope and clearing the reference $beforeEach = $this->currentBeforeEachCall; $this->currentBeforeEachCall = null; - unset($beforeEach); // Trigger destructor immediately - + unset($beforeEach); self::$describing[] = $this->description; try { @@ -68,8 +52,6 @@ final class DescribeCall } /** - * Dynamically calls methods on each test call. - * * @param array $arguments */ public function __call(string $name, array $arguments): self diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index ccf9b4f9..a0d4702d 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -38,25 +38,14 @@ final class TestCall // @phpstan-ignore-line use Describable; /** - * The list of test case factory attributes. - * * @var array */ private array $testCaseFactoryAttributes = []; - /** - * The Test Case Factory. - */ public readonly TestCaseMethodFactory $testCaseMethod; - /** - * If test call is descriptionLess. - */ private readonly bool $descriptionLess; - /** - * Creates a new Pending Call. - */ public function __construct( private readonly TestSuite $testSuite, private readonly string $filename, @@ -72,9 +61,6 @@ final class TestCall // @phpstan-ignore-line $this->testSuite->beforeEach->get($this->filename)[0]($this); } - /** - * Runs the given closure after the test. - */ public function after(Closure $closure): self { if ($this->description === null) { @@ -108,17 +94,11 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Asserts that the test fails with the given message. - */ public function fails(?string $message = null): self { return $this->throws(AssertionFailedError::class, $message); } - /** - * Asserts that the test throws the given `$exceptionClass` when called. - */ public function throws(string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self { if (is_int($exception)) { @@ -147,8 +127,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Asserts that the test throws the given `$exceptionClass` when called if the given condition is true. - * * @param (callable(): bool)|bool $condition */ public function throwsIf(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self @@ -165,8 +143,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Asserts that the test throws the given `$exceptionClass` when called if the given condition is false. - * * @param (callable(): bool)|bool $condition */ public function throwsUnless(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self @@ -183,8 +159,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Runs the current test multiple times with each item of the given `iterable`. - * * @param Closure|iterable|string $data */ public function with(Closure|iterable|string ...$data): self @@ -196,9 +170,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the test depends. - */ public function depends(string ...$depends): self { foreach ($depends as $depend) { @@ -208,9 +179,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the test group(s). - */ public function group(string ...$groups): self { foreach ($groups as $group) { @@ -223,9 +191,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Filters the test suite by "only" tests. - */ public function only(): self { Only::enable($this, ...func_get_args()); @@ -233,9 +198,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Skips the current test. - */ public function skip(Closure|bool|string $conditionOrMessage = true, string $message = ''): self { $condition = is_string($conditionOrMessage) @@ -260,9 +222,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Skips the current test on the given PHP version. - */ public function skipOnPhp(string $version): self { if (mb_strlen($version) < 2) { @@ -275,7 +234,6 @@ final class TestCall // @phpstan-ignore-line } elseif (str_starts_with($version, '>') || str_starts_with($version, '<')) { $operator = $version[0]; $version = substr($version, 1); - // ensure starts with number: } elseif (is_numeric($version[0])) { $operator = '=='; } else { @@ -285,33 +243,21 @@ final class TestCall // @phpstan-ignore-line return $this->skip(version_compare(PHP_VERSION, $version, $operator), sprintf('This test is skipped on PHP [%s%s].', $operator, $version)); } - /** - * Skips the current test if the given test is running on Windows. - */ public function skipOnWindows(): self { return $this->skipOnOs('Windows', 'This test is skipped on [Windows].'); } - /** - * Skips the current test if the given test is running on Mac OS. - */ public function skipOnMac(): self { return $this->skipOnOs('Darwin', 'This test is skipped on [Mac].'); } - /** - * Skips the current test if the given test is running on Linux. - */ public function skipOnLinux(): self { return $this->skipOnOs('Linux', 'This test is skipped on [Linux].'); } - /** - * Skips the current test if the given test is running on the given operating systems. - */ private function skipOnOs(string $osFamily, string $message): self { return $osFamily === PHP_OS_FAMILY @@ -319,9 +265,6 @@ final class TestCall // @phpstan-ignore-line : $this; } - /** - * Weather the current test is running on a CI environment. - */ private function runningOnCI(): bool { foreach ([ @@ -353,9 +296,6 @@ final class TestCall // @phpstan-ignore-line return Environment::name() === Environment::CI; } - /** - * Skips the current test when running on a CI environments. - */ public function skipOnCI(): self { if ($this->runningOnCI()) { @@ -374,33 +314,21 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Skips the current test unless the given test is running on Windows. - */ public function onlyOnWindows(): self { return $this->skipOnMac()->skipOnLinux(); } - /** - * Skips the current test unless the given test is running on Mac. - */ public function onlyOnMac(): self { return $this->skipOnWindows()->skipOnLinux(); } - /** - * Skips the current test unless the given test is running on Linux. - */ public function onlyOnLinux(): self { return $this->skipOnWindows()->skipOnMac(); } - /** - * Repeats the current test the given number of times. - */ public function repeat(int $times): self { if ($times < 1) { @@ -412,9 +340,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Marks the test as flaky, retrying it up to the given number of times. - */ public function flaky(int $tries = 3): self { if ($tries < 1) { @@ -426,9 +351,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Marks the test as "todo". - */ public function todo(// @phpstan-ignore-line array|string|null $note = null, array|string|null $assignee = null, @@ -458,9 +380,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the test as "work in progress". - */ public function wip(// @phpstan-ignore-line array|string|null $note = null, array|string|null $assignee = null, @@ -486,9 +405,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the test as "done". - */ public function done(// @phpstan-ignore-line array|string|null $note = null, array|string|null $assignee = null, @@ -515,8 +431,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Associates the test with the given issue(s). - * * @param array|string|int $number */ public function issue(array|string|int $number): self @@ -531,8 +445,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Associates the test with the given ticket(s). (Alias for `issue`) - * * @param array|string|int $number */ public function ticket(array|string|int $number): self @@ -541,8 +453,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Sets the test assignee(s). - * * @param array|string $assignee */ public function assignee(array|string $assignee): self @@ -555,8 +465,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Associates the test with the given pull request(s). - * * @param array|string|int $number */ public function pr(array|string|int $number): self @@ -571,8 +479,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Adds a note to the test. - * * @param array|string $note */ public function note(array|string $note): self @@ -585,8 +491,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Sets the covered classes or methods. - * * @param array|string $classesOrFunctions */ public function covers(array|string ...$classesOrFunctions): self @@ -615,9 +519,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the covered classes. - */ public function coversClass(string ...$classes): self { foreach ($classes as $class) { @@ -638,9 +539,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the covered classes. - */ public function coversTrait(string ...$traits): self { foreach ($traits as $trait) { @@ -661,9 +559,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Sets the covered functions. - */ public function coversFunction(string ...$functions): self { foreach ($functions as $function) { @@ -677,9 +572,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Adds one or more references to the tested method or class. This helps - * to link test cases to the source code for easier navigation. - * * @param array|class-string ...$classes */ public function references(string|array ...$classes): self @@ -690,9 +582,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Adds one or more references to the tested method or class. This helps - * to link test cases to the source code for easier navigation. - * * @param array|class-string ...$classes */ public function see(string|array ...$classes): self @@ -700,11 +589,6 @@ final class TestCall // @phpstan-ignore-line return $this->references(...$classes); } - /** - * Informs the test runner that no expectations happen in this test, - * and its purpose is simply to check whether the given code can - * be executed without throwing exceptions. - */ public function throwsNoExceptions(): self { $this->testCaseMethod->proxies->add(Backtrace::file(), Backtrace::line(), 'expectNotToPerformAssertions', []); @@ -712,17 +596,12 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Saves the property accessors to be used on the target. - */ public function __get(string $name): self { return $this->addChain(Backtrace::file(), Backtrace::line(), $name); } /** - * Saves the calls to be used on the target. - * * @param array $arguments */ public function __call(string $name, array $arguments): self @@ -731,8 +610,6 @@ final class TestCall // @phpstan-ignore-line } /** - * Add a chain to the test case factory. Omitting the arguments will treat it as a property accessor. - * * @param array|null $arguments */ private function addChain(string $file, int $line, string $name, ?array $arguments = null): self @@ -758,9 +635,6 @@ final class TestCall // @phpstan-ignore-line return $this; } - /** - * Creates the Call. - */ public function __destruct() { if ($this->description === null) { diff --git a/src/PendingCalls/UsesCall.php b/src/PendingCalls/UsesCall.php index 7acc1208..82c20193 100644 --- a/src/PendingCalls/UsesCall.php +++ b/src/PendingCalls/UsesCall.php @@ -14,36 +14,21 @@ use Pest\TestSuite; final class UsesCall { /** - * Contains a global before each hook closure to be executed. - * - * Array indices here matter. They are mapped as follows: - * - * - `0` => `beforeAll` - * - `1` => `beforeEach` - * - `2` => `afterEach` - * - `3` => `afterAll` - * * @var array */ private array $hooks = []; /** - * Holds the targets of the uses. - * * @var array */ private array $targets; /** - * Holds the groups of the uses. - * * @var array */ private array $groups = []; /** - * Creates a new Pending Call. - * * @param array $classAndTraits */ public function __construct( @@ -62,8 +47,6 @@ final class UsesCall } /** - * Specifies the class or traits to use. - * * @alias extend */ public function use(string ...$classAndTraits): self @@ -71,9 +54,6 @@ final class UsesCall return $this->extend(...$classAndTraits); } - /** - * Specifies the class or traits to use. - */ public function extend(string ...$classAndTraits): self { $this->classAndTraits = array_merge($this->classAndTraits, array_values($classAndTraits)); @@ -81,9 +61,6 @@ final class UsesCall return $this; } - /** - * The directories or file where the class or traits should be used. - */ public function in(string ...$targets): self { $targets = array_map(function (string $path): string { @@ -116,9 +93,6 @@ final class UsesCall return $this; } - /** - * Sets the test group(s). - */ public function group(string ...$groups): self { $this->groups = array_values($groups); @@ -126,9 +100,6 @@ final class UsesCall return $this; } - /** - * Sets the global beforeAll test hook. - */ public function beforeAll(Closure $hook): self { $this->hooks[0] = $hook; @@ -136,9 +107,6 @@ final class UsesCall return $this; } - /** - * Sets the global beforeEach test hook. - */ public function beforeEach(Closure $hook): self { $this->hooks[1] = $hook; @@ -146,9 +114,6 @@ final class UsesCall return $this; } - /** - * Sets the global afterEach test hook. - */ public function afterEach(Closure $hook): self { $this->hooks[2] = $hook; @@ -156,9 +121,6 @@ final class UsesCall return $this; } - /** - * Sets the global afterAll test hook. - */ public function afterAll(Closure $hook): self { $this->hooks[3] = $hook; @@ -166,9 +128,6 @@ final class UsesCall return $this; } - /** - * Creates the Call. - */ public function __destruct() { TestSuite::getInstance()->tests->use( diff --git a/src/Pest.php b/src/Pest.php index 5d15f61d..f08752c5 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '5.0.4'; + return '5.0.5'; } function testDirectory(string $file = ''): string diff --git a/src/Plugin.php b/src/Plugin.php index 54780337..d68151e3 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -7,8 +7,6 @@ namespace Pest; final class Plugin { /** - * The lazy callables to be executed once the test suite boots. - * * @var array * * @internal @@ -16,8 +14,6 @@ final class Plugin public static array $callables = []; /** - * Lazy loads an `uses` call on the context of plugins. - * * @param class-string ...$traits */ public static function uses(string ...$traits): void diff --git a/src/Plugins/Actions/CallsAddsOutput.php b/src/Plugins/Actions/CallsAddsOutput.php index 695e23cc..c7fb5868 100644 --- a/src/Plugins/Actions/CallsAddsOutput.php +++ b/src/Plugins/Actions/CallsAddsOutput.php @@ -12,11 +12,6 @@ use Pest\Plugin\Loader; */ final class CallsAddsOutput { - /** - * Executes the Plugin action. - * - * Provides an opportunity for any plugins that want to provide additional output after test execution. - */ public static function execute(int $exitCode): int { $plugins = Loader::getPlugins(Plugins\AddsOutput::class); diff --git a/src/Plugins/Actions/CallsBoot.php b/src/Plugins/Actions/CallsBoot.php index f2459b80..51064c4f 100644 --- a/src/Plugins/Actions/CallsBoot.php +++ b/src/Plugins/Actions/CallsBoot.php @@ -12,11 +12,6 @@ use Pest\Plugin\Loader; */ final class CallsBoot { - /** - * Executes the Plugin action. - * - * Provides an opportunity for any plugins to boot. - */ public static function execute(): void { $plugins = Loader::getPlugins(Plugins\Bootable::class); diff --git a/src/Plugins/Actions/CallsHandleArguments.php b/src/Plugins/Actions/CallsHandleArguments.php index 660620f9..0e9df0fc 100644 --- a/src/Plugins/Actions/CallsHandleArguments.php +++ b/src/Plugins/Actions/CallsHandleArguments.php @@ -13,10 +13,6 @@ use Pest\Plugin\Loader; final class CallsHandleArguments { /** - * Executes the Plugin action. - * - * Transform the input arguments by passing it to the relevant plugins. - * * @param array $argv * @return array */ diff --git a/src/Plugins/Actions/CallsHandleOriginalArguments.php b/src/Plugins/Actions/CallsHandleOriginalArguments.php index 5917df7b..4b16703c 100644 --- a/src/Plugins/Actions/CallsHandleOriginalArguments.php +++ b/src/Plugins/Actions/CallsHandleOriginalArguments.php @@ -13,10 +13,6 @@ use Pest\Plugin\Loader; final class CallsHandleOriginalArguments { /** - * Executes the Plugin action. - * - * Transform the input arguments by passing it to the relevant plugins. - * * @param array $argv */ public static function execute(array $argv): void diff --git a/src/Plugins/Actions/CallsTerminable.php b/src/Plugins/Actions/CallsTerminable.php index 619b9c0f..6666d369 100644 --- a/src/Plugins/Actions/CallsTerminable.php +++ b/src/Plugins/Actions/CallsTerminable.php @@ -12,11 +12,6 @@ use Pest\Plugin\Loader; */ final class CallsTerminable { - /** - * Executes the Plugin action. - * - * Provides an opportunity for any plugins to terminate. - */ public static function execute(): void { $plugins = Loader::getPlugins(Plugins\Terminable::class); diff --git a/src/Plugins/Bail.php b/src/Plugins/Bail.php index d82bd2f6..27cc7ff4 100644 --- a/src/Plugins/Bail.php +++ b/src/Plugins/Bail.php @@ -14,9 +14,6 @@ final class Bail implements HandlesArguments { use HandleArguments; - /** - * Handles the arguments, adding the `--stop-on-defect` when the `--bail` argument is present. - */ public function handleArguments(array $arguments): array { if ($this->hasArgument('--bail', $arguments)) { diff --git a/src/Plugins/Cache.php b/src/Plugins/Cache.php index b0ff8a6d..1d4ca21f 100644 --- a/src/Plugins/Cache.php +++ b/src/Plugins/Cache.php @@ -18,9 +18,6 @@ final class Cache implements HandlesArguments { use HandleArguments; - /** - * The temporary folder. - */ private const string TEMPORARY_FOLDER = __DIR__ .DIRECTORY_SEPARATOR .'..' @@ -29,9 +26,6 @@ final class Cache implements HandlesArguments .DIRECTORY_SEPARATOR .'.temp'; - /** - * Handles the arguments, adding the cache directory and the cache result arguments. - */ public function handleArguments(array $arguments): array { if (! $this->hasArgument('--cache-directory', $arguments)) { diff --git a/src/Plugins/Concerns/HandleArguments.php b/src/Plugins/Concerns/HandleArguments.php index e12baec6..8d8e497c 100644 --- a/src/Plugins/Concerns/HandleArguments.php +++ b/src/Plugins/Concerns/HandleArguments.php @@ -10,8 +10,6 @@ namespace Pest\Plugins\Concerns; trait HandleArguments { /** - * Checks if the given argument exists on the arguments. - * * @param array $arguments */ public function hasArgument(string $argument, array $arguments): bool @@ -30,8 +28,6 @@ trait HandleArguments } /** - * Adds the given argument and value to the list of arguments. - * * @param array $arguments * @return array */ @@ -43,8 +39,6 @@ trait HandleArguments } /** - * Pops the given argument from the arguments. - * * @param array $arguments * @return array */ @@ -61,8 +55,6 @@ trait HandleArguments } /** - * Pops the given argument and its value from the arguments, returning the value. - * * @param array $arguments */ public function popArgumentValue(string $argument, array &$arguments): ?string diff --git a/src/Plugins/Configuration.php b/src/Plugins/Configuration.php index 54c9627f..b34a3b0d 100644 --- a/src/Plugins/Configuration.php +++ b/src/Plugins/Configuration.php @@ -18,9 +18,6 @@ final class Configuration implements HandlesArguments, Terminable { use HandleArguments; - /** - * The base PHPUnit file. - */ public const string BASE_PHPUNIT_FILE = __DIR__ .DIRECTORY_SEPARATOR .'..' @@ -29,9 +26,6 @@ final class Configuration implements HandlesArguments, Terminable .DIRECTORY_SEPARATOR .'resources/base-phpunit.xml'; - /** - * Handles the arguments, adding the cache directory and the cache result arguments. - */ public function handleArguments(array $arguments): array { if ($this->hasArgument('--configuration', $arguments) || $this->hasArgument('-c', $arguments) || $this->hasCustomConfigurationFile()) { @@ -43,9 +37,6 @@ final class Configuration implements HandlesArguments, Terminable return $this->pushArgument((string) realpath($this->fromGeneratedConfigurationFile()), $arguments); } - /** - * Get the configuration file from the generated configuration file. - */ private function fromGeneratedConfigurationFile(): string { $path = $this->getTempPhpunitXmlPath(); @@ -63,9 +54,6 @@ final class Configuration implements HandlesArguments, Terminable return $path; } - /** - * Check if the configuration file is custom. - */ private function hasCustomConfigurationFile(): bool { $cliConfiguration = (new CliConfigurationBuilder)->fromParameters([]); @@ -74,17 +62,11 @@ final class Configuration implements HandlesArguments, Terminable return is_string($configurationFile); } - /** - * Get the temporary phpunit.xml path. - */ private function getTempPhpunitXmlPath(): string { return getcwd().'/.pest.xml'; } - /** - * Terminates the plugin. - */ public function terminate(): void { $path = $this->getTempPhpunitXmlPath(); diff --git a/src/Plugins/Coverage.php b/src/Plugins/Coverage.php index 50bbe8e3..3217dc6f 100644 --- a/src/Plugins/Coverage.php +++ b/src/Plugins/Coverage.php @@ -27,37 +27,19 @@ final class Coverage implements AddsOutput, HandlesArguments private const string ONLY_COVERED_OPTION = 'only-covered'; - /** - * Whether it should show the coverage or not. - */ public bool $coverage = false; - /** - * Whether it should show the coverage or not. - */ public bool $compact = false; - /** - * The minimum coverage. - */ public float $coverageMin = 0.0; - /** - * The exactly coverage. - */ public ?float $coverageExactly = null; - /** - * Whether it should show only covered files. - */ public bool $showOnlyCovered = false; - /** - * Creates a new Plugin instance. - */ public function __construct(private readonly OutputInterface $output) { - // .. + // } /** @@ -186,9 +168,6 @@ final class Coverage implements AddsOutput, HandlesArguments return $exitCode; } - /** - * Computes the comparable coverage to a percentage with one decimal. - */ private function computeComparableCoverage(float $coverage): float { return floor($coverage * 10) / 10; diff --git a/src/Plugins/Environment.php b/src/Plugins/Environment.php index 7edbbbd3..6188f1c7 100644 --- a/src/Plugins/Environment.php +++ b/src/Plugins/Environment.php @@ -11,19 +11,10 @@ use Pest\Contracts\Plugins\HandlesArguments; */ final class Environment implements HandlesArguments { - /** - * The continuous integration environment. - */ public const string CI = 'ci'; - /** - * The local environment. - */ public const string LOCAL = 'local'; - /** - * The current environment. - */ private static ?string $name = null; /** @@ -42,9 +33,6 @@ final class Environment implements HandlesArguments return array_values($arguments); } - /** - * Gets the environment name. - */ public static function name(?string $name = null): string { if (is_string($name)) { diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index 1260d243..9615fa59 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -18,13 +18,10 @@ final readonly class Help implements HandlesArguments { use Concerns\HandleArguments; - /** - * Creates a new Plugin instance. - */ public function __construct( private OutputInterface $output ) { - // .. + // } /** @@ -80,9 +77,6 @@ final readonly class Help implements HandlesArguments return $arguments; } - /** - * Colorizes the given string options. - */ private function colorizeOptions(string $argument): string { return (string) preg_replace( diff --git a/src/Plugins/Init.php b/src/Plugins/Init.php index c31dd759..fe0105bb 100644 --- a/src/Plugins/Init.php +++ b/src/Plugins/Init.php @@ -17,14 +17,8 @@ use Symfony\Component\Console\Output\OutputInterface; */ final readonly class Init implements HandlesArguments { - /** - * The option the triggers the init job. - */ private const string INIT_OPTION = '--init'; - /** - * The files that will be created. - */ private const array STUBS = [ 'phpunit.xml.stub' => 'phpunit.xml', 'Pest.php.stub' => 'tests/Pest.php', @@ -33,15 +27,12 @@ final readonly class Init implements HandlesArguments 'Feature/ExampleTest.php.stub' => 'tests/Feature/ExampleTest.php', ]; - /** - * Creates a new Plugin instance. - */ public function __construct( private TestSuite $testSuite, private InputInterface $input, private OutputInterface $output ) { - // .. + // } /** @@ -63,9 +54,6 @@ final readonly class Init implements HandlesArguments exit(0); } - /** - * Initializes the tests directory. - */ public function init(): void { $testsBaseDir = "{$this->testSuite->rootPath}/tests"; @@ -114,9 +102,6 @@ final readonly class Init implements HandlesArguments (new Thanks($this->input, $this->output))(); } - /** - * Checks if laravel is installed through Composer - */ private function isLaravelInstalled(): bool { return InstalledVersions::isInstalled('laravel/framework'); diff --git a/src/Plugins/Memory.php b/src/Plugins/Memory.php index 0755f743..05a6580c 100644 --- a/src/Plugins/Memory.php +++ b/src/Plugins/Memory.php @@ -15,18 +15,12 @@ final class Memory implements AddsOutput, HandlesArguments { use Concerns\HandleArguments; - /** - * If memory should be displayed. - */ private bool $enabled = false; - /** - * Creates a new Plugin instance. - */ public function __construct( private readonly OutputInterface $output ) { - // .. + // } /** diff --git a/src/Plugins/Only.php b/src/Plugins/Only.php index fd1001de..bd228e33 100644 --- a/src/Plugins/Only.php +++ b/src/Plugins/Only.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\Group; */ final class Only implements Terminable { - /** - * The temporary folder. - */ private const string TEMPORARY_FOLDER = __DIR__ .DIRECTORY_SEPARATOR .'..' @@ -26,9 +23,6 @@ final class Only implements Terminable .DIRECTORY_SEPARATOR .'.temp'; - /** - * Creates the lock file. - */ public static function enable(TestCall|TestCaseMethodFactory $testCall, string $group = '__pest_only'): void { if ($testCall instanceof TestCall) { @@ -59,9 +53,6 @@ final class Only implements Terminable } } - /** - * Checks if "only" mode is enabled. - */ public static function isEnabled(): bool { $lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock'; @@ -69,9 +60,6 @@ final class Only implements Terminable return file_exists($lockFile); } - /** - * Returns the group name. - */ public static function group(): string { $lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock'; diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index eb1d754a..cd9ecab5 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -36,9 +36,6 @@ final class Parallel implements HandlesArguments */ private const array UNSUPPORTED_ARGUMENTS = ['--todo', '--todos', '--retry', '--notes', '--issue', '--pr', '--pull-request', '--flaky']; - /** - * Whether the given command line arguments indicate that the test suite should be run in parallel. - */ public static function isEnabled(): bool { $argv = new ArgvInput; @@ -50,9 +47,6 @@ final class Parallel implements HandlesArguments return $argv->hasParameterOption('-p'); } - /** - * If this code is running in a worker process rather than the main process. - */ public static function isWorker(): bool { $argvValue = Arr::get($_SERVER, 'PARATEST'); @@ -62,9 +56,6 @@ final class Parallel implements HandlesArguments return ((int) $argvValue) === 1; } - /** - * Sets a global value that can be accessed by the parent process and all workers. - */ public static function setGlobal(string $key, string|int|bool|Stringable $value): void { $data = ['value' => $value instanceof Stringable ? $value->__toString() : $value]; @@ -72,9 +63,6 @@ final class Parallel implements HandlesArguments $_ENV[self::GLOBAL_PREFIX.$key] = json_encode($data, JSON_THROW_ON_ERROR); } - /** - * Returns the given global value if one has been set. - */ public static function getGlobal(string $key): string|int|bool|null { $placesToCheck = [$_SERVER, $_ENV]; @@ -110,8 +98,6 @@ final class Parallel implements HandlesArguments } /** - * Runs the test suite in parallel. This method will exit the process upon completion. - * * @param array $arguments */ private function runTestSuiteInParallel(array $arguments): int @@ -135,8 +121,6 @@ final class Parallel implements HandlesArguments } /** - * Runs any handlers that have been registered to handle worker arguments, and returns the modified arguments. - * * @param array $arguments * @return array */ @@ -154,9 +138,6 @@ final class Parallel implements HandlesArguments ); } - /** - * Builds an instance of the Paratest command. - */ private function paratestCommand(): Application { /** @var non-empty-string $rootPath */ @@ -170,10 +151,6 @@ final class Parallel implements HandlesArguments return $command; } - /** - * Whether the command line arguments contain any arguments that are - * not supported or are suboptimal when running in parallel. - */ private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool { $arguments = new ArgvInput; @@ -182,8 +159,6 @@ final class Parallel implements HandlesArguments } /** - * Removes any parallel arguments. - * * @param array $arguments * @return array */ diff --git a/src/Plugins/Parallel/Handlers/Laravel.php b/src/Plugins/Parallel/Handlers/Laravel.php index 30063d5f..7fce40e6 100644 --- a/src/Plugins/Parallel/Handlers/Laravel.php +++ b/src/Plugins/Parallel/Handlers/Laravel.php @@ -37,8 +37,6 @@ final class Laravel implements HandlesArguments } /** - * Executes the given closure when running Laravel. - * * @param array $arguments * @param Closure(array): array $closure * @return array @@ -55,9 +53,6 @@ final class Laravel implements HandlesArguments return $arguments; } - /** - * Ensures the runner is resolvable. - */ private function ensureRunnerIsResolvable(): void { ParallelRunner::resolveRunnerUsing( // @phpstan-ignore-line @@ -66,8 +61,6 @@ final class Laravel implements HandlesArguments } /** - * Ensures the environment variables are set. - * * @param array $arguments * @return array */ @@ -89,8 +82,6 @@ final class Laravel implements HandlesArguments } /** - * Ensure the runner is set. - * * @param array $arguments * @return array */ diff --git a/src/Plugins/Parallel/Handlers/Parallel.php b/src/Plugins/Parallel/Handlers/Parallel.php index d99139b2..99f2a140 100644 --- a/src/Plugins/Parallel/Handlers/Parallel.php +++ b/src/Plugins/Parallel/Handlers/Parallel.php @@ -15,9 +15,6 @@ final class Parallel implements HandlesArguments { use HandleArguments; - /** - * The list of arguments to remove. - */ private const array ARGS_TO_REMOVE = [ '--parallel', '-p', @@ -25,9 +22,6 @@ final class Parallel implements HandlesArguments '--cache-result', ]; - /** - * Handles the arguments, removing the ones that are not needed, and adds the "runner" argument. - */ public function handleArguments(array $arguments): array { $args = array_reduce(self::ARGS_TO_REMOVE, fn (array $args, string $arg): array => $this->popArgument($arg, $args), $arguments); diff --git a/src/Plugins/Parallel/Handlers/Pest.php b/src/Plugins/Parallel/Handlers/Pest.php index eb9132b7..6dd64b36 100644 --- a/src/Plugins/Parallel/Handlers/Pest.php +++ b/src/Plugins/Parallel/Handlers/Pest.php @@ -11,9 +11,6 @@ final class Pest implements HandlersWorkerArguments { use HandleArguments; - /** - * Handles the arguments, adding the "PEST_PARALLEL" environment variable to the global $_SERVER. - */ public function handleWorkerArguments(array $arguments): array { $_SERVER['PEST_PARALLEL'] = '1'; diff --git a/src/Plugins/Parallel/Paratest/CleanConsoleOutput.php b/src/Plugins/Parallel/Paratest/CleanConsoleOutput.php index cf5272b1..54af4d21 100644 --- a/src/Plugins/Parallel/Paratest/CleanConsoleOutput.php +++ b/src/Plugins/Parallel/Paratest/CleanConsoleOutput.php @@ -21,9 +21,6 @@ final class CleanConsoleOutput extends ConsoleOutput parent::doWrite($message, $newline); } - /** - * Removes the opening headline, witch is not needed. - */ private function isOpeningHeadline(string $message): bool { return str_contains($message, 'by Sebastian Bergmann and contributors.'); diff --git a/src/Plugins/Parallel/Paratest/ResultPrinter.php b/src/Plugins/Parallel/Paratest/ResultPrinter.php index 48fc5845..72b952c0 100644 --- a/src/Plugins/Parallel/Paratest/ResultPrinter.php +++ b/src/Plugins/Parallel/Paratest/ResultPrinter.php @@ -29,24 +29,12 @@ use function strlen; */ final class ResultPrinter { - /** - * If the test should be marked as todo. - */ public bool $lastWasTodo = false; - /** - * The "native" printer. - */ public readonly Printer $printer; - /** - * The state. - */ public int $passedTests = 0; - /** - * The "compact" printer. - */ private readonly CompactPrinter $compactPrinter; /** @var resource|null */ diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index db76ea00..3bc9b67d 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -58,32 +58,17 @@ use function usleep; */ final class WrapperRunner implements RunnerInterface { - /** - * The merged test result from the parallel run. - */ public static ?TestResult $result = null; - /** - * The time to sleep between cycles. - */ private const int CYCLE_SLEEP = 10000; - /** - * The result printer. - */ private readonly ResultPrinter $printer; - /** - * The timer. - */ private readonly Timer $timer; /** @var list */ private array $pending = []; - /** - * The exit code. - */ private int $exitcode = -1; /** @var array */ @@ -128,9 +113,6 @@ final class WrapperRunner implements RunnerInterface /** @var non-empty-string[] */ private readonly array $parameters; - /** - * The code coverage filter registry. - */ private CodeCoverageFilterRegistry $codeCoverageFilterRegistry; public function __construct( @@ -190,8 +172,6 @@ final class WrapperRunner implements RunnerInterface } /** - * Handles Laravel Herd's debug and coverage modes. - * * @param array $parameters * @return array */ @@ -352,7 +332,6 @@ final class WrapperRunner implements RunnerInterface private function destroyWorker(int $token): void { $this->workers[$token]->stop(); - // We need to wait for ApplicationForWrapperWorker::end to end while ($this->workers[$token]->isRunning()) { usleep(self::CYCLE_SLEEP); } @@ -612,8 +591,6 @@ final class WrapperRunner implements RunnerInterface } /** - * Returns the test files to be executed. - * * @return array */ private function getTestFiles(SuiteLoader $suiteLoader): array diff --git a/src/Plugins/Parallel/Support/CompactPrinter.php b/src/Plugins/Parallel/Support/CompactPrinter.php index 09b4dcbb..ee70d845 100644 --- a/src/Plugins/Parallel/Support/CompactPrinter.php +++ b/src/Plugins/Parallel/Support/CompactPrinter.php @@ -27,9 +27,6 @@ use function Termwind\terminal; */ final class CompactPrinter { - /** - * The number of processed tests. - */ private int $processed = 0; /** @@ -48,21 +45,15 @@ final class CompactPrinter 'F' => ['red', '⨯'], ]; - /** - * Creates a new instance of the Compact Printer. - */ public function __construct( private readonly Terminal $terminal, private readonly OutputInterface $output, private readonly Style $style, private readonly int $compactSymbolsPerLine, ) { - // .. + // } - /** - * Creates a new instance of the Compact Printer. - */ public static function default(bool $decorated = true): self { return new self( @@ -73,17 +64,11 @@ final class CompactPrinter ); } - /** - * Output an empty line in the console. Useful for providing a little breathing room. - */ public function newLine(): void { render('
'); } - /** - * Outputs the given description item from the ProgressPrinter as a gorgeous, colored symbol. - */ public function descriptionItem(string $item): void { [$color, $icon] = self::LOOKUP_TABLE[$item] ?? self::LOOKUP_TABLE['.']; @@ -104,9 +89,6 @@ final class CompactPrinter $this->processed++; } - /** - * Outputs all errors from the given state using Collision's beautiful error output. - */ public function errors(State $state): void { $this->output->writeln(''); @@ -114,9 +96,6 @@ final class CompactPrinter $this->style->writeErrorsSummary($state); } - /** - * Outputs a clean recap of the test run, including the number of tests, assertions, and failures. - */ public function recap(State $state, PHPUnitTestResult $testResult, Duration $duration, Options $options): void { assert($this->output instanceof ConsoleOutput); diff --git a/src/Plugins/Shard.php b/src/Plugins/Shard.php index 00e05fc5..7c7a29cc 100644 --- a/src/Plugins/Shard.php +++ b/src/Plugins/Shard.php @@ -27,16 +27,9 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable private const string SHARD_OPTION = 'shard'; - /** - * The maximum length allowed for the filter argument. - * While ARG_MAX can be 2MB, individual arguments are often limited to 128KB (MAX_ARG_STRLEN). - * Practical limits in CI environments (like Docker or pipeline runners) can be even lower. - */ private const int MAX_FILTER_LENGTH = 32768; /** - * The shard index and total number of shards. - * * @var array{ * index: int, * total: int, @@ -46,43 +39,24 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable */ private static ?array $shard = null; - /** - * Whether to update the shards.json file. - */ private static bool $updateShards = false; - /** - * Whether time-balanced sharding was used. - */ private static bool $timeBalanced = false; - /** - * Whether the shards.json file is outdated. - */ private static bool $shardsOutdated = false; - /** - * Whether the test suite passed. - */ private static bool $passed = false; /** - * Collected timings from workers or subscribers. - * * @var array|null */ private static ?array $collectedTimings = null; /** - * The canonical list of test classes from --list-tests. - * * @var list|null */ private static ?array $knownTests = null; - /** - * Creates a new Plugin instance. - */ public function __construct( private readonly OutputInterface $output, ) { @@ -162,8 +136,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Handles the --update-shards argument. - * * @param array $arguments * @return array */ @@ -192,8 +164,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Returns all tests that the test suite would run. - * * @param list $arguments * @return list */ @@ -223,8 +193,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Builds the subprocess command used to enumerate tests via `--list-tests`. - * * @param list $arguments * @return list */ @@ -236,8 +204,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Parses `--list-tests` output into a unique list of test class FQCNs. - * * @return list */ private function parseListTestsOutput(string $output): array @@ -248,8 +214,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Builds the filter argument for the given tests to run. - * * @param array $testsToRun */ private function buildFilterArgument(array $testsToRun): string @@ -289,8 +253,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Ensures that the filter length is safe for the current environment. - * * @throws InvalidOption */ private function ensureFilterLengthIsSafe(string $filter): void @@ -308,9 +270,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } } - /** - * Adds output after the Test Suite execution. - */ public function addOutput(int $exitCode): int { self::$passed = $exitCode === 0; @@ -357,9 +316,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable return $exitCode; } - /** - * Terminates the plugin. - */ public function terminate(): void { if (! self::$updateShards) { @@ -386,8 +342,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Collects timings from subscribers or worker temp files. - * * @return array */ private function collectTimings(): array @@ -401,9 +355,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable return EnsureShardTimingsAreCollected::timings(); } - /** - * Writes the current worker's timing data to a temp file. - */ private function writeWorkerTimings(): void { $timings = EnsureShardTimingsAreCollected::timings(); @@ -424,8 +375,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Reads and merges timing data from all worker temp files. - * * @return array */ private function readWorkerTimings(string $runId): array @@ -458,9 +407,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable return $merged; } - /** - * Returns the path to shards.json. - */ private function shardsPath(): string { $testSuite = TestSuite::getInstance(); @@ -469,8 +415,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Loads the timings from shards.json. - * * @return array|null */ private function loadShardsFile(): ?array @@ -497,8 +441,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Partitions tests across shards using the LPT (Longest Processing Time) algorithm. - * * @param list $tests * @param array $timings * @return list> @@ -536,8 +478,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Calculates the median of an array of floats. - * * @param list $values */ private function median(array $values): float @@ -555,8 +495,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Writes the timings to shards.json. - * * @param array $timings */ private function writeTimings(array $timings): void @@ -586,8 +524,6 @@ final class Shard implements AddsOutput, HandlesArguments, Terminable } /** - * Returns the shard information. - * * @return array{index: int, total: int} */ public static function getShard(InputInterface $input): array diff --git a/src/Plugins/Snapshot.php b/src/Plugins/Snapshot.php index e0ac0505..98ec275f 100644 --- a/src/Plugins/Snapshot.php +++ b/src/Plugins/Snapshot.php @@ -14,9 +14,6 @@ final class Snapshot implements HandlesArguments { use Concerns\HandleArguments; - /** - * Whether snapshots should be updated on this run. - */ public static bool $updateSnapshots = false; /** @@ -48,8 +45,6 @@ final class Snapshot implements HandlesArguments } /** - * Options that take a value as the next argument (rather than via "=value"). - * * @var list */ private const array FLAGS_WITH_VALUES = [ @@ -89,8 +84,6 @@ final class Snapshot implements HandlesArguments ]; /** - * Determines whether the command targets the entire suite (no filter, no path). - * * @param array $arguments */ private function isFullRun(array $arguments): bool diff --git a/src/Plugins/Tia.php b/src/Plugins/Tia.php index d59213ff..8cd755f9 100644 --- a/src/Plugins/Tia.php +++ b/src/Plugins/Tia.php @@ -105,8 +105,6 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument private const string DEFAULT_BRANCH = 'main'; /** - * PHPUnit/Pest CLI flags whose subsequent argument is a value, not a path. - * * @var list */ private const array VALUE_TAKING_FLAGS = [ @@ -354,7 +352,6 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument /** * Mirrors {@see HandleArguments::hasArgument()} for - * use from static contexts — matches both `--flag` and `--flag=value`. * * @param array $arguments */ @@ -1626,10 +1623,6 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument } /** - * Union of two per-test edge maps — piggybacked line-coverage edges plus - * the recorder's link-tracked edges (rendered Blade views, ...), which - * never appear in line coverage. - * * @param array> $coverage * @param array> $linked * @return array> @@ -2127,13 +2120,6 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument return implode(', ', array_keys($seen)); } - /** - * The path from the git repository root down to $projectRoot (e.g. - * `laravel-app`) when the project is nested inside a larger repo, or `null` - * when the project root is itself the repo root (or git is unavailable). - * TIA requires the two to coincide: git reports and addresses paths - * relative to the repo root, while the dependency graph is project-relative. - */ private function gitSubdirectoryPrefix(string $projectRoot): ?string { return new Git($projectRoot)->subdirectoryPrefix(); diff --git a/src/Plugins/Tia/ChangedFiles.php b/src/Plugins/Tia/ChangedFiles.php index 02e101fa..4e2d9d45 100644 --- a/src/Plugins/Tia/ChangedFiles.php +++ b/src/Plugins/Tia/ChangedFiles.php @@ -178,7 +178,6 @@ final readonly class ChangedFiles implode("\x00", array_keys($candidates)), ); - // `check-ignore` exits 1 when nothing matched — that is not a failure. if ($result['exitCode'] !== 0 && $result['exitCode'] !== 1) { throw new MissingDependency('Tia mode', 'git'); } @@ -291,10 +290,6 @@ final readonly class ChangedFiles return $this->git->hasCommits(); } - /** - * Working-tree scans get a longer leash than metadata queries — on a large - * repository with a cold cache, `status` and `diff` are not instant. - */ private function scan(): Git { return $this->git->withTimeout(60.0); diff --git a/src/Plugins/Tia/Contracts/Ci.php b/src/Plugins/Tia/Contracts/Ci.php index 53fc2a6f..e5e72027 100644 --- a/src/Plugins/Tia/Contracts/Ci.php +++ b/src/Plugins/Tia/Contracts/Ci.php @@ -9,9 +9,5 @@ namespace Pest\Plugins\Tia\Contracts; */ interface Ci { - /** - * The default branch advertised by this CI, or `null` when the run - * does not happen on it — or when it exposes no such information. - */ public function defaultBranch(): ?string; } diff --git a/src/Plugins/Tia/CoverageMerger.php b/src/Plugins/Tia/CoverageMerger.php index 40ea62c0..370c1ecb 100644 --- a/src/Plugins/Tia/CoverageMerger.php +++ b/src/Plugins/Tia/CoverageMerger.php @@ -164,15 +164,10 @@ final class CoverageMerger return null; } - // Legacy `--coverage-php` format: a serialized `CodeCoverage` object. if ($value instanceof CodeCoverage) { return $value; } - // Since phpunit/php-code-coverage 14, `--coverage-php` writes the report - // as a serialized array (`['codeCoverage' => ..., 'testResults' => ..., - // 'basePath' => ...]`) rather than a `CodeCoverage` object, so it has to - // be rebuilt into one before it can be merged. return self::coverageFromSerializedData($reportPath); } diff --git a/src/Plugins/Tia/Fingerprint.php b/src/Plugins/Tia/Fingerprint.php index 0f4823a2..e8ef26cb 100644 --- a/src/Plugins/Tia/Fingerprint.php +++ b/src/Plugins/Tia/Fingerprint.php @@ -35,19 +35,13 @@ final readonly class Fingerprint 'composer_lock' => self::composerLockHash($projectRoot), 'phpunit_xml' => self::trackedHash($projectRoot, 'phpunit.xml'), 'phpunit_xml_dist' => self::trackedHash($projectRoot, 'phpunit.xml.dist'), - // 'pest_factory' => self::contentHashOrNull(__DIR__.'/../../Factories/TestCaseFactory.php'), - // 'pest_method_factory' => self::contentHashOrNull(__DIR__.'/../../Factories/TestCaseMethodFactory.php'), 'vite_config' => self::viteConfigHash($projectRoot), - // 'package_json' => self::packageJsonHash($projectRoot), 'package_lock' => self::packageLockHash($projectRoot), 'js_config' => self::jsConfigHash($projectRoot), - // 'composer_json' => self::composerJsonHash($projectRoot), ], 'environmental' => [ 'php_minor' => PHP_MAJOR_VERSION, - // 'extensions' => self::extensionsFingerprint($projectRoot), - // 'env_files' => self::envFilesHash($projectRoot), ], ]; } @@ -267,13 +261,6 @@ final readonly class Fingerprint return self::hashIfExists($projectRoot.'/'.$relativePath); } - /** - * Returns true when the file exists and is not gitignored. - * - * Gitignored lockfiles (e.g. `package-lock.json` excluded from the repo) - * regenerate per-machine with OS-specific optional deps, which would - * otherwise force a fingerprint mismatch on every fetched baseline. - */ private static function isTrackedByGit(string $projectRoot, string $relativePath): bool { if (! is_file($projectRoot.'/'.$relativePath)) { diff --git a/src/Plugins/Tia/Graph.php b/src/Plugins/Tia/Graph.php index e9171bae..4f0d77f0 100644 --- a/src/Plugins/Tia/Graph.php +++ b/src/Plugins/Tia/Graph.php @@ -19,10 +19,6 @@ use PHPUnit\TextUI\Configuration\Registry; final class Graph { /** - * Livewire's generated-file directories, relative to its cache directory, - * mapped to the extension each one writes. Only these three land in the - * graph — scripts and styles are never rendered or executed by PHP. - * * @var array */ private const array LIVEWIRE_GENERATED_PATHS = [ @@ -184,9 +180,6 @@ final class Graph */ private function applyMigrationChanges(array $migrationPaths, array &$affectedSet): array { - // With no recorded table usage at all, table intersection can never - // select anything — route every migration change through the - // watch-pattern fallback instead of silently skipping tests. if ($this->testTables === []) { return $migrationPaths; } @@ -231,7 +224,6 @@ final class Graph * @param list $nonMigrationPaths * @param array $affectedSet * @return array{0: array, 1: array, 2: array} - * globalFrontendRuntimeFiles, preciselyHandledPages, sharedFilesResolved */ private function applyInertiaChanges(array $nonMigrationPaths, array &$affectedSet): array { @@ -440,9 +432,6 @@ final class Graph } /** - * A changed file inside the configured test suites is itself the unit of - * work — always run it (new untracked tests, edited tests, renames). - * * @param list $nonMigrationPaths * @param array $affectedSet */ @@ -488,9 +477,6 @@ final class Graph $bladeAffected = $this->affectedByStaticBladeUsage($rel); - // Only a walk that actually selected tests counts as handled — a - // component whose usage the static walk missed must still reach - // the watch-pattern fallback instead of being silently swallowed. if ($bladeAffected !== []) { foreach ($bladeAffected as $testFile) { $affectedSet[$testFile] = true; @@ -504,11 +490,6 @@ final class Graph } /** - * Livewire compiles single- and multi-file components into generated files - * under the (per-worker) compiled view directory, so the graph only ever - * holds those generated paths — never the component source the developer - * edited. Reproduce Livewire's hash to walk that mapping backwards. - * * @param list $nonMigrationPaths * @param array $affectedSet * @return array @@ -553,11 +534,6 @@ final class Graph } /** - * The component sources whose Livewire hash a changed file could carry: the - * file itself when it is a single-file component, and its directory when it - * sits inside a multi-file component — a class or asset sibling of the view - * is compiled under the directory's hash, not its own. - * * @return list */ private function livewireSourcePaths(string $rel): array @@ -577,12 +553,6 @@ final class Graph return $sourcePaths; } - /** - * Mirrors Livewire\Finder\Finder::hasValidMultiFileComponentSource(): a - * multi-file component is a directory holding both ".php" and - * ".blade.php", where "" is the directory name with the ⚡ - * marker stripped, collapsed to "index" for the index convention. - */ private function isLivewireMultiFileDirectory(string $componentDirectory): bool { $directoryName = basename($componentDirectory); @@ -602,22 +572,12 @@ final class Graph return is_file($source.'.php') && is_file($source.'.blade.php'); } - /** - * Mirrors Livewire\Compiler\CacheManager::getHash(): the first eight hex - * digits of md5() over the source path relative to base_path(), leading - * separator included. Should Livewire ever change that scheme, nothing - * matches and the watch-pattern fallback takes over again. - */ private function livewireHash(string $sourcePath): string { return substr(md5(DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $sourcePath)), 0, 8); } /** - * Index every Livewire-generated file already in the graph by its hash. The - * same component yields one entry per parallel worker, so a hash maps to a - * list of ids rather than a single one. - * * @return array> */ private function livewireGeneratedFileIds(): array @@ -915,11 +875,6 @@ final class Graph return $this->shouldRerunStatus(TestStatus::from($status)); } - /** - * Whether a cached result with this status must be re-executed rather - * than replayed, honouring the configured failOn* / displayDetailsOn* - * policies. - */ public function shouldRerunStatus(TestStatus $testStatus): bool { if ($testStatus->isFailure() || $testStatus->isError()) { @@ -1098,20 +1053,9 @@ final class Graph } /** - * Mark test files that executed under a recorded coverage session as "known", - * seeding an empty edge set for any that produced zero project-source edges. - * - * Without this, a test that covers no application source (e.g. a pure unit - * test asserting on language primitives) never becomes an edge key, so * {@see self::knowsTest()} reports it as unknown and it re-runs on every TIA - * run. Recording it with an empty edge set lets it be replayed/skipped while - * unchanged; it is still re-run whenever its own file changes, via * {@see self::applyTestFileChanges()}. * - * Must only be called from the recording path, where coverage was actually - * collected — otherwise a missing edge set could mean "coverage was off", - * not "genuinely covered nothing". - * * @param array $testFiles Absolute or project-relative test file paths. */ public function markKnownTestFiles(array $testFiles): void @@ -1539,7 +1483,6 @@ final class Graph $names = [$name, str_replace('_', '-', $name)]; - // Anonymous index components: components/card/index.blade.php resolves as . if (str_ends_with($name, '.index') && $name !== '.index') { $base = substr($name, 0, -strlen('.index')); @@ -1696,9 +1639,6 @@ final class Graph } /** - * Prune baseline result entries whose test files were just executed but whose - * test IDs are no longer present (e.g. the test method was removed or renamed). - * * @param array $touchedFiles Absolute or project-relative paths. * @param array $keepTestIds Test IDs that produced a result this run. */ diff --git a/src/Plugins/Tia/JsModuleGraph.php b/src/Plugins/Tia/JsModuleGraph.php index 4d318e4c..633e50ce 100644 --- a/src/Plugins/Tia/JsModuleGraph.php +++ b/src/Plugins/Tia/JsModuleGraph.php @@ -28,9 +28,6 @@ final class JsModuleGraph ]; /** - * Candidate page directories, in priority order. Must stay in sync with - * `PAGE_DIR_CANDIDATES` in bin/pest-tia-vite-deps.mjs. - * * @var list */ private const array PAGE_DIR_CANDIDATES = [ diff --git a/src/Plugins/Tia/Recorder.php b/src/Plugins/Tia/Recorder.php index 98e8b79c..9093f260 100644 --- a/src/Plugins/Tia/Recorder.php +++ b/src/Plugins/Tia/Recorder.php @@ -50,11 +50,6 @@ final class Recorder $this->captureCoverage = true; } - /** - * Enable per-test link tracking (tables, Inertia components, database - * usage, rendered views) without driving pcov/xdebug — for runs where - * coverage edges are piggybacked from an existing PHPUnit coverage session. - */ public function activateLinkTracking(): void { $this->active = true; diff --git a/src/Plugins/Tia/SourceScope.php b/src/Plugins/Tia/SourceScope.php index 325b3e12..b6c2220c 100644 --- a/src/Plugins/Tia/SourceScope.php +++ b/src/Plugins/Tia/SourceScope.php @@ -58,7 +58,7 @@ final class SourceScope $phpunitExcludes[] = self::normalise($dir->path()); } } catch (Throwable) { - // Registry not initialized — fall back to project-root scanning. + // } $rootIncludes = self::topLevelProjectDirs($projectRoot); diff --git a/src/Plugins/Tia/TableExtractor.php b/src/Plugins/Tia/TableExtractor.php index 8fe0ecd6..d8af4a1c 100644 --- a/src/Plugins/Tia/TableExtractor.php +++ b/src/Plugins/Tia/TableExtractor.php @@ -11,9 +11,6 @@ final class TableExtractor { private const array DML_PREFIXES = ['select', 'insert', 'update', 'delete', 'with', 'replace']; - /** - * A single (optionally quoted) identifier segment. - */ private const string IDENTIFIER = '(?:"[^"]+"|`[^`]+`|\[[^\]]+\]|\w+)'; /** @@ -118,11 +115,6 @@ final class TableExtractor return $out; } - /** - * The table segment of a possibly schema-qualified identifier chain, - * e.g. `"public"."users"` or `analytics.events` yield `users` / `events`. - * Empty when any segment is schema metadata (`information_schema.tables`, ...). - */ private static function unqualified(string $qualified): string { $name = ''; diff --git a/src/Plugins/Tia/TestPaths.php b/src/Plugins/Tia/TestPaths.php index eb1fa7c4..101a876e 100644 --- a/src/Plugins/Tia/TestPaths.php +++ b/src/Plugins/Tia/TestPaths.php @@ -9,10 +9,6 @@ use PHPUnit\TextUI\Configuration\Registry; use Throwable; /** - * Resolves the set of project-relative paths that are considered test files, - * driven by phpunit.xml's . Falls back to the runtime TestSuite - * configuration when no config file is present. - * * @internal */ final readonly class TestPaths @@ -63,7 +59,7 @@ final readonly class TestPaths } } } catch (Throwable) { - // Registry not initialized — fall through to defaults. + // } if ($suffixes === []) { diff --git a/src/Plugins/Verbose.php b/src/Plugins/Verbose.php index 9cec77de..3160f11d 100644 --- a/src/Plugins/Verbose.php +++ b/src/Plugins/Verbose.php @@ -13,9 +13,6 @@ final class Verbose implements HandlesArguments { use Concerns\HandleArguments; - /** - * The list of verbosity levels. - */ private const array VERBOSITY_LEVELS = ['v', 'vv', 'vvv', 'q']; /** diff --git a/src/Preset.php b/src/Preset.php index 549b3845..62c085ab 100644 --- a/src/Preset.php +++ b/src/Preset.php @@ -14,8 +14,6 @@ use Pest\ArchPresets\Relaxed; use Pest\ArchPresets\Security; use Pest\ArchPresets\Strict; use Pest\Exceptions\InvalidArgumentException; -use Pest\PendingCalls\TestCall; -use stdClass; /** * @internal @@ -23,70 +21,46 @@ use stdClass; final class Preset { /** - * The application / package base namespaces. - * * @var ?array */ private static ?array $baseNamespaces = null; /** - * The custom presets. - * * @var array */ private static array $customPresets = []; - /** - * Creates a new preset instance. - */ public function __construct() { // } - /** - * Uses the Pest php preset and returns the test call instance. - */ public function php(): Php { return $this->executePreset(new Php($this->baseNamespaces())); } - /** - * Uses the Pest laravel preset and returns the test call instance. - */ public function laravel(): Laravel { return $this->executePreset(new Laravel($this->baseNamespaces())); } - /** - * Uses the Pest strict preset and returns the test call instance. - */ public function strict(): Strict { return $this->executePreset(new Strict($this->baseNamespaces())); } - /** - * Uses the Pest security preset and returns the test call instance. - */ public function security(): AbstractPreset { return $this->executePreset(new Security($this->baseNamespaces())); } - /** - * Uses the Pest relaxed preset and returns the test call instance. - */ public function relaxed(): AbstractPreset { return $this->executePreset(new Relaxed($this->baseNamespaces())); } /** - * Uses the Pest custom preset and returns the test call instance. - * * @internal */ public static function custom(string $name, Closure $execute): void @@ -99,8 +73,6 @@ final class Preset } /** - * Dynamically handle calls to the class. - * * @param array $arguments * * @throws InvalidArgumentException @@ -120,8 +92,6 @@ final class Preset } /** - * Executes the given preset. - * * @template TPreset of AbstractPreset * * @param TPreset $preset @@ -133,16 +103,10 @@ final class Preset $preset->execute(); - // $this->testCall->testCaseMethod->closure = (function () use ($preset): void { - // $preset->flush(); - // })->bindTo(new stdClass); - return $preset; } /** - * Get the base namespaces for the application / package. - * * @return array */ private function baseNamespaces(): array diff --git a/src/Repositories/AfterAllRepository.php b/src/Repositories/AfterAllRepository.php index d2896ed6..4877dfa7 100644 --- a/src/Repositories/AfterAllRepository.php +++ b/src/Repositories/AfterAllRepository.php @@ -19,9 +19,6 @@ final class AfterAllRepository */ private array $state = []; - /** - * Runs the given closure for each after all. - */ public function each(callable $each): void { foreach ($this->state as $filename => $closure) { @@ -29,9 +26,6 @@ final class AfterAllRepository } } - /** - * Sets a after all closure. - */ public function set(Closure $closure): void { $filename = Reflection::getFileNameFromClosure($closure); @@ -43,9 +37,6 @@ final class AfterAllRepository $this->state[$filename] = $closure; } - /** - * Gets a after all closure by the given filename. - */ public function get(string $filename): Closure { return $this->state[$filename] ?? NullClosure::create(); diff --git a/src/Repositories/AfterEachRepository.php b/src/Repositories/AfterEachRepository.php index ef88f375..ed68d8a4 100644 --- a/src/Repositories/AfterEachRepository.php +++ b/src/Repositories/AfterEachRepository.php @@ -20,9 +20,6 @@ final class AfterEachRepository */ private array $state = []; - /** - * Sets a after each closure. - */ public function set(string $filename, AfterEachCall $afterEachCall, Closure $afterEachTestCase): void { if (array_key_exists($filename, $this->state)) { @@ -37,9 +34,6 @@ final class AfterEachRepository $this->state[$filename] = $afterEachTestCase; } - /** - * Gets an after each closure by the given filename. - */ public function get(string $filename): Closure { $afterEach = $this->state[$filename] ?? NullClosure::create(); diff --git a/src/Repositories/BeforeAllRepository.php b/src/Repositories/BeforeAllRepository.php index 51736b41..0b028672 100644 --- a/src/Repositories/BeforeAllRepository.php +++ b/src/Repositories/BeforeAllRepository.php @@ -19,9 +19,6 @@ final class BeforeAllRepository */ private array $state = []; - /** - * Runs one before all closure, and unsets it from the repository. - */ public function pop(string $filename): Closure { $closure = $this->get($filename); @@ -31,9 +28,6 @@ final class BeforeAllRepository return $closure; } - /** - * Sets a before all closure. - */ public function set(Closure $closure): void { $filename = Reflection::getFileNameFromClosure($closure); @@ -45,9 +39,6 @@ final class BeforeAllRepository $this->state[$filename] = $closure; } - /** - * Gets a before all closure by the given filename. - */ public function get(string $filename): Closure { return $this->state[$filename] ?? NullClosure::create(); diff --git a/src/Repositories/BeforeEachRepository.php b/src/Repositories/BeforeEachRepository.php index 5f6072e7..1d09f25b 100644 --- a/src/Repositories/BeforeEachRepository.php +++ b/src/Repositories/BeforeEachRepository.php @@ -19,9 +19,6 @@ final class BeforeEachRepository */ private array $state = []; - /** - * Sets a before each closure. - */ public function set(string $filename, BeforeEachCall $beforeEachCall, Closure $beforeEachTestCall, Closure $beforeEachTestCase): void { if (array_key_exists($filename, $this->state)) { @@ -36,8 +33,6 @@ final class BeforeEachRepository } /** - * Gets a before each closure by the given filename. - * * @return array{0: Closure, 1: Closure} */ public function get(string $filename): array diff --git a/src/Repositories/DatasetsRepository.php b/src/Repositories/DatasetsRepository.php index 0c6b13a8..26e04127 100644 --- a/src/Repositories/DatasetsRepository.php +++ b/src/Repositories/DatasetsRepository.php @@ -22,22 +22,16 @@ final class DatasetsRepository private const string SEPARATOR = '>>'; /** - * Holds the datasets. - * * @var array> */ private static array $datasets = []; /** - * Holds the withs. - * * @var array|string>> */ private static array $withs = []; /** - * Sets the given. - * * @param Closure|iterable $data */ public static function set(string $name, Closure|iterable $data, string $scope): void @@ -52,8 +46,6 @@ final class DatasetsRepository } /** - * Sets the given "with". - * * @param array|string> $with */ public static function with(string $filename, string $description, array $with): void @@ -85,8 +77,6 @@ final class DatasetsRepository } /** - * Resolves the current dataset to an array value. - * * @param array|string> $dataset * @return array|null */ diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index 30b31546..ce3088ae 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -15,26 +15,18 @@ final class SnapshotRepository /** @var array */ private static array $expectationsCounter = []; - /** - * Creates a snapshot repository instance. - */ public function __construct( private readonly string $rootPath, private readonly string $testsPath, private readonly string $snapshotsPath, ) {} - /** - * Checks if the snapshot exists. - */ public function has(): bool { return file_exists($this->getSnapshotFilename()); } /** - * Gets the snapshot. - * * @return array{0: string, 1: string} * * @throws ShouldNotHappen @@ -52,9 +44,6 @@ final class SnapshotRepository return [$snapshot, $contents]; } - /** - * Saves the given snapshot for the given test case. - */ public function save(string $snapshot): string { $snapshotFilename = $this->getSnapshotFilename(); @@ -70,9 +59,6 @@ final class SnapshotRepository return str_replace(dirname($this->testsPath).'/', '', $snapshotFilename); } - /** - * Flushes the snapshots. - */ public function flush(): void { $absoluteSnapshotsPath = $this->testsPath.'/'.$this->snapshotsPath; @@ -101,26 +87,18 @@ final class SnapshotRepository } } - /** - * Gets the snapshot's "filename". - */ private function getSnapshotFilename(): string { $testFile = TestSuite::getInstance()->getFilename(); if (str_starts_with($testFile, $this->testsPath)) { - // if the test file is in the tests directory $startPath = $this->testsPath; } else { - // if the test file is in the app, src, etc. directory $startPath = $this->rootPath; } - // relative path: we use substr() and not str_replace() to remove the start path - // for instance, if the $startPath is /app/ and the $testFile is /app/app/tests/Unit/ExampleTest.php, we should only remove the first /app/ from the path $relativePath = substr($testFile, strlen($startPath)); - // remove extension from filename $relativePath = substr($relativePath, 0, (int) strrpos($relativePath, '.')); $description = TestSuite::getInstance()->getDescription(); diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index cfce2cf1..2d6573f5 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -41,17 +41,12 @@ final class TestRepository */ private array $testCaseMethodFilters = []; - /** - * Counts the number of test cases. - */ public function count(): int { return count($this->testCases); } /** - * Returns the filename of each test that should be executed in the suite. - * * @return array */ public function getFilenames(): array @@ -60,8 +55,6 @@ final class TestRepository } /** - * Uses the given `$testCaseClass` on the given `$paths`. - * * @param array $classOrTraits * @param array $groups * @param array $paths @@ -97,25 +90,17 @@ final class TestRepository } } - /** - * Filters the test cases using the given filter. - */ public function addTestCaseFilter(TestCaseFilter $filter): void { $this->testCaseFilters[] = $filter; } - /** - * Filters the test cases using the given filter. - */ public function addTestCaseMethodFilter(TestCaseMethodFilter $filter): void { $this->testCaseMethodFilters[] = $filter; } /** - * Gets the class and traits configured for the given directory path. - * * @return array */ public function getUsesForPath(string $path): array @@ -123,17 +108,11 @@ final class TestRepository return $this->uses[$path][0] ?? []; } - /** - * Gets the test case factory from the given filename. - */ public function get(string $filename): ?TestCaseFactory { return $this->testCases[$filename] ?? null; } - /** - * Sets a new test case method. - */ public function set(TestCaseMethodFactory $method): void { foreach ($this->testCaseFilters as $filter) { @@ -155,9 +134,6 @@ final class TestRepository $this->testCases[$method->filename]->addMethod($method); } - /** - * Makes a Test Case from the given filename, if exists. - */ public function makeIfNeeded(string $filename): void { if (! array_key_exists($filename, $this->testCases)) { @@ -173,9 +149,6 @@ final class TestRepository $this->make($this->testCases[$filename]); } - /** - * Makes a Test Case using the given factory. - */ private function make(TestCaseFactory $testCase): void { $startsWith = static fn (string $target, string $directory): bool => Str::startsWith($target, $directory.DIRECTORY_SEPARATOR); diff --git a/src/Result.php b/src/Result.php index 97eda17f..3fa57c74 100644 --- a/src/Result.php +++ b/src/Result.php @@ -15,25 +15,16 @@ final class Result { private const int SUCCESS_EXIT = 0; - /** - * If the exit code is different from 0. - */ public static function failed(Configuration $configuration, TestResult $result): bool { return ! self::ok($configuration, $result); } - /** - * If the exit code is exactly 0. - */ public static function ok(Configuration $configuration, TestResult $result): bool { return self::exitCode($configuration, $result) === self::SUCCESS_EXIT; } - /** - * Get the test execution's exit code. - */ public static function exitCode(Configuration $configuration, TestResult $result): int { $shell = new ShellExitCodeCalculator; diff --git a/src/Subscribers/EnsureConfigurationIsAvailable.php b/src/Subscribers/EnsureConfigurationIsAvailable.php index f23ee108..734cdeae 100644 --- a/src/Subscribers/EnsureConfigurationIsAvailable.php +++ b/src/Subscribers/EnsureConfigurationIsAvailable.php @@ -14,9 +14,6 @@ use PHPUnit\TextUI\Configuration\Configuration; */ final class EnsureConfigurationIsAvailable implements ConfiguredSubscriber { - /** - * Runs the subscriber. - */ public function notify(Configured $event): void { Container::getInstance()->add(Configuration::class, $event->configuration()); diff --git a/src/Subscribers/EnsureIgnorableTestCasesAreIgnored.php b/src/Subscribers/EnsureIgnorableTestCasesAreIgnored.php index 45a7823d..afa7082e 100644 --- a/src/Subscribers/EnsureIgnorableTestCasesAreIgnored.php +++ b/src/Subscribers/EnsureIgnorableTestCasesAreIgnored.php @@ -16,9 +16,6 @@ use ReflectionClass; */ final class EnsureIgnorableTestCasesAreIgnored implements StartedSubscriber { - /** - * Runs the subscriber. - */ public function notify(Started $event): void { $reflection = new ReflectionClass(Facade::class); diff --git a/src/Subscribers/EnsureKernelDumpIsFlushed.php b/src/Subscribers/EnsureKernelDumpIsFlushed.php index debcc99c..579deb6b 100644 --- a/src/Subscribers/EnsureKernelDumpIsFlushed.php +++ b/src/Subscribers/EnsureKernelDumpIsFlushed.php @@ -14,9 +14,6 @@ use PHPUnit\Event\TestRunner\StartedSubscriber; */ final class EnsureKernelDumpIsFlushed implements StartedSubscriber { - /** - * Runs the subscriber. - */ public function notify(Started $event): void { $kernelDump = Container::getInstance()->get(KernelDump::class); diff --git a/src/Subscribers/EnsureShardTimingFinished.php b/src/Subscribers/EnsureShardTimingFinished.php index f1732d9b..dbd5a6c4 100644 --- a/src/Subscribers/EnsureShardTimingFinished.php +++ b/src/Subscribers/EnsureShardTimingFinished.php @@ -12,9 +12,6 @@ use PHPUnit\Event\TestSuite\FinishedSubscriber; */ final class EnsureShardTimingFinished implements FinishedSubscriber { - /** - * Runs the subscriber. - */ public function notify(Finished $event): void { EnsureShardTimingsAreCollected::finished($event); diff --git a/src/Subscribers/EnsureShardTimingStarted.php b/src/Subscribers/EnsureShardTimingStarted.php index 7dd5124e..792db9be 100644 --- a/src/Subscribers/EnsureShardTimingStarted.php +++ b/src/Subscribers/EnsureShardTimingStarted.php @@ -12,9 +12,6 @@ use PHPUnit\Event\TestSuite\StartedSubscriber; */ final class EnsureShardTimingStarted implements StartedSubscriber { - /** - * Runs the subscriber. - */ public function notify(Started $event): void { EnsureShardTimingsAreCollected::started($event); diff --git a/src/Subscribers/EnsureShardTimingsAreCollected.php b/src/Subscribers/EnsureShardTimingsAreCollected.php index a45d2337..9ddd6d66 100644 --- a/src/Subscribers/EnsureShardTimingsAreCollected.php +++ b/src/Subscribers/EnsureShardTimingsAreCollected.php @@ -14,22 +14,15 @@ use PHPUnit\Event\TestSuite\Started; final class EnsureShardTimingsAreCollected { /** - * The start times for each test class. - * * @var array */ private static array $startTimes = []; /** - * The collected timings for each test class. - * * @var array */ private static array $timings = []; - /** - * Records the start time for a test suite. - */ public static function started(Started $event): void { if (! $event->testSuite()->isForTestClass()) { @@ -43,9 +36,6 @@ final class EnsureShardTimingsAreCollected } } - /** - * Records the duration for a test suite. - */ public static function finished(Finished $event): void { if (! $event->testSuite()->isForTestClass()) { @@ -64,8 +54,6 @@ final class EnsureShardTimingsAreCollected } /** - * Returns the collected timings. - * * @return array */ public static function timings(): array diff --git a/src/Subscribers/EnsureTeamCityEnabled.php b/src/Subscribers/EnsureTeamCityEnabled.php index 89793d31..edaa2085 100644 --- a/src/Subscribers/EnsureTeamCityEnabled.php +++ b/src/Subscribers/EnsureTeamCityEnabled.php @@ -17,23 +17,14 @@ use Symfony\Component\Console\Output\OutputInterface; */ final class EnsureTeamCityEnabled implements ConfiguredSubscriber { - /** - * Indicates if the TeamCity logger has already been registered. - */ private static bool $registered = false; - /** - * Creates a new Configured Subscriber instance. - */ public function __construct( private readonly InputInterface $input, private readonly OutputInterface $output, private readonly TestSuite $testSuite, ) {} - /** - * Runs the subscriber. - */ public function notify(Configured $event): void { if (self::$registered) { diff --git a/src/Support/Arr.php b/src/Support/Arr.php index daf7e3a4..c30d7757 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -10,8 +10,6 @@ namespace Pest\Support; final class Arr { /** - * Checks if the given array has the given key. - * * @param array $array */ public static function has(array $array, string|int $key): bool @@ -34,8 +32,6 @@ final class Arr } /** - * Gets the given key value. - * * @param array $array */ public static function get(array $array, string|int $key, mixed $default = null): mixed @@ -62,8 +58,6 @@ final class Arr } /** - * Flatten a multi-dimensional associative array with dots. - * * @param array $array * @return array */ @@ -83,8 +77,6 @@ final class Arr } /** - * Returns the value of the last element or false for empty array - * * @param array $array */ public static function last(array $array): mixed diff --git a/src/Support/Backtrace.php b/src/Support/Backtrace.php index 86957bcb..8ad285c0 100644 --- a/src/Support/Backtrace.php +++ b/src/Support/Backtrace.php @@ -15,9 +15,6 @@ final class Backtrace private const int BACKTRACE_OPTIONS = DEBUG_BACKTRACE_IGNORE_ARGS; - /** - * Returns the current test file. - */ public static function testFile(): string { $current = null; @@ -46,9 +43,6 @@ final class Backtrace return $current[self::FILE]; } - /** - * Returns the current datasets file. - */ public static function datasetsFile(): string { $current = null; @@ -72,9 +66,6 @@ final class Backtrace return $current[self::FILE]; } - /** - * Returns the filename that called the current function/method. - */ public static function file(): string { $trace = self::backtrace(); @@ -82,9 +73,6 @@ final class Backtrace return $trace[self::FILE]; } - /** - * Returns the dirname that called the current function/method. - */ public static function dirname(): string { $trace = self::backtrace(); @@ -92,9 +80,6 @@ final class Backtrace return dirname($trace[self::FILE]); } - /** - * Returns the line that called the current function/method. - */ public static function line(): int { $trace = self::backtrace(); diff --git a/src/Support/ChainableClosure.php b/src/Support/ChainableClosure.php index a6d7a683..7c459a84 100644 --- a/src/Support/ChainableClosure.php +++ b/src/Support/ChainableClosure.php @@ -12,9 +12,6 @@ use Pest\Exceptions\ShouldNotHappen; */ final class ChainableClosure { - /** - * Calls the given `$closure` when the given condition is true, "bound" to the same object. - */ public static function boundWhen(Closure $condition, Closure $next): Closure { return function (...$arguments) use ($condition, $next): void { @@ -28,9 +25,6 @@ final class ChainableClosure }; } - /** - * Calls the given `$closure` and chains the `$next` closure, "bound" to the same object. - */ public static function bound(Closure $closure, Closure $next): Closure { return function (...$arguments) use ($closure, $next): void { @@ -43,9 +37,6 @@ final class ChainableClosure }; } - /** - * Calls the given `$closure` and chains the `$next` closure, "unbound" of any object. - */ public static function unbound(Closure $closure, Closure $next): Closure { return function (...$arguments) use ($closure, $next): void { @@ -54,9 +45,6 @@ final class ChainableClosure }; } - /** - * Call the given static `$closure` and chains the `$next` closure, "bound" to the same object statically. - */ public static function boundStatically(Closure $closure, Closure $next): Closure { return static function (...$arguments) use ($closure, $next): void { diff --git a/src/Support/Closure.php b/src/Support/Closure.php index bf715780..81ac80b4 100644 --- a/src/Support/Closure.php +++ b/src/Support/Closure.php @@ -13,8 +13,6 @@ use Pest\Exceptions\ShouldNotHappen; final class Closure { /** - * Binds the given closure to the given "this". - * * @throws ShouldNotHappen */ public static function bind(?BaseClosure $closure, ?object $newThis, object|string|null $newScope = 'static'): BaseClosure diff --git a/src/Support/Container.php b/src/Support/Container.php index d43c22be..bf1895ad 100644 --- a/src/Support/Container.php +++ b/src/Support/Container.php @@ -13,9 +13,6 @@ use ReflectionParameter; */ final class Container { - /** - * The instance of the container. - */ private static ?Container $instance = null; /** @@ -23,9 +20,6 @@ final class Container */ private array $instances = []; - /** - * Gets a new or already existing container. - */ public static function getInstance(): self { if (! self::$instance instanceof Container) { @@ -35,9 +29,6 @@ final class Container return self::$instance; } - /** - * Gets a dependency from the container. - */ public function get(string $id): object|string { if (! array_key_exists($id, $this->instances)) { @@ -49,8 +40,6 @@ final class Container } /** - * Adds the given instance to the container. - * * @return $this */ public function add(string $id, object|string $instance): self @@ -61,8 +50,6 @@ final class Container } /** - * Tries to build the given instance. - * * @template TObject of object * * @param class-string $id diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index f3968bc9..92110713 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -22,9 +22,6 @@ use function Termwind\terminal; */ final class Coverage { - /** - * Returns the coverage path. - */ public static function getPath(): string { return implode(DIRECTORY_SEPARATOR, [ @@ -34,9 +31,6 @@ final class Coverage ]); } - /** - * Runs true there is any code coverage driver available. - */ public static function isAvailable(): bool { $runtime = new Runtime; @@ -64,18 +58,11 @@ final class Coverage return in_array('coverage', xdebug_info('mode'), true); } - /** - * If the user is using Xdebug. - */ public static function usingXdebug(): bool { return (new Runtime)->hasXdebug(); } - /** - * Reports the code coverage report to the - * console and returns the result in float. - */ public static function report(OutputInterface $output, bool $compact = false, bool $showOnlyCovered = false): float { if (! file_exists($reportPath = self::getPath())) { @@ -174,13 +161,6 @@ final class Coverage } /** - * Generates an array of missing coverage on the following format:. - * - * ``` - * ['11', '20..25', '50', '60..80']; - * ``` - * - * * @param File $file * @return array */ diff --git a/src/Support/Description.php b/src/Support/Description.php index d7d775f2..01fc45a6 100644 --- a/src/Support/Description.php +++ b/src/Support/Description.php @@ -6,14 +6,8 @@ namespace Pest\Support; final readonly class Description implements \Stringable { - /** - * Creates a new Description instance. - */ public function __construct(private string $description) {} - /** - * Returns the description as a string. - */ public function __toString(): string { return $this->description; diff --git a/src/Support/ExceptionTrace.php b/src/Support/ExceptionTrace.php index 92047840..f593adb5 100644 --- a/src/Support/ExceptionTrace.php +++ b/src/Support/ExceptionTrace.php @@ -16,8 +16,6 @@ final class ExceptionTrace private const string UNDEFINED_METHOD = 'Call to undefined method P\\'; /** - * Ensures the given closure reports the good execution context. - * * @throws Throwable */ public static function ensure(Closure $closure): mixed diff --git a/src/Support/ExpectationPipeline.php b/src/Support/ExpectationPipeline.php index 5e0d88db..613bd3d9 100644 --- a/src/Support/ExpectationPipeline.php +++ b/src/Support/ExpectationPipeline.php @@ -12,37 +12,24 @@ use Closure; final class ExpectationPipeline { /** - * The list of pipes. - * * @var array */ private array $pipes = []; /** - * The list of passables. - * * @var array */ private array $passables; - /** - * Creates a new instance of Expectation Pipeline. - */ public function __construct( private readonly Closure $closure ) {} - /** - * Creates a new instance of Expectation Pipeline with given closure. - */ public static function for(Closure $closure): self { return new self($closure); } - /** - * Sets the list of passables. - */ public function send(mixed ...$passables): self { $this->passables = $passables; @@ -51,8 +38,6 @@ final class ExpectationPipeline } /** - * Sets the list of pipes. - * * @param array $pipes */ public function through(array $pipes): self @@ -62,9 +47,6 @@ final class ExpectationPipeline return $this; } - /** - * Runs the pipeline. - */ public function run(): void { $pipeline = array_reduce( @@ -78,9 +60,6 @@ final class ExpectationPipeline $pipeline(); } - /** - * Get a Closure that will carry of the expectation. - */ public function carry(): Closure { return fn (mixed $stack, callable $pipe): Closure => fn () => $pipe($stack, ...$this->passables); diff --git a/src/Support/Exporter.php b/src/Support/Exporter.php index 6fd89c53..f6591d83 100644 --- a/src/Support/Exporter.php +++ b/src/Support/Exporter.php @@ -12,23 +12,14 @@ use SebastianBergmann\RecursionContext\Context; */ final readonly class Exporter { - /** - * The maximum number of items in an array to export. - */ private const int MAX_ARRAY_ITEMS = 3; - /** - * Creates a new Exporter instance. - */ public function __construct( private BaseExporter $exporter, ) { - // ... + // } - /** - * Creates a new Exporter instance. - */ public static function default(): self { return new self( @@ -37,8 +28,6 @@ final readonly class Exporter } /** - * Exports a value into a single-line string recursively. - * * @param array $data */ public function shortenedRecursiveExport(array &$data, ?Context $context = null): string @@ -73,9 +62,6 @@ final readonly class Exporter return implode(', ', $result); } - /** - * Exports a value into a single-line string. - */ public function shortenedExport(mixed $value): string { $map = [ @@ -87,9 +73,6 @@ final readonly class Exporter return (string) preg_replace(array_keys($map), array_values($map), $this->exporter->shortenedExport($value)); } - /** - * Exports a value into a full single-line string without truncation. - */ public function export(mixed $value): string { $map = [ diff --git a/src/Support/HigherOrderCallables.php b/src/Support/HigherOrderCallables.php index 358b4da5..525f3491 100644 --- a/src/Support/HigherOrderCallables.php +++ b/src/Support/HigherOrderCallables.php @@ -12,19 +12,14 @@ use Pest\Expectation; */ final readonly class HigherOrderCallables { - /** - * Creates a new Higher Order Callables instances. - */ public function __construct(private object $target) { - // .. + // } /** * @template TValue * - * Create a new expectation. Callable values will be executed prior to returning the new expectation. - * * @param (Closure():TValue)|TValue $value * @return Expectation */ @@ -39,8 +34,6 @@ final readonly class HigherOrderCallables /** * @template TValue * - * Create a new expectation. Callable values will be executed prior to returning the new expectation. - * * @param callable|TValue $value * @return Expectation<(callable(): mixed)|TValue> */ @@ -50,9 +43,6 @@ final readonly class HigherOrderCallables return $this->expect($value); } - /** - * Execute the given callable after the test has executed the setup method. - */ public function defer(callable $callable): object { Reflection::bindCallableWithData($callable); diff --git a/src/Support/HigherOrderMessage.php b/src/Support/HigherOrderMessage.php index e25dc633..bad2a7e5 100644 --- a/src/Support/HigherOrderMessage.php +++ b/src/Support/HigherOrderMessage.php @@ -16,15 +16,11 @@ final class HigherOrderMessage public const string UNDEFINED_METHOD = 'Method %s does not exist'; /** - * An optional condition that will determine if the message will be executed. - * * @var (Closure(): bool)|null */ public ?Closure $condition = null; /** - * Creates a new higher order message. - * * @param array|null $arguments */ public function __construct( @@ -33,12 +29,10 @@ final class HigherOrderMessage public string $name, public ?array $arguments ) { - // .. + // } /** - * Re-throws the given `$throwable` with the good line and filename. - * * @template TValue of object * * @param TValue $target @@ -73,8 +67,6 @@ final class HigherOrderMessage } /** - * Indicates that this message should only be called when the given condition is true. - * * @param callable(): bool $condition */ public function when(callable $condition): self @@ -84,9 +76,6 @@ final class HigherOrderMessage return $this; } - /** - * Determines whether or not there exists a higher order callable with the message name. - */ private function hasHigherOrderCallable(): bool { return in_array($this->name, get_class_methods(HigherOrderCallables::class), true); diff --git a/src/Support/HigherOrderMessageCollection.php b/src/Support/HigherOrderMessageCollection.php index b90c257d..0c830d6e 100644 --- a/src/Support/HigherOrderMessageCollection.php +++ b/src/Support/HigherOrderMessageCollection.php @@ -15,8 +15,6 @@ final class HigherOrderMessageCollection private array $messages = []; /** - * Adds a new higher order message to the collection. - * * @param array|null $arguments */ public function add(string $filename, int $line, string $name, ?array $arguments): void @@ -25,8 +23,6 @@ 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 */ public function addWhen(callable $condition, string $filename, int $line, string $name, ?array $arguments): void @@ -34,9 +30,6 @@ final class HigherOrderMessageCollection $this->messages[] = new HigherOrderMessage($filename, $line, $name, $arguments)->when($condition); } - /** - * Proxy all the messages starting from the target. - */ public function chain(object $target): void { foreach ($this->messages as $message) { @@ -44,9 +37,6 @@ final class HigherOrderMessageCollection } } - /** - * Proxy all the messages to the target. - */ public function proxy(object $target): void { foreach ($this->messages as $message) { @@ -55,8 +45,6 @@ final class HigherOrderMessageCollection } /** - * Count the number of messages with the given 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 166d8a42..d43c74f8 100644 --- a/src/Support/HigherOrderTapProxy.php +++ b/src/Support/HigherOrderTapProxy.php @@ -12,26 +12,17 @@ use ReflectionClass; */ final class HigherOrderTapProxy { - /** - * Create a new tap proxy instance. - */ public function __construct( public TestCase $target ) { - // .. + // } - /** - * Dynamically sets properties on the target. - */ public function __set(string $property, mixed $value): void { $this->target->{$property} = $value; } - /** - * Dynamically pass properties gets to the target. - */ public function __get(string $property): mixed { if (property_exists($this->target, $property)) { @@ -50,8 +41,6 @@ final class HigherOrderTapProxy } /** - * Dynamically pass method calls to the target. - * * @param array $arguments * @return mixed */ diff --git a/src/Support/NullClosure.php b/src/Support/NullClosure.php index 0f56a008..c800872d 100644 --- a/src/Support/NullClosure.php +++ b/src/Support/NullClosure.php @@ -11,9 +11,6 @@ use Closure; */ final class NullClosure { - /** - * Creates a nullable closure. - */ public static function create(): Closure { return Closure::fromCallable(function (): void {}); diff --git a/src/Support/Reflection.php b/src/Support/Reflection.php index 3d059f5f..6c8f6a92 100644 --- a/src/Support/Reflection.php +++ b/src/Support/Reflection.php @@ -24,8 +24,6 @@ use ReflectionUnionType; final class Reflection { /** - * Calls the given method with args on the given object. - * * @param array $args */ public static function call(object $object, string $method, array $args = []): mixed @@ -50,8 +48,6 @@ final class Reflection } /** - * Bind a callable to the TestCase and return the result. - * * @param array $args */ public static function bindCallable(callable $callable, array $args = []): mixed @@ -59,10 +55,6 @@ final class Reflection return Closure::fromCallable($callable)->bindTo(TestSuite::getInstance()->test)(...$args); } - /** - * Bind a callable to the TestCase and return the result, - * passing in the current dataset values as arguments. - */ public static function bindCallableWithData(callable $callable): mixed { $test = TestSuite::getInstance()->test; @@ -80,9 +72,6 @@ final class Reflection return Closure::fromCallable($callable)->bindTo($test)(...$test->providedData()); } - /** - * Infers the file name from the given closure. - */ public static function getFileNameFromClosure(Closure $closure): string { $reflectionClosure = new ReflectionFunction($closure); @@ -90,9 +79,6 @@ final class Reflection return (string) $reflectionClosure->getFileName(); } - /** - * Gets the property value from of the given object. - */ public static function getPropertyValue(object $object, string $property): mixed { $reflectionClass = new ReflectionClass($object); @@ -116,8 +102,6 @@ final class Reflection } /** - * Sets the property value of the given object. - * * @template TValue of object * * @param TValue $object @@ -145,8 +129,6 @@ final class Reflection } /** - * Get the class name of the given parameter's type, if possible. - * * @see https://github.com/laravel/framework/blob/v6.18.25/src/Illuminate/Support/Reflector.php */ public static function getParameterClassName(ReflectionParameter $parameter): ?string @@ -175,8 +157,6 @@ final class Reflection } /** - * Receive a map of function argument names to their types. - * * @return array */ public static function getFunctionArguments(Closure $function): array @@ -197,7 +177,7 @@ final class Reflection $arguments[$parameter->getName()] = implode('|', array_map( static fn (ReflectionNamedType $type): string => $type->getName(), // @phpstan-ignore-line ($types instanceof ReflectionNamedType) - ? [$types] // NOTE: normalize as list of to handle unions + ? [$types] : $types->getTypes(), )); } @@ -211,10 +191,6 @@ final class Reflection } /** - * Get the properties from the given reflection class. - * - * Used by `expect()->toHavePropertiesDocumented()`. - * * @param ReflectionClass $reflectionClass * @return array */ @@ -246,10 +222,6 @@ final class Reflection } /** - * Get the methods from the given reflection class. - * - * Used by `expect()->toHaveMethodsDocumented()`. - * * @param ReflectionClass $reflectionClass * @return array */ diff --git a/src/Support/Shell.php b/src/Support/Shell.php index b5c5b157..08bab0d0 100644 --- a/src/Support/Shell.php +++ b/src/Support/Shell.php @@ -16,9 +16,6 @@ use Psy\VersionUpdater\Checker; */ final class Shell { - /** - * Creates a new interactive shell. - */ public static function open(): void { $config = new Configuration; @@ -39,8 +36,6 @@ final class Shell } /** - * Returns the casters for the Psy Shell. - * * @return array */ private static function casters(): array @@ -72,9 +67,6 @@ final class Shell return array_merge($casters, (array) $config->get('tinker.casters', [])); } - /** - * Tinkers the current shell, if the Tinker package is available. - */ private static function tinkered(PsyShell $shell): ?object { if (function_exists('app') === false diff --git a/src/Support/StateGenerator.php b/src/Support/StateGenerator.php index 6ed7ccbd..a3cea7e5 100644 --- a/src/Support/StateGenerator.php +++ b/src/Support/StateGenerator.php @@ -167,7 +167,6 @@ final class StateGenerator } } - // for each test that passed, we need to add it to the state for ($i = 0; $i < $passedTests; $i++) { $state->add(TestResult::fromPestParallelTestCase( new TestMethod( @@ -186,11 +185,6 @@ final class StateGenerator return $state; } - /** - * Adds the given class-level "hook" failure to the state. Collision's - * `fromBeforeFirstTestMethodErrored` only accepts `BeforeFirstTestMethodErrored` - * events, so the remaining class-level events get a synthesized test method. - */ private function addClassLevelEvent(State $state, AfterLastTestMethodErrored|AfterLastTestMethodFailed|BeforeFirstTestMethodErrored|BeforeFirstTestMethodFailed $event): void { if ($event instanceof BeforeFirstTestMethodErrored) { diff --git a/src/Support/Str.php b/src/Support/Str.php index 335432ee..0280d73f 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -9,17 +9,11 @@ namespace Pest\Support; */ final class Str { - /** - * Pool of alpha-numeric characters for generating (unsafe) random strings - * from. - */ private const string POOL = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; private const string PREFIX = '__pest_evaluable_'; /** - * The list of names PHP reserves, and therefore refuses, as class names. - * * @see https://github.com/php/php-src/blob/master/Zend/zend_compile.c * * @var array @@ -45,9 +39,6 @@ final class Str ]; /** - * Create a (unsecure & non-cryptographically safe) random alpha-numeric - * string value. - * * @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 @@ -57,17 +48,11 @@ final class Str return substr(str_shuffle(str_repeat(self::POOL, 5)), 0, $length); } - /** - * Checks if the given `$target` starts with the given `$search`. - */ public static function startsWith(string $target, string $search): bool { return str_starts_with($target, $search); } - /** - * Checks if the given `$target` ends with the given `$search`. - */ public static function endsWith(string $target, string $search): bool { $length = strlen($search); @@ -78,31 +63,20 @@ final class Str return $search === substr($target, -$length); } - /** - * Makes the given string evaluable by an `eval`. - */ public static function evaluable(string $code): string { $code = str_replace('_', '__', $code); $code = self::PREFIX.str_replace(' ', '_', $code); - // sticks to PHP8.2 function naming rules https://www.php.net/manual/en/functions.user-defined.php return (string) preg_replace('/[^a-zA-Z0-9_\x80-\xff]/', '_', $code); } - /** - * Determine if the given name is a valid PHP identifier, and therefore may - * be used as a single namespace name. - */ public static function isValidIdentifier(string $name): bool { return preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) === 1; } - /** - * Determine if the given name may be declared as a class name by an `eval`. - */ public static function isValidClassName(string $name): bool { if (! self::isValidIdentifier($name)) { @@ -115,14 +89,9 @@ final class Str $tokens = token_get_all(sprintf(' 0; } - /** - * Determine if a given value is a valid ULID. - */ public static function isUlid(string $value): bool { return preg_match('/^[0-9A-HJKMNP-TV-Z]{26}$/', $value) > 0; } /** - * Creates a describe block as `$describeDescription` → `$testDescription` format. - * * @param array $describeDescriptions */ public static function describe(array $describeDescriptions, string $testDescription): string @@ -174,25 +132,16 @@ final class Str return sprintf(str_repeat('`%s` → ', count($describeDescriptions)).'%s', ...$descriptionComponents); } - /** - * Determine if a given value is a valid email address. - */ public static function isEmail(string $value): bool { return (bool) filter_var($value, FILTER_VALIDATE_EMAIL); } - /** - * Determine if a given value is a valid URL. - */ public static function isUrl(string $value): bool { return (bool) filter_var($value, FILTER_VALIDATE_URL); } - /** - * Converts the given `$target` to a URL-friendly "slug". - */ public static function slugify(string $target): string { $target = preg_replace('/[^a-zA-Z0-9]+/', '-', $target); diff --git a/src/Support/View.php b/src/Support/View.php index a73fd83a..e7919bc1 100644 --- a/src/Support/View.php +++ b/src/Support/View.php @@ -15,22 +15,14 @@ use function Termwind\renderUsing; */ final class View { - /** - * The implementation of the output. - */ private static OutputInterface $output; - /** - * Renders views using the given Output instance. - */ public static function renderUsing(OutputInterface $output): void { self::$output = $output; } /** - * Renders the given view. - * * @param array $data */ public static function render(string $path, array $data = []): void @@ -49,8 +41,6 @@ final class View } /** - * Compiles the given view. - * * @param array $data */ private static function compile(string $path, array $data): string diff --git a/src/TestCaseFilters/GitDirtyTestCaseFilter.php b/src/TestCaseFilters/GitDirtyTestCaseFilter.php index 70447b50..87bbd4c9 100644 --- a/src/TestCaseFilters/GitDirtyTestCaseFilter.php +++ b/src/TestCaseFilters/GitDirtyTestCaseFilter.php @@ -18,12 +18,9 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter */ private ?array $changedFiles = null; - /** - * Creates a new instance of the filter. - */ public function __construct(private readonly string $projectRoot) { - // ... + // } /** @@ -47,9 +44,6 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter return in_array($relativePath, $this->changedFiles, true); } - /** - * Loads the changed files. - */ private function loadChangedFiles(): void { $status = new Git(timeout: 60.0)->raw(['status', '--short', '--', '*.php']); diff --git a/src/TestCaseMethodFilters/AssigneeTestCaseFilter.php b/src/TestCaseMethodFilters/AssigneeTestCaseFilter.php index e21ff032..3fb345ec 100644 --- a/src/TestCaseMethodFilters/AssigneeTestCaseFilter.php +++ b/src/TestCaseMethodFilters/AssigneeTestCaseFilter.php @@ -9,17 +9,11 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class AssigneeTestCaseFilter implements TestCaseMethodFilter { - /** - * Create a new filter instance. - */ public function __construct(private string $assignee) { // } - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return array_filter($factory->assignees, fn (string $assignee): bool => str_starts_with($assignee, $this->assignee)) !== []; diff --git a/src/TestCaseMethodFilters/FlakyTestCaseFilter.php b/src/TestCaseMethodFilters/FlakyTestCaseFilter.php index fac0640e..2ccd1485 100644 --- a/src/TestCaseMethodFilters/FlakyTestCaseFilter.php +++ b/src/TestCaseMethodFilters/FlakyTestCaseFilter.php @@ -9,9 +9,6 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class FlakyTestCaseFilter implements TestCaseMethodFilter { - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return $factory->flakyTries !== null; diff --git a/src/TestCaseMethodFilters/IssueTestCaseFilter.php b/src/TestCaseMethodFilters/IssueTestCaseFilter.php index 5dfd336b..da459157 100644 --- a/src/TestCaseMethodFilters/IssueTestCaseFilter.php +++ b/src/TestCaseMethodFilters/IssueTestCaseFilter.php @@ -9,17 +9,11 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class IssueTestCaseFilter implements TestCaseMethodFilter { - /** - * Create a new filter instance. - */ public function __construct(private int $number) { // } - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return in_array($this->number, $factory->issues, true); diff --git a/src/TestCaseMethodFilters/NotesTestCaseFilter.php b/src/TestCaseMethodFilters/NotesTestCaseFilter.php index 6aafc974..592fc600 100644 --- a/src/TestCaseMethodFilters/NotesTestCaseFilter.php +++ b/src/TestCaseMethodFilters/NotesTestCaseFilter.php @@ -9,9 +9,6 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class NotesTestCaseFilter implements TestCaseMethodFilter { - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return $factory->notes !== []; diff --git a/src/TestCaseMethodFilters/PrTestCaseFilter.php b/src/TestCaseMethodFilters/PrTestCaseFilter.php index 7905b5ae..3d6d5e57 100644 --- a/src/TestCaseMethodFilters/PrTestCaseFilter.php +++ b/src/TestCaseMethodFilters/PrTestCaseFilter.php @@ -9,17 +9,11 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class PrTestCaseFilter implements TestCaseMethodFilter { - /** - * Create a new filter instance. - */ public function __construct(private int $number) { // } - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return in_array($this->number, $factory->prs, true); diff --git a/src/TestCaseMethodFilters/TodoTestCaseFilter.php b/src/TestCaseMethodFilters/TodoTestCaseFilter.php index a9d66acd..26c93781 100644 --- a/src/TestCaseMethodFilters/TodoTestCaseFilter.php +++ b/src/TestCaseMethodFilters/TodoTestCaseFilter.php @@ -9,9 +9,6 @@ use Pest\Factories\TestCaseMethodFactory; final readonly class TodoTestCaseFilter implements TestCaseMethodFilter { - /** - * Filter the test case methods. - */ public function accept(TestCaseMethodFactory $factory): bool { return $factory->todo; diff --git a/src/TestCases/IgnorableTestCase.php b/src/TestCases/IgnorableTestCase.php index 0d5bcee5..524e5ae3 100644 --- a/src/TestCases/IgnorableTestCase.php +++ b/src/TestCases/IgnorableTestCase.php @@ -11,5 +11,5 @@ use PHPUnit\Framework\TestCase; */ final class IgnorableTestCase extends TestCase { - // ... + // } diff --git a/src/TestSuite.php b/src/TestSuite.php index df17ec2d..c56a74f6 100644 --- a/src/TestSuite.php +++ b/src/TestSuite.php @@ -19,54 +19,24 @@ use PHPUnit\Framework\TestCase; */ final class TestSuite { - /** - * Holds the current test case. - */ public ?TestCase $test = null; - /** - * Holds the tests repository. - */ public TestRepository $tests; - /** - * Holds the before each repository. - */ public BeforeEachRepository $beforeEach; - /** - * Holds the before all repository. - */ public BeforeAllRepository $beforeAll; - /** - * Holds the after each repository. - */ public AfterEachRepository $afterEach; - /** - * Holds the after all repository. - */ public AfterAllRepository $afterAll; - /** - * Holds the snapshots repository. - */ public SnapshotRepository $snapshots; - /** - * Holds the root path. - */ public string $rootPath; - /** - * Holds an instance of the test suite. - */ private static ?TestSuite $instance = null; - /** - * Creates a new instance of the test suite. - */ public function __construct( string $rootPath, public string $testPath, @@ -84,9 +54,6 @@ final class TestSuite ); } - /** - * Returns the current instance of the test suite. - */ public static function getInstance( ?string $rootPath = null, ?string $testPath = null, diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index 56f40481..d9517985 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -1,5 +1,5 @@ - Pest Testing Framework 5.0.4. + Pest Testing Framework 5.0.5. USAGE: pest [options] diff --git a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap index 10b4a5d6..aebbb912 100644 --- a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap @@ -1,3 +1,3 @@ - Pest Testing Framework 5.0.4. + Pest Testing Framework 5.0.5. diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 79b93237..527b14cd 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -73,9 +73,9 @@ ↓ is marked as todo 3 ↓ shouldBeMarkedAsTodo - WARN Tests\Features\Coverage + PASS Tests\Features\Coverage ✓ it has plugin - - it adds coverage if --coverage exist → Coverage is not available + ✓ it adds coverage if --coverage exist ✓ it adds coverage if --min exist ✓ it generates coverage based on file input @@ -1709,7 +1709,7 @@ PASS Tests\Features\Tia\LivewireComponents ✓ a changed single-file component selects only the tests that rendered it, across workers - ✓ a changed multi-file component class selects the tests that rendered the component + ✓ a changed multi-file component asset selects the tests that rendered the component ✓ a deleted single-file component selects the tests that rendered it ✓ a Blade file with no generated view still falls back to the watch pattern @@ -2119,6 +2119,9 @@ ✓ Livewire component views → it maps documented MFC locations using the component directory hash with dataset "default component location" ✓ Livewire component views → it maps documented MFC locations using the component directory hash with dataset "default component location without emoji" ✓ Livewire component views → it maps documented MFC locations using the component directory hash with dataset "index convention" + ✓ Livewire component views → it maps a changed MFC sibling through the component directory hash with dataset "class sibling via the generated class" + ✓ Livewire component views → it maps a changed MFC sibling through the component directory hash with dataset "class sibling via the generated view" + ✓ Livewire component views → it maps a changed MFC sibling through the component directory hash with dataset "asset sibling via the generated view" ✓ Livewire component views → it preserves direct view edges for class-based components ✓ Livewire component views → it falls back to watch patterns when no generated view matches ✓ markKnownTestFiles() → it makes a test file with no edges known @@ -2432,4 +2435,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1756 passed (3974 assertions) \ No newline at end of file + Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 34 skipped, 1760 passed (3983 assertions) \ No newline at end of file diff --git a/tests/Features/AfterAll.php b/tests/Features/AfterAll.php index 0afd0a56..03bf7972 100644 --- a/tests/Features/AfterAll.php +++ b/tests/Features/AfterAll.php @@ -16,6 +16,6 @@ test('deletes file after all', function () use ($file): void { file_put_contents($file, 'foo'); expect($file)->toBeFile(); register_shutdown_function(function (): void { - // $this->assertFileDoesNotExist($file); + // }); }); diff --git a/tests/Features/BeforeEachProxiesToTestCallWithExpectations.php b/tests/Features/BeforeEachProxiesToTestCallWithExpectations.php index 3c70c32e..58acd4ce 100644 --- a/tests/Features/BeforeEachProxiesToTestCallWithExpectations.php +++ b/tests/Features/BeforeEachProxiesToTestCallWithExpectations.php @@ -5,13 +5,13 @@ declare(strict_types=1); beforeEach()->expect(true)->toBeTrue(); test('runs 1', function (): void { - // This test did performs assertions... + // }); test('runs 2', function (): void { - // This test did performs assertions... + // }); test('runs 3', function (): void { - // This test did performs assertions... + // }); diff --git a/tests/Features/DatasetMethodChaining.php b/tests/Features/DatasetMethodChaining.php index af1fa261..8c844dc8 100644 --- a/tests/Features/DatasetMethodChaining.php +++ b/tests/Features/DatasetMethodChaining.php @@ -1,16 +1,5 @@ with(), describe()->with(), - * and nested describe blocks with datasets. - */ - -// --------------------------------------------------------------- -// beforeEach()->with() inside describe blocks -// --------------------------------------------------------------- - describe('beforeEach()->with() applies dataset to tests', function (): void { beforeEach()->with([10]); @@ -50,10 +39,6 @@ describe('beforeEach()->with() with closure dataset', function (): void { }); }); -// --------------------------------------------------------------- -// describe()->with() method chaining -// --------------------------------------------------------------- - describe('describe()->with() passes dataset to tests', function (): void { test('receives the dataset value', function ($value): void { expect($value)->toBe(42); @@ -85,10 +70,6 @@ describe('describe()->with() with closure dataset', function (): void { yield [14]; }); -// --------------------------------------------------------------- -// Nested describe blocks with datasets -// --------------------------------------------------------------- - describe('outer with dataset', function (): void { describe('inner without dataset', function (): void { test('inherits outer dataset', function (...$args): void { @@ -123,10 +104,6 @@ describe('deeply nested describe with datasets', function (): void { })->with([1]); }); -// --------------------------------------------------------------- -// Combining hook datasets with test-level datasets -// --------------------------------------------------------------- - describe('beforeEach()->with() combined with test->with()', function (): void { beforeEach()->with([10]); @@ -143,10 +120,6 @@ describe('describe()->with() combined with test->with()', function (): void { })->with([50, 60]); })->with([5]); -// --------------------------------------------------------------- -// beforeEach()->with() combined with beforeEach closure -// --------------------------------------------------------------- - describe('beforeEach closure and beforeEach()->with() coexist', function (): void { beforeEach(function (): void { $this->setupValue = 'initialized'; @@ -177,10 +150,6 @@ describe('beforeEach()->with() does not interfere with closure hooks', function }); }); -// --------------------------------------------------------------- -// Dataset isolation between describe blocks -// --------------------------------------------------------------- - describe('first describe with dataset', function (): void { beforeEach()->with([111]); @@ -203,10 +172,6 @@ describe('third describe without dataset', function (): void { }); }); -// --------------------------------------------------------------- -// describe()->with() combined with beforeEach hooks -// --------------------------------------------------------------- - describe('describe()->with() with beforeEach closure', function (): void { beforeEach(function (): void { $this->hookRan = true; @@ -229,10 +194,6 @@ describe('describe()->with() with afterEach closure', function (): void { }); })->with([88]); -// --------------------------------------------------------------- -// Multiple tests in a describe with beforeEach()->with() -// --------------------------------------------------------------- - describe('multiple tests share the same beforeEach dataset', function (): void { beforeEach()->with([33]); @@ -249,10 +210,6 @@ describe('multiple tests share the same beforeEach dataset', function (): void { }); }); -// --------------------------------------------------------------- -// Nested describe with beforeEach()->with() at inner level -// --------------------------------------------------------------- - describe('outer describe', function (): void { beforeEach(function (): void { $this->outer = true; @@ -272,10 +229,6 @@ describe('outer describe', function (): void { }); }); -// --------------------------------------------------------------- -// describe()->with() with depends -// --------------------------------------------------------------- - describe('describe()->with() preserves depends', function (): void { test('first', function ($value): void { expect($value)->toBe(9); diff --git a/tests/Features/DatasetsTests.php b/tests/Features/DatasetsTests.php index 3cf345a9..d70bb05c 100644 --- a/tests/Features/DatasetsTests.php +++ b/tests/Features/DatasetsTests.php @@ -38,7 +38,6 @@ it('gets bound to test case object', function ($value): void { test('it truncates the description', function (): void { expect(true)->toBeTrue(); - // it gets tested by the integration test })->with([str_repeat('Fooo', 10)]); $state = new stdClass; @@ -294,7 +293,7 @@ it('resolves a potential bound dataset logically', function ($foo, $bar): void { [ 'foo', fn (): string => 'bar', - ], // This should be passed as a closure because we've passed multiple arguments + ], ]); it('resolves a potential bound dataset logically even when the closure comes first', function ($foo, $bar): void { @@ -303,7 +302,7 @@ it('resolves a potential bound dataset logically even when the closure comes fir })->with([ [ fn (): string => 'foo', 'bar', - ], // This should be passed as a closure because we've passed multiple arguments + ], ]); it('will not resolve a closure if it is type hinted as a closure', function (Closure $data): void { diff --git a/tests/Features/Depends.php b/tests/Features/Depends.php index 0fbe91f5..c9658d9d 100644 --- a/tests/Features/Depends.php +++ b/tests/Features/Depends.php @@ -33,7 +33,6 @@ test('depends run test only once', function () use (&$runCounter): void { expect($runCounter)->toBe(2); })->depends('first', 'second'); -// Regression tests. See https://github.com/pestphp/pest/pull/216 it('asserts true is true')->assertTrue(true); test('depends works with the correct test name')->assertTrue(true)->depends('it asserts true is true'); diff --git a/tests/Features/DescriptionLess.php b/tests/Features/DescriptionLess.php index 99afb446..c859d083 100644 --- a/tests/Features/DescriptionLess.php +++ b/tests/Features/DescriptionLess.php @@ -26,12 +26,12 @@ trait Gettable } } -get('foo'); // not incomplete because closure is created... +get('foo'); get('foo')->get('bar')->expect(true)->toBeTrue(); get('foo')->expect(true)->toBeTrue(); describe('a "describe" group of tests', function (): void { - get('foo'); // not incomplete because closure is created... + get('foo'); get('foo')->get('bar')->expect(true)->toBeTrue(); get('foo')->expect(true)->toBeTrue(); }); diff --git a/tests/Features/Expect/each.php b/tests/Features/Expect/each.php index 6b94b54b..fdafb7c0 100644 --- a/tests/Features/Expect/each.php +++ b/tests/Features/Expect/each.php @@ -10,13 +10,9 @@ it('expects on each item', function (): void { expect([1, 1, 1]) ->each() ->toEqual(1) - ->and(static::getCount())->toBe(3); // + 1 assertion - - expect([1, 1, 1]) - ->each - ->toEqual(1); - - expect(static::getCount())->toBe(7); + ->and(static::getCount())->toBe(3) + ->and([1, 1, 1])->each->toEqual(1) + ->and(static::getCount())->toBe(7); }); it('chains expectations on each item', function (): void { @@ -24,14 +20,8 @@ it('chains expectations on each item', function (): void { ->each() ->toBeInt() ->toEqual(1) - ->and(static::getCount())->toBe(6); // + 1 assertion - - expect([2, 2, 2]) - ->each - ->toBeInt - ->toEqual(2); - - expect(static::getCount())->toBe(13); + ->and(static::getCount())->toBe(6)->and([2, 2, 2])->each->toBeInt->toEqual(2) + ->and(static::getCount())->toBe(13); }); test('opposite expectations on each item', function (): void { @@ -60,18 +50,17 @@ test('chained opposite and non-opposite expectations', function (): void { it('can add expectations via "and"', function (): void { expect([1, 2, 3]) ->each() - ->toBeInt // + 3 + ->toBeInt ->and([4, 5, 6]) ->each - ->toBeLessThan(7) // + 3 + ->toBeLessThan(7) ->not ->toBeLessThan(3) - ->toBeGreaterThan(3) // + 3 + ->toBeGreaterThan(3) ->and('Hello World') - ->toBeString // + 1 - ->toEqual('Hello World'); // + 1 - - expect(static::getCount())->toBe(14); + ->toBeString + ->toEqual('Hello World') + ->and(static::getCount())->toBe(14); }); it('accepts callables', function (): void { diff --git a/tests/Features/Expect/pipes.php b/tests/Features/Expect/pipes.php index e4ddff28..50d6c958 100644 --- a/tests/Features/Expect/pipes.php +++ b/tests/Features/Expect/pipes.php @@ -12,7 +12,7 @@ class Number public function __construct( public int $value ) { - // .. + // } } @@ -21,7 +21,7 @@ class Char public function __construct( public string $value ) { - // .. + // } } @@ -30,7 +30,7 @@ class Symbol public function __construct( public string $value ) { - // .. + // } } @@ -58,9 +58,6 @@ class State $state = new State; -/* - * Overrides toBe to assert two Characters are the same - */ expect()->pipe('toBe', function ($next, $expected) use ($state): void { $state->runCount['char']++; @@ -70,17 +67,12 @@ expect()->pipe('toBe', function ($next, $expected) use ($state): void { assertInstanceOf(Char::class, $expected); assertEquals($this->value->value, $expected->value); - // returning nothing stops pipeline execution return; } - // calling $next(); let the pipeline to keep running $next(); }); -/* - * Overrides toBe to assert two Number objects are the same - */ expect()->intercept('toBe', Number::class, function ($expected) use ($state): void { $state->runCount['number']++; $state->appliedCount['number']++; @@ -89,17 +81,11 @@ expect()->intercept('toBe', Number::class, function ($expected) use ($state): vo assertEquals($this->value->value, $expected->value); }); -/* - * Overrides toBe to assert all integers are allowed if value is a wildcard (*) - */ expect()->intercept('toBe', fn ($value, $expected) => $value === '*' && is_numeric($expected), function ($expected) use ($state): void { $state->runCount['wildcard']++; $state->appliedCount['wildcard']++; }); -/* - * Overrides toBe to assert to Symbols are the same - */ expect()->pipe('toBe', function ($next, $expected) use ($state): void { $state->runCount['symbol']++; @@ -114,9 +100,6 @@ expect()->pipe('toBe', function ($next, $expected) use ($state): void { $next(); }); -/* - * Overrides toBe to allow ignoring case when checking strings - */ expect()->intercept('toBe', fn ($value) => is_string($value), function ($expected, $ignoreCase = false): void { if ($ignoreCase) { assertEqualsIgnoringCase($expected, $this->value); diff --git a/tests/Features/Expect/toBeBase64.php b/tests/Features/Expect/toBeBase64.php index 06bfe965..a872c21a 100644 --- a/tests/Features/Expect/toBeBase64.php +++ b/tests/Features/Expect/toBeBase64.php @@ -6,11 +6,11 @@ use Pest\Exceptions\InvalidExpectationValue; use PHPUnit\Framework\ExpectationFailedException; test('pass', function (): void { - expect('Zm9v')->toBeBase64() // 'foo' (no padding) - ->and('Zm9vYg==')->toBeBase64() // 'foob' (with padding) - ->and('Zm9vYmE=')->toBeBase64() // 'fooba' (with padding) - ->and('Zm9vYmFy')->toBeBase64() // 'foobar' (no padding) - ->and('')->toBeBase64(); // empty string + expect('Zm9v')->toBeBase64() + ->and('Zm9vYg==')->toBeBase64() + ->and('Zm9vYmE=')->toBeBase64() + ->and('Zm9vYmFy')->toBeBase64() + ->and('')->toBeBase64(); }); test('failures', function (): void { diff --git a/tests/Features/Expect/toBeDomain.php b/tests/Features/Expect/toBeDomain.php index 694dcf34..1d818ee2 100644 --- a/tests/Features/Expect/toBeDomain.php +++ b/tests/Features/Expect/toBeDomain.php @@ -6,10 +6,10 @@ use Pest\Exceptions\InvalidExpectationValue; use PHPUnit\Framework\ExpectationFailedException; test('pass', function (): void { - expect('example.com')->toBeDomain() // standard domain - ->and('sub.example.com')->toBeDomain() // subdomain - ->and('my-host.io')->toBeDomain() // with hyphen - ->and('example.co.uk')->toBeDomain(); // multi-level TLD + expect('example.com')->toBeDomain() + ->and('sub.example.com')->toBeDomain() + ->and('my-host.io')->toBeDomain() + ->and('example.co.uk')->toBeDomain(); }); test('failures', function (): void { diff --git a/tests/Features/Expect/toBeHexadecimal.php b/tests/Features/Expect/toBeHexadecimal.php index aeb7eef7..6c838074 100644 --- a/tests/Features/Expect/toBeHexadecimal.php +++ b/tests/Features/Expect/toBeHexadecimal.php @@ -6,11 +6,11 @@ use Pest\Exceptions\InvalidExpectationValue; use PHPUnit\Framework\ExpectationFailedException; test('pass', function (): void { - expect('abcdef')->toBeHexadecimal() // lowercase - ->and('ABCDEF')->toBeHexadecimal() // uppercase - ->and('aBcDeF')->toBeHexadecimal() // mixed case - ->and('1234567890')->toBeHexadecimal() // numeric - ->and('deadbeef')->toBeHexadecimal(); // alphanumeric + expect('abcdef')->toBeHexadecimal() + ->and('ABCDEF')->toBeHexadecimal() + ->and('aBcDeF')->toBeHexadecimal() + ->and('1234567890')->toBeHexadecimal() + ->and('deadbeef')->toBeHexadecimal(); }); test('failures', function (): void { diff --git a/tests/Features/Expect/toBeHostname.php b/tests/Features/Expect/toBeHostname.php index 3c542df1..381ef704 100644 --- a/tests/Features/Expect/toBeHostname.php +++ b/tests/Features/Expect/toBeHostname.php @@ -6,10 +6,10 @@ use Pest\Exceptions\InvalidExpectationValue; use PHPUnit\Framework\ExpectationFailedException; test('pass', function (): void { - expect('example')->toBeHostname() // single label - ->and('example.com')->toBeHostname() // multiple labels - ->and('sub.example.com')->toBeHostname() // subdomain - ->and('my-host')->toBeHostname(); // with hyphen + expect('example')->toBeHostname() + ->and('example.com')->toBeHostname() + ->and('sub.example.com')->toBeHostname() + ->and('my-host')->toBeHostname(); }); test('failures', function (): void { diff --git a/tests/Features/Expect/toBeMacAddress.php b/tests/Features/Expect/toBeMacAddress.php index 012c0b36..d5a438ad 100644 --- a/tests/Features/Expect/toBeMacAddress.php +++ b/tests/Features/Expect/toBeMacAddress.php @@ -6,8 +6,8 @@ use Pest\Exceptions\InvalidExpectationValue; use PHPUnit\Framework\ExpectationFailedException; test('pass', function (): void { - expect('00:1a:2b:3c:4d:5e')->toBeMacAddress() // colon-separated - ->and('00-1a-2b-3c-4d-5e')->toBeMacAddress() // hyphen-separated + expect('00:1a:2b:3c:4d:5e')->toBeMacAddress() + ->and('00-1a-2b-3c-4d-5e')->toBeMacAddress() ->and('ff:ff:ff:ff:ff:ff')->toBeMacAddress(); }); diff --git a/tests/Features/Expect/toBeUuid.php b/tests/Features/Expect/toBeUuid.php index c993ffb2..24138b22 100644 --- a/tests/Features/Expect/toBeUuid.php +++ b/tests/Features/Expect/toBeUuid.php @@ -10,14 +10,14 @@ test('failures with wrong type', function (): void { })->throws(InvalidExpectationValue::class, 'Invalid expectation value type. Expected [string].'); test('pass', function (): void { - expect('3cafb226-4326-11ee-a516-846993788c86')->toBeUuid(); // version 1 - expect('0000415c-4326-21ee-a700-846993788c86')->toBeUuid(); // version 2 - expect('3f703955-aaba-3e70-a3cb-baff6aa3b28f')->toBeUuid(); // version 3 - expect('ca0a8228-cdf6-41db-b34b-c2f31485796c')->toBeUuid(); // version 4 - expect('a35477ae-bfb1-5f2e-b5a4-4711594d855f')->toBeUuid(); // version 5 - expect('1ee43263-cf5a-6fd8-8f47-846993788c86')->toBeUuid(); // version 6 - expect('018a2bef-09f2-728c-becb-c3f569d91486')->toBeUuid(); // version 7 - expect('00112233-4455-8677-8899-aabbccddeeff')->toBeUuid(); // version 8 + expect('3cafb226-4326-11ee-a516-846993788c86')->toBeUuid() + ->and('0000415c-4326-21ee-a700-846993788c86')->toBeUuid() + ->and('3f703955-aaba-3e70-a3cb-baff6aa3b28f')->toBeUuid() + ->and('ca0a8228-cdf6-41db-b34b-c2f31485796c')->toBeUuid() + ->and('a35477ae-bfb1-5f2e-b5a4-4711594d855f')->toBeUuid() + ->and('1ee43263-cf5a-6fd8-8f47-846993788c86')->toBeUuid() + ->and('018a2bef-09f2-728c-becb-c3f569d91486')->toBeUuid() + ->and('00112233-4455-8677-8899-aabbccddeeff')->toBeUuid(); }); test('failures', function (): void { diff --git a/tests/Features/Expect/toHaveFileSystemPermissions.php b/tests/Features/Expect/toHaveFileSystemPermissions.php index b1e0877e..174d7fd7 100644 --- a/tests/Features/Expect/toHaveFileSystemPermissions.php +++ b/tests/Features/Expect/toHaveFileSystemPermissions.php @@ -1,5 +1,3 @@ toHaveMethodsDocumented() - ->and(ExampleTest::class)->not->toHaveMethodsDocumented(); + expect(ExampleTest::class)->not->toHaveMethodsDocumented(); }); it('fails 1', function (): void { diff --git a/tests/Features/Expect/unless.php b/tests/Features/Expect/unless.php index 1e9a6c76..9a5b98fb 100644 --- a/tests/Features/Expect/unless.php +++ b/tests/Features/Expect/unless.php @@ -41,15 +41,11 @@ it('skips with falsy', function (): void { expect($this->unlessObject) ->unless( 1, - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->unless( true, - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->foo->toEqual('foo') ->and(static::getCount())->toBe(1); @@ -69,9 +65,7 @@ it('skips with falsy closure condition', function (): void { expect($this->unlessObject) ->unless( fn (): string => '1', - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->foo->toEqual('foo') ->and(static::getCount())->toBe(1); diff --git a/tests/Features/Expect/when.php b/tests/Features/Expect/when.php index 3261a17c..118f5bc8 100644 --- a/tests/Features/Expect/when.php +++ b/tests/Features/Expect/when.php @@ -41,15 +41,11 @@ it('skips with falsy', function (): void { expect($this->whenObject) ->when( 0, - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->when( false, - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->foo->toEqual('foo') ->and(static::getCount())->toBe(1); @@ -69,9 +65,7 @@ it('skips with falsy closure condition', function (): void { expect($this->whenObject) ->when( fn (): string => '0', - function ($value) { - return $value->trueValue->toBeFalse(); // fails - } + fn ($value) => $value->trueValue->toBeFalse() ) ->foo->toEqual('foo') ->and(static::getCount())->toBe(1); diff --git a/tests/Features/Flaky.php b/tests/Features/Flaky.php index 389c76c1..beabd6ca 100644 --- a/tests/Features/Flaky.php +++ b/tests/Features/Flaky.php @@ -100,7 +100,6 @@ describe('lifecycle hooks with flaky', function (): void { } @unlink($file); - // After retry: setUp ran for initial + retry = setupCount should be 2 expect($this->setupCount)->toBe(2); })->flaky(tries: 3); }); @@ -123,7 +122,6 @@ describe('afterEach with flaky', function (): void { } @unlink($file); - // tearDown was called once between retries expect($state->teardownCount)->toBe(1); })->flaky(tries: 3); }); @@ -184,9 +182,6 @@ it('works with throws and flaky', function (): void { })->throws(RuntimeException::class, 'Expected exception')->flaky(tries: 2); it('does not retry expected exceptions', function (): void { - // If flaky retried this, the temp file counter would reach 2 and - // the test would NOT throw — causing PHPUnit's "expected exception - // was not raised" to fail. The test passes only if we don't retry. $file = sys_get_temp_dir().'/pest_flaky_expected'; $count = file_exists($file) ? (int) file_get_contents($file) : 0; file_put_contents($file, (string) ++$count); @@ -194,8 +189,6 @@ it('does not retry expected exceptions', function (): void { if ($count >= 2) { @unlink($file); - // Second call means flaky retried — don't throw, which will FAIL - // because PHPUnit expects the exception return; } @@ -229,18 +222,16 @@ it('does not leak mock objects between retries', function (): void { file_put_contents($file, (string) ++$count); if ($count < 2) { - @unlink(sys_get_temp_dir().'/pest_flaky_mock'); // clean before retry writes again + @unlink(sys_get_temp_dir().'/pest_flaky_mock'); file_put_contents($file, '1'); throw new Exception('Flaky mock failure'); } @unlink($file); - // Call mock — only the mock from THIS attempt should be verified expect($mock->count())->toBe(1); })->flaky(tries: 3); it('does not stop retrying when snapshot changes are absent', function (): void { - // Ensures the snapshot guard only triggers when __snapshotChanges is non-empty $file = sys_get_temp_dir().'/pest_flaky_no_snapshot'; $count = file_exists($file) ? (int) file_get_contents($file) : 0; file_put_contents($file, (string) ++$count); @@ -294,6 +285,5 @@ it('preserves output between retries when no output expectation is set', functio } @unlink($file); - // Output from attempt 1 is still in the buffer $this->expectOutputString('from attempt 1'); })->flaky(tries: 3); diff --git a/tests/Features/Tia.php b/tests/Features/Tia.php index 30df425d..38894109 100644 --- a/tests/Features/Tia.php +++ b/tests/Features/Tia.php @@ -26,7 +26,6 @@ it('does not run user hooks when replaying cached skipped and incomplete results $graph = new Graph($projectRoot); $graph->setFingerprint(Fingerprint::compute($projectRoot)); $graph->setRecordedAtSha($branch, $sha); - // Hashes the working tree as it stands, so the replay sees nothing as changed. $graph->setLastRunTree($branch, $changedFiles->snapshotTree($changedFiles->since($sha) ?? [])); $graph->markKnownTestFiles([$fixture]); $graph->setResult($branch, $id('replayed pass'), 0, '', 0.01, 1, $fixture); @@ -64,7 +63,6 @@ it('does not run user hooks when replaying cached skipped and incomplete results $output = removeAnsiEscapeSequences($process->getOutput().$process->getErrorOutput()); - // Both hooks throw, so the run stays green only if neither one ran. expect($output)->toContain('3 replayed') ->and($output)->not->toContain('must not run for replayed tests') ->and($output)->toContain('1 incomplete, 1 skipped, 1 passed') diff --git a/tests/Features/Tia/LivewireComponents.php b/tests/Features/Tia/LivewireComponents.php index c90746c2..a10d58ed 100644 --- a/tests/Features/Tia/LivewireComponents.php +++ b/tests/Features/Tia/LivewireComponents.php @@ -8,12 +8,6 @@ afterEach(function (): void { Project::destroyAll(); }); -/** - * Livewire never renders a single- or multi-file component source directly: it - * compiles it into `/livewire/{views,classes}/.` and - * renders that, so the recorded graph only ever holds the generated path. These - * helpers seed the graph the way a real recording run would leave it. - */ function tiaLivewireHash(string $sourcePath): string { return substr(md5(DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $sourcePath)), 0, 8); @@ -44,7 +38,6 @@ test('a changed single-file component selects only the tests that rendered it, a $hash = tiaLivewireHash('resources/views/pages/⚡orders.blade.php'); - // The same component, compiled once per parallel worker. tiaSeedWithGeneratedViews($project, [ 'storage/framework/views/test_1/livewire/views/'.$hash.'.blade.php' => 'tests/Unit/GreeterTest.php', 'storage/framework/views/test_2/livewire/views/'.$hash.'.blade.php' => 'tests/Unit/CalculatorTest.php', @@ -60,20 +53,18 @@ test('a changed single-file component selects only the tests that rendered it, a ->and($result->replayed())->toBe(2, $result->describe()); })->skipOnWindows(); -test('a changed multi-file component class selects the tests that rendered the component', function (): void { +test('a changed multi-file component asset selects the tests that rendered the component', function (): void { $project = Project::make('master', 'livewire-watch'); $project->write('resources/views/components/⚡counter/counter.blade.php', "
{{ \$count }}
\n"); $project->write('resources/views/components/⚡counter/counter.php', "write('resources/views/components/⚡counter/counter.js', "export default 1\n"); $project->git()->commit('add the component'); - // A multi-file component is compiled under the hash of its *directory*, and - // its class is what PHP executes — so the class sibling, not the view, is - // what the graph can be reached through. tiaSeedWithGeneratedViews($project, [ 'storage/framework/views/livewire/classes/'.tiaLivewireHash('resources/views/components/⚡counter').'.php' => 'tests/Unit/GreeterTest.php', ]); - $project->write('resources/views/components/⚡counter/counter.php', "write('resources/views/components/⚡counter/counter.js', "export default 2\n"); $project->snapshot(); $result = $project->pest('--tia'); diff --git a/tests/Fixtures/Arch/ToUseStrictTypes/HasStrictTypeWithCommentsAbove.php b/tests/Fixtures/Arch/ToUseStrictTypes/HasStrictTypeWithCommentsAbove.php index fc4703ff..747c625f 100644 --- a/tests/Fixtures/Arch/ToUseStrictTypes/HasStrictTypeWithCommentsAbove.php +++ b/tests/Fixtures/Arch/ToUseStrictTypes/HasStrictTypeWithCommentsAbove.php @@ -2,8 +2,6 @@ /** @noinspection PhpUnused */ -// some other comment - declare(strict_types=1); namespace Tests\Fixtures\Arch\ToUseStrictTypes; diff --git a/tests/Fixtures/Tia/overlays/livewire-watch/tests/Pest.php b/tests/Fixtures/Tia/overlays/livewire-watch/tests/Pest.php index ce847cfb..5e5ce61e 100644 --- a/tests/Fixtures/Tia/overlays/livewire-watch/tests/Pest.php +++ b/tests/Fixtures/Tia/overlays/livewire-watch/tests/Pest.php @@ -5,8 +5,4 @@ declare(strict_types=1); require_once __DIR__.'/../app/Calculator.php'; require_once __DIR__.'/../app/Greeter.php'; -// Stands in for the built-in Laravel/Livewire watch defaults, which are not -// applicable here because the fixture installs neither package. Without the -// generated-view mapping, every changed Blade file lands on this rule and -// invalidates the whole suite — which is exactly what issue #1808 reported. pest()->tia()->watch(['resources/views/**' => 'tests']); diff --git a/tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php b/tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php index c829124d..28497a1e 100644 --- a/tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php +++ b/tests/PHPUnit/CustomAffixes/@#$%^&()-_=+.php @@ -1,10 +1,3 @@ assertTrue(true); diff --git a/tests/PHPUnit/CustomTestCase/ExecutedTest.php b/tests/PHPUnit/CustomTestCase/ExecutedTest.php index 754f6712..4ad45f8b 100644 --- a/tests/PHPUnit/CustomTestCase/ExecutedTest.php +++ b/tests/PHPUnit/CustomTestCase/ExecutedTest.php @@ -20,5 +20,3 @@ class ExecutedTest extends TestCase assertTrue(true); } } - -// register_shutdown_function(fn () => assertTrue(ExecutedTest::$executed)); diff --git a/tests/Pest.php b/tests/Pest.php index 156431f3..e9433dc8 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -11,17 +11,14 @@ pest()->project()->github('pestphp/pest'); pest()->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder')->use(CustomTestCaseInSubFolder::class); -// test case for all the directories inside PHPUnit/GlobPatternTests/SubFolder/ pest()->in('PHPUnit/GlobPatternTests/SubFolder/*')->extend(CustomTestCase::class); -// test case for all the files that end with AsPattern.php inside PHPUnit/GlobPatternTests/SubFolder2/ pest()->in('PHPUnit/GlobPatternTests/SubFolder2/*AsPattern.php')->use(CustomTestCase::class); pest()->in('Visual')->group('integration'); pest()->in('Features/Tia')->group('integration', 'tia'); -// NOTE: global test value container to be mutated and checked across files, as needed $_SERVER['globalHook'] = (object) ['calls' => (object) ['beforeAll' => 0, 'afterAll' => 0]]; pest() @@ -90,8 +87,8 @@ function removeAnsiEscapeSequences(string $input): ?string { return preg_replace( [ - '#\\x1b[[][^A-Za-z]*[A-Za-z]#', // CSI (colors, cursor, etc.) - '#\\x1b\\]8;[^\\x1b\\x07]*(?:\\x1b\\\\|\\x07)#', // OSC 8 hyperlinks + '#\\x1b[[][^A-Za-z]*[A-Za-z]#', + '#\\x1b\\]8;[^\\x1b\\x07]*(?:\\x1b\\\\|\\x07)#', ], '', $input, diff --git a/tests/Unit/Plugins/Tia/FileState.php b/tests/Unit/Plugins/Tia/FileState.php index a03017a5..10822b22 100644 --- a/tests/Unit/Plugins/Tia/FileState.php +++ b/tests/Unit/Plugins/Tia/FileState.php @@ -34,7 +34,6 @@ describe('keysWithPrefix()', function (): void { $state = new FileState($this->root); $state->write('worker-edges-a.json', '{}'); - // Simulate another process mid-write: its temp file exists but has not been renamed yet. file_put_contents($this->root.'/worker-edges-b.json.'.bin2hex(random_bytes(4)).'.tmp', '{'); expect($state->keysWithPrefix('worker-edges-'))->toBe(['worker-edges-a.json']); diff --git a/tests/Unit/Plugins/Tia/Graph.php b/tests/Unit/Plugins/Tia/Graph.php index 36a19333..19ea5ca0 100644 --- a/tests/Unit/Plugins/Tia/Graph.php +++ b/tests/Unit/Plugins/Tia/Graph.php @@ -232,6 +232,26 @@ describe('Livewire component views', function (): void { 'index convention' => ['resources/views/components/post/⚡index', 'resources/views/components/post/⚡index/index.blade.php'], ]); + it('maps a changed MFC sibling through the component directory hash', function (string $sibling, string $generated): void { + $componentDirectory = 'resources/views/components/post/⚡create'; + $hash = substr(md5(DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $componentDirectory)), 0, 8); + + mkdir($this->projectRoot.'/'.$componentDirectory, 0755, true); + file_put_contents($this->projectRoot.'/'.$componentDirectory.'/create.blade.php', '
Component
'); + file_put_contents($this->projectRoot.'/'.$componentDirectory.'/create.php', 'projectRoot.'/'.$componentDirectory.'/create.js', '// js'); + + $graph = new Graph($this->projectRoot); + $graph->link('tests/Feature/ComponentTest.php', 'storage/framework/views/test_7/livewire/'.str_replace('{hash}', $hash, $generated)); + $graph->link('tests/Feature/UnrelatedTest.php', 'storage/framework/views/test_8/livewire/views/deadbeef.blade.php'); + + expect($graph->affected([$componentDirectory.'/'.$sibling]))->toBe(['tests/Feature/ComponentTest.php']); + })->with([ + 'class sibling via the generated class' => ['create.php', 'classes/{hash}.php'], + 'class sibling via the generated view' => ['create.php', 'views/{hash}.blade.php'], + 'asset sibling via the generated view' => ['create.js', 'views/{hash}.blade.php'], + ]); + it('preserves direct view edges for class-based components', function (): void { $viewPath = 'resources/views/livewire/create-post.blade.php'; @@ -279,7 +299,6 @@ describe('markKnownTestFiles()', function (): void { $graph->markKnownTestFiles(['tests/Feature/UserTest.php']); - // The pre-existing edge survives — the test still depends on the source file. $affected = $graph->affected(['app/Models/User.php']); expect($affected)->toContain('tests/Feature/UserTest.php'); diff --git a/tests/Unit/Plugins/Tia/IsEnabledForRun.php b/tests/Unit/Plugins/Tia/IsEnabledForRun.php index b65ab479..8c818d44 100644 --- a/tests/Unit/Plugins/Tia/IsEnabledForRun.php +++ b/tests/Unit/Plugins/Tia/IsEnabledForRun.php @@ -3,11 +3,6 @@ use Pest\Plugins\Tia; test('does not throw when an integer --random-order-seed is passed as a separate argv element', function (): void { - // Mirrors the parallel worker argv (see bin/worker.php), where - // `--random-order-seed` and its value arrive as separate items and the - // seed value is an int rather than a string. Regression test for the - // str_starts_with() TypeError in Tia::argumentPresent() — the same class - // of bug as #1206, which was only fixed in HandleArguments. $arguments = ['--order-by=random', '--random-order-seed', 1782350398]; expect(Tia::isEnabledForRun($arguments))->toBeFalse(); diff --git a/tests/Unit/Plugins/Tia/Recorder.php b/tests/Unit/Plugins/Tia/Recorder.php index d5a8acf4..0242d12d 100644 --- a/tests/Unit/Plugins/Tia/Recorder.php +++ b/tests/Unit/Plugins/Tia/Recorder.php @@ -38,7 +38,6 @@ describe('activateLinkTracking()', function (): void { $recorder->linkSource('/project/resources/views/welcome.blade.php'); $recorder->endTest(); - // A second test must start cleanly — endTest resets state even with no driver. $recorder->beginTest('Some\Missing\TestClass', 'second', '/project/tests/Feature/SecondTest.php'); $recorder->linkSource('/project/resources/views/about.blade.php'); $recorder->endTest(); diff --git a/tests/Unit/Plugins/Tia/ResultKey.php b/tests/Unit/Plugins/Tia/ResultKey.php index 97665467..2ed82c1c 100644 --- a/tests/Unit/Plugins/Tia/ResultKey.php +++ b/tests/Unit/Plugins/Tia/ResultKey.php @@ -78,9 +78,6 @@ it('keys a result per dataset row rather than per method', function (): void { $collector->testSkipped('the fake driver does not report balances'); $collector->finishTest(); - // Without the dataset in the key both rows write to `Class::method`, so the - // second one overwrites the first and a replay hands every row the same - // status — a passing row reported as skipped, or a failing one as passed. expect(array_keys($collector->all()))->toBe([ 'Tests\Feature\OrderTest::it prices an order#opp', 'Tests\Feature\OrderTest::it prices an order#fake', diff --git a/tests/Unit/Plugins/Tia/TableExtractor.php b/tests/Unit/Plugins/Tia/TableExtractor.php index 9ee59c68..879f1509 100644 --- a/tests/Unit/Plugins/Tia/TableExtractor.php +++ b/tests/Unit/Plugins/Tia/TableExtractor.php @@ -48,10 +48,6 @@ describe('fromSql()', function (): void { }); it('does not leak int keys for numeric identifiers', function (): void { - // `substring(x FROM 1 FOR 3)` is standard SQL, and the `1` matches the - // FROM pattern. Collecting names as array keys makes PHP coerce the - // numeric string to an int, which then violates the declared - // list and blows up Recorder::linkTable(string). expect(TableExtractor::fromSql('select substring(name from 1 for 3) from users')) ->each->toBeString(); }); @@ -99,9 +95,6 @@ describe('fromMigrationSource()', function (): void { }); it('does not leak int keys for numeric table names', function (): void { - // A table named `123` is a legal quoted identifier. Collecting names as - // array keys makes PHP coerce it to an int, breaking the declared - // list, so it must survive as a string rather than be dropped. expect(TableExtractor::fromMigrationSource("DB::table('123')->insert([]);")) ->toBe(['123']); }); diff --git a/tests/Unit/Plugins/Tia/TestPaths.php b/tests/Unit/Plugins/Tia/TestPaths.php index 69190eb6..a68d5bc2 100644 --- a/tests/Unit/Plugins/Tia/TestPaths.php +++ b/tests/Unit/Plugins/Tia/TestPaths.php @@ -57,9 +57,6 @@ describe('isTestFile()', function (): void { ->and($paths->isTestFile('tests/Unit/Helper.php'))->toBeTrue(); }); - // Regression: a suffix of "Test.php" must match "ExampleTest.php". A previous - // normalisation prepended a dot (".Test.php"), which matched nothing and left - // edited tests looking unchanged to TIA, replaying stale results. it('does not require a dot before the suffix', function (): void { $paths = new TestPaths( directories: ['tests/Unit'], diff --git a/tests/Visual/Collision.php b/tests/Visual/Collision.php index 3ab4c5aa..cabb033e 100644 --- a/tests/Visual/Collision.php +++ b/tests/Visual/Collision.php @@ -28,5 +28,4 @@ test('collision', function (array $arguments): void { expect(implode("\n", $outputContent))->toMatchSnapshot(); })->with([ [['']], - // [['--parallel']], ])->skipOnWindows(); diff --git a/tests/Visual/JUnit.php b/tests/Visual/JUnit.php index 29f1e57a..5e1af647 100644 --- a/tests/Visual/JUnit.php +++ b/tests/Visual/JUnit.php @@ -16,7 +16,6 @@ $run = function () { $rawXmlContent = file_get_contents($junitLogFile); unlink($junitLogFile); - // convert xml to array try { $xml = new SimpleXMLElement(preg_replace("/(<\/?)(\w+):([^>]*>)/", '$1$2$3', $rawXmlContent)); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 83a58b4b..674b18b1 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -26,13 +26,13 @@ test('parallel', function () use ($run): void { $file = file_get_contents(__FILE__); $file = preg_replace( '/\$expected = \'.*?\';/', - "\$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1540 passed (3343 assertions)';", + "\$expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 26 skipped, 1544 passed (3350 assertions)';", $file, ); file_put_contents(__FILE__, $file); } - $expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1540 passed (3343 assertions)'; + $expected = '1 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 26 skipped, 1544 passed (3350 assertions)'; expect($output) ->toContain("Tests: {$expected}")