diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml index c8e5934272a..d8e0e9e17ea 100644 --- a/.psalm/baseline.xml +++ b/.psalm/baseline.xml @@ -126,9 +126,6 @@ - - $data - $data @@ -382,11 +379,6 @@ getMethod - valueObjectForEvents - valueObjectForEvents - valueObjectForEvents - valueObjectForEvents - valueObjectForEvents $outputBufferingLevel diff --git a/src/Event/Exception/MoreThanOneDataSetFromDataProviderException.php b/src/Event/Exception/MoreThanOneDataSetFromDataProviderException.php deleted file mode 100644 index 0d26b7f6cb8..00000000000 --- a/src/Event/Exception/MoreThanOneDataSetFromDataProviderException.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace PHPUnit\Event\TestData; - -use PHPUnit\Event\Exception; -use RuntimeException; - -/** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - */ -final class MoreThanOneDataSetFromDataProviderException extends RuntimeException implements Exception -{ -} diff --git a/src/Event/Value/Test/TestData/TestDataCollection.php b/src/Event/Value/Test/TestData/TestDataCollection.php index 55012259767..8f8047a5319 100644 --- a/src/Event/Value/Test/TestData/TestDataCollection.php +++ b/src/Event/Value/Test/TestData/TestDataCollection.php @@ -28,20 +28,19 @@ final class TestDataCollection implements Countable, IteratorAggregate /** * @psalm-param list $data - * - * @throws MoreThanOneDataSetFromDataProviderException */ public static function fromArray(array $data): self { return new self(...$data); } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function __construct(TestData ...$data) { - $this->ensureNoMoreThanOneDataFromDataProvider($data); + foreach ($data as $_data) { + if ($_data->isFromDataProvider()) { + $this->fromDataProvider = $_data; + } + } $this->data = $data; } @@ -83,22 +82,4 @@ public function getIterator(): TestDataCollectionIterator { return new TestDataCollectionIterator($this); } - - /** - * @psalm-param list $data - * - * @throws MoreThanOneDataSetFromDataProviderException - */ - private function ensureNoMoreThanOneDataFromDataProvider(array $data): void - { - foreach ($data as $_data) { - if ($_data->isFromDataProvider()) { - if ($this->fromDataProvider !== null) { - throw new MoreThanOneDataSetFromDataProviderException; - } - - $this->fromDataProvider = $_data; - } - } - } } diff --git a/src/Event/Value/Test/TestDoxBuilder.php b/src/Event/Value/Test/TestDoxBuilder.php index 2c17469815d..edad458748c 100644 --- a/src/Event/Value/Test/TestDoxBuilder.php +++ b/src/Event/Value/Test/TestDoxBuilder.php @@ -9,7 +9,6 @@ */ namespace PHPUnit\Event\Code; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Framework\TestCase; use PHPUnit\Logging\TestDox\NamePrettifier; @@ -18,9 +17,6 @@ */ final class TestDoxBuilder { - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ public static function fromTestCase(TestCase $testCase): TestDox { $prettifier = new NamePrettifier; diff --git a/src/Event/Value/Test/TestMethodBuilder.php b/src/Event/Value/Test/TestMethodBuilder.php index 8d413f63c9c..8a276fec0bd 100644 --- a/src/Event/Value/Test/TestMethodBuilder.php +++ b/src/Event/Value/Test/TestMethodBuilder.php @@ -15,7 +15,6 @@ use PHPUnit\Event\Facade as EventFacade; use PHPUnit\Event\TestData\DataFromDataProvider; use PHPUnit\Event\TestData\DataFromTestDependency; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Event\TestData\TestDataCollection; use PHPUnit\Framework\TestCase; use PHPUnit\Metadata\Parser\Registry as MetadataRegistry; @@ -27,9 +26,6 @@ */ final class TestMethodBuilder { - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ public static function fromTestCase(TestCase $testCase): TestMethod { $methodName = $testCase->name(); @@ -63,9 +59,6 @@ public static function fromCallStack(): TestMethod throw new NoTestCaseObjectOnCallStackException; } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private static function dataFor(TestCase $testCase): TestDataCollection { $testData = []; diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 6c298e6935c..4b420f58c96 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -56,7 +56,6 @@ use DeepCopy\DeepCopy; use PHPUnit\Event; use PHPUnit\Event\NoPreviousThrowableException; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Event\TestData\NoDataSetFromDataProviderException; use PHPUnit\Framework\Constraint\Exception as ExceptionConstraint; use PHPUnit\Framework\Constraint\ExceptionCode; @@ -291,7 +290,6 @@ final public function status(): TestStatus * @throws \SebastianBergmann\Template\InvalidArgumentException * @throws CodeCoverageException * @throws Exception - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoDataSetFromDataProviderException * @throws NoPreviousThrowableException * @throws ProcessIsolationException @@ -864,8 +862,6 @@ final public function setData(int|string $dataName, array $data): void /** * @internal This method is not covered by the backward compatibility promise for PHPUnit - * - * @throws MoreThanOneDataSetFromDataProviderException */ final public function valueObjectForEvents(): Event\Code\TestMethod { @@ -1618,7 +1614,6 @@ private function handleDependencies(): bool /** * @throws Exception - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ private function markErrorForInvalidDependency(?ExecutionOrderDependency $dependency = null): void @@ -1642,9 +1637,6 @@ private function markErrorForInvalidDependency(?ExecutionOrderDependency $depend $this->status = TestStatus::error($message); } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function markSkippedForMissingDependency(ExecutionOrderDependency $dependency): void { $message = sprintf( @@ -1668,9 +1660,6 @@ private function startOutputBuffering(): void $this->outputBufferingLevel = ob_get_level(); } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function stopOutputBuffering(): bool { $bufferingLevel = ob_get_level(); @@ -1716,9 +1705,6 @@ private function snapshotGlobalState(): void $this->snapshot = $snapshot; } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function restoreGlobalState(): void { if (!$this->snapshot instanceof Snapshot) { @@ -1783,9 +1769,6 @@ private function createGlobalStateSnapshot(bool $backupGlobals): Snapshot ); } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after): void { $backupGlobals = $this->backupGlobals === null || $this->backupGlobals; @@ -1813,9 +1796,6 @@ private function compareGlobalStateSnapshots(Snapshot $before, Snapshot $after): } } - /** - * @throws MoreThanOneDataSetFromDataProviderException - */ private function compareGlobalStateSnapshotPart(array $before, array $after, string $header): void { if ($before != $after) { @@ -1986,7 +1966,6 @@ private function isCallableTestMethod(string $dependency): bool /** * @throws Exception * @throws ExpectationFailedException - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ private function performAssertionsOnOutput(): void diff --git a/src/Framework/TestRunner.php b/src/Framework/TestRunner.php index e5f5b033bf8..97ad391828d 100644 --- a/src/Framework/TestRunner.php +++ b/src/Framework/TestRunner.php @@ -25,7 +25,6 @@ use AssertionError; use PHPUnit\Event; use PHPUnit\Event\NoPreviousThrowableException; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Event\TestData\NoDataSetFromDataProviderException; use PHPUnit\Metadata\Api\CodeCoverage as CodeCoverageMetadataApi; use PHPUnit\Metadata\Parser\Registry as MetadataRegistry; @@ -61,7 +60,6 @@ public function __construct() * @throws \PHPUnit\Runner\Exception * @throws \SebastianBergmann\CodeCoverage\InvalidArgumentException * @throws CodeCoverageException - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoDataSetFromDataProviderException * @throws UnintentionallyCoveredCodeException */ @@ -247,7 +245,6 @@ public function run(TestCase $test): void * @throws \PHPUnit\Util\Exception * @throws \SebastianBergmann\Template\InvalidArgumentException * @throws Exception - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException * @throws ProcessIsolationException * @throws StaticAnalysisCacheNotConfiguredException diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 15a144cfb2f..84cdb6ea4c3 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -463,7 +463,6 @@ public function isForTestClass(): bool } /** - * @throws \PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException * @throws Exception */ protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method): void diff --git a/src/Metadata/Api/DataProvider.php b/src/Metadata/Api/DataProvider.php index 420b56ebef8..8c3540a8981 100644 --- a/src/Metadata/Api/DataProvider.php +++ b/src/Metadata/Api/DataProvider.php @@ -27,15 +27,11 @@ use function substr; use function trim; use PHPUnit\Event; -use PHPUnit\Event\Code\TestMethod; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; -use PHPUnit\Event\TestData\TestDataCollection; use PHPUnit\Framework\InvalidDataProviderException; use PHPUnit\Metadata\DataProvider as DataProviderMetadata; use PHPUnit\Metadata\MetadataCollection; use PHPUnit\Metadata\Parser\Registry as MetadataRegistry; use PHPUnit\Metadata\TestWith; -use PHPUnit\Util\Reflection; use ReflectionClass; use ReflectionMethod; use Throwable; diff --git a/src/Runner/CodeCoverage.php b/src/Runner/CodeCoverage.php index 55a8df84a7e..c726ed1b8ca 100644 --- a/src/Runner/CodeCoverage.php +++ b/src/Runner/CodeCoverage.php @@ -12,7 +12,6 @@ use function file_put_contents; use function sprintf; use PHPUnit\Event\Facade as EventFacade; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Event\TestData\NoDataSetFromDataProviderException; use PHPUnit\Framework\TestCase; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; @@ -140,7 +139,6 @@ public function driver(): Driver } /** - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoDataSetFromDataProviderException */ public function start(TestCase $test): void diff --git a/src/Runner/Filter/TestIdFilterIterator.php b/src/Runner/Filter/TestIdFilterIterator.php index 6c44289605b..33fbd351208 100644 --- a/src/Runner/Filter/TestIdFilterIterator.php +++ b/src/Runner/Filter/TestIdFilterIterator.php @@ -10,7 +10,6 @@ namespace PHPUnit\Runner\Filter; use function in_array; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Event\TestData\NoDataSetFromDataProviderException; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; @@ -54,7 +53,7 @@ public function accept(): bool try { return in_array($test->valueObjectForEvents()->id(), $this->testIds, true); - } catch (MoreThanOneDataSetFromDataProviderException|NoDataSetFromDataProviderException) { + } catch (NoDataSetFromDataProviderException) { return false; } } diff --git a/src/Util/PHP/AbstractPhpProcess.php b/src/Util/PHP/AbstractPhpProcess.php index 7223d695632..1a7b5a9d7a3 100644 --- a/src/Util/PHP/AbstractPhpProcess.php +++ b/src/Util/PHP/AbstractPhpProcess.php @@ -27,7 +27,6 @@ use PHPUnit\Event\Code\ThrowableBuilder; use PHPUnit\Event\Facade; use PHPUnit\Event\NoPreviousThrowableException; -use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Exception; use PHPUnit\Framework\Test; @@ -132,7 +131,6 @@ public function getEnv(): array * * @throws \PHPUnit\Runner\Exception * @throws Exception - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ public function runTestJob(string $job, Test $test, string $processResultFile): void @@ -226,7 +224,6 @@ protected function settingsToParameters(array $settings): string /** * @throws \PHPUnit\Runner\Exception * @throws Exception - * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ private function processChildResult(Test $test, string $stdout, string $stderr): void