Skip to content

Commit 4a33370

Browse files
committed
CS
1 parent d768453 commit 4a33370

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
treatPhpDocTypesAsCertain: false
3+
ignoreErrors:
4+
- '#Cannot access property \$args on PhpParser\\Node\|null#'
5+
- '#Call to an undefined method PhpParser\\Node\\Expr\|PhpParser\\Node\\Name\:\:toString\(\)#'
6+
- '#Parameter \#1 \$array of function array_flip expects array, array\<int, int\|string\>\|int\|string given\.#'
7+
8+
excludes_analyse:
9+
- src/TestUtils/WorkshopExerciseTest.php

src/Exercise/HaveTheLastSay.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,18 @@ public function getArgs(): array
6262

6363
file_put_contents(
6464
$file,
65-
implode("\n", array_map(
66-
fn ($row) => implode("|", $row),
67-
$this->getRandomCountries($countries))
68-
)
65+
implode("\n", array_map(fn ($row) => implode("|", $row), $this->getRandomCountries($countries)))
6966
);
7067

7168
return [
7269
[$file]
7370
];
7471
}
7572

73+
/**
74+
* @param array<array{0: string, 1: string}> $countries
75+
* @return array<array{0: string, 1: string}> $countries
76+
*/
7677
private function getRandomCountries(array $countries): array
7778
{
7879
return array_intersect_key(
@@ -140,7 +141,10 @@ public function check(Input $input): ResultInterface
140141
}
141142

142143
if (!$funcCall->args[1]->name) {
143-
return Failure::fromNameAndReason($this->getName(), 'The second positional argument should not be specified');
144+
return Failure::fromNameAndReason(
145+
$this->getName(),
146+
'The second positional argument should not be specified'
147+
);
144148
}
145149

146150
if ($funcCall->args[1]->name->name !== 'separator') {

test/Exercise/HaveTheLastSayTest.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public function testWithNoStreamArgument(): void
3838

3939
$this->assertVerifyWasNotSuccessful();
4040

41-
$this->assertResultsHasFailure(Failure::class, 'The stream argument must be specified using a positional parameter');
41+
$this->assertResultsHasFailure(
42+
Failure::class,
43+
'The stream argument must be specified using a positional parameter'
44+
);
4245
}
4346

4447
public function testWithStreamAsNamedArgument(): void
@@ -47,7 +50,10 @@ public function testWithStreamAsNamedArgument(): void
4750

4851
$this->assertVerifyWasNotSuccessful();
4952

50-
$this->assertResultsHasFailure(Failure::class, 'The stream argument must be specified using a positional parameter');
53+
$this->assertResultsHasFailure(
54+
Failure::class,
55+
'The stream argument must be specified using a positional parameter'
56+
);
5157
}
5258

5359
public function testWithSecondArgumentSpecified(): void
@@ -56,7 +62,10 @@ public function testWithSecondArgumentSpecified(): void
5662

5763
$this->assertVerifyWasNotSuccessful();
5864

59-
$this->assertResultsHasFailure(Failure::class, 'The second positional argument should not be specified');
65+
$this->assertResultsHasFailure(
66+
Failure::class,
67+
'The second positional argument should not be specified'
68+
);
6069
}
6170

6271
public function testWithMoreThanTwoArguments(): void
@@ -65,7 +74,10 @@ public function testWithMoreThanTwoArguments(): void
6574

6675
$this->assertVerifyWasNotSuccessful();
6776

68-
$this->assertResultsHasFailure(Failure::class, 'You should only specify the stream and separator arguments, no others');
77+
$this->assertResultsHasFailure(
78+
Failure::class,
79+
'You should only specify the stream and separator arguments, no others'
80+
);
6981
}
7082

7183
public function testWithNoSeparatorArgumentSpecified(): void
@@ -74,7 +86,10 @@ public function testWithNoSeparatorArgumentSpecified(): void
7486

7587
$this->assertVerifyWasNotSuccessful();
7688

77-
$this->assertResultsHasFailure(Failure::class, 'The separator argument has not been specified');
89+
$this->assertResultsHasFailure(
90+
Failure::class,
91+
'The separator argument has not been specified'
92+
);
7893
}
7994

8095
public function testWithWrongNamedArgument(): void
@@ -83,7 +98,10 @@ public function testWithWrongNamedArgument(): void
8398

8499
$this->assertVerifyWasNotSuccessful();
85100

86-
$this->assertResultsHasFailure(Failure::class, 'A named argument has been used, but not for the separator argument');
101+
$this->assertResultsHasFailure(
102+
Failure::class,
103+
'A named argument has been used, but not for the separator argument'
104+
);
87105
}
88106

89107
public function testWithNoFgetCsv(): void

0 commit comments

Comments
 (0)