Skip to content

Commit b6cedb9

Browse files
Fix CS/WS issues
1 parent 48a97a7 commit b6cedb9

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

src/Framework/TestBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function buildDataProviderTestSuite(string $methodName, string $classNam
9595
foreach ($data as $_dataName => $_data) {
9696
$_test = new $className($methodName);
9797

98-
$_test->setData($_dataName, $_data->getData());
98+
$_test->setData($_dataName, $_data->value());
9999

100100
$this->configureTestCase(
101101
$_test,

src/Metadata/Api/DataProvider.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ public function providedData(string $className, string $methodName): ?array
8787
$testMethodIsNonVariadic = !$method->isVariadic();
8888

8989
foreach ($data as $key => $providedData) {
90-
$value = $providedData->getData();
90+
$value = $providedData->value();
9191

9292
if (!is_array($value)) {
9393
throw new InvalidDataProviderException(
9494
sprintf(
9595
'Data set %s provided by %s is invalid, expected array but got %s',
9696
$this->formatKey($key),
97-
$providedData->getProviderLabel(),
97+
$providedData->label(),
9898
get_debug_type($value),
9999
),
100100
);
@@ -117,7 +117,7 @@ public function providedData(string $className, string $methodName): ?array
117117
sprintf(
118118
'Data set %s provided by %s has more arguments (%d) than the test method accepts (%d)',
119119
$this->formatKey($key),
120-
$providedData->getProviderLabel(),
120+
$providedData->label(),
121121
count($value),
122122
$testMethodNumberOfParameters,
123123
),
@@ -140,7 +140,11 @@ private function dataProvidedByMethods(string $className, string $methodName, Me
140140
{
141141
$testMethod = new Event\Code\ClassMethod($className, $methodName);
142142
$methodsCalled = [];
143-
$result = [];
143+
144+
/**
145+
* @var array<ProvidedData> $result
146+
*/
147+
$result = [];
144148

145149
foreach ($dataProvider as $_dataProvider) {
146150
assert($_dataProvider instanceof DataProviderMetadata);
@@ -216,7 +220,7 @@ private function dataProvidedByMethods(string $className, string $methodName, Me
216220
sprintf(
217221
'The key "%s" has already been defined by provider %s',
218222
$key,
219-
$result[$key]->getProviderLabel(),
223+
$result[$key]->label(),
220224
),
221225
);
222226
}
@@ -261,7 +265,7 @@ private function dataProvidedByMetadata(MetadataCollection $testWith): array
261265
sprintf(
262266
'The key "%s" has already been defined by %s',
263267
$key,
264-
$result[$key]->getProviderLabel(),
268+
$result[$key]->label(),
265269
),
266270
);
267271
}

src/Metadata/Api/ProvidedData.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,38 @@
99
*/
1010
namespace PHPUnit\Metadata\Api;
1111

12+
/**
13+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
14+
*
15+
* @internal This class is not covered by the backward compatibility promise for PHPUnit
16+
*/
1217
final readonly class ProvidedData
1318
{
14-
public function __construct(
15-
private string $providerLabel,
16-
private mixed $data
17-
) {
19+
/**
20+
* @var non-empty-string
21+
*/
22+
private string $label;
23+
private mixed $value;
24+
25+
/**
26+
* @param non-empty-string $label
27+
*/
28+
public function __construct(string $label, mixed $value)
29+
{
30+
$this->label = $label;
31+
$this->value = $value;
1832
}
1933

20-
public function getData(): mixed
34+
/**
35+
* @return non-empty-string
36+
*/
37+
public function label(): string
2138
{
22-
return $this->data;
39+
return $this->label;
2340
}
2441

25-
public function getProviderLabel(): string
42+
public function value(): mixed
2643
{
27-
return $this->providerLabel;
44+
return $this->value;
2845
}
2946
}

tests/unit/Metadata/Api/DataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private function getRawDataFromProvidedData(array $providedData): array
220220
$raw = [];
221221

222222
foreach ($providedData as $key => $data) {
223-
$raw[$key] = $data->getData();
223+
$raw[$key] = $data->value();
224224
}
225225

226226
return $raw;

0 commit comments

Comments
 (0)