Skip to content

Commit 04863a4

Browse files
committed
fix test action
1 parent c598221 commit 04863a4

8 files changed

Lines changed: 37 additions & 45 deletions

File tree

β€Ž.docker/Dockerfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.2
1+
FROM php:8.3
22

33
COPY dev.sh /tmp/library-scripts/
44

β€Ž.github/workflows/test.ymlβ€Ž

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,26 @@ jobs:
4343
run: composer install --prefer-dist --no-progress
4444

4545
- name: Run the unit tests
46-
run:
47-
- vendor/bin/phpunit --version
48-
- vendor/bin/phpunit --testdox
46+
run: |
47+
vendor/bin/phpunit --version
48+
vendor/bin/phpunit --testdox
4949
5050
- name: Run the doc tests
51-
run:
52-
- vendor/bin/doctest --version
53-
- vendor/bin/doctest
51+
run: |
52+
vendor/bin/doctest --version
53+
vendor/bin/doctest
5454
5555
- name: Run linter
56-
run:
57-
- vendor/bin/phpcs --version
58-
- vendor/bin/phpcs -ps
56+
run: |
57+
vendor/bin/phpcs --version
58+
vendor/bin/phpcs -ps
5959
6060
- name: Run static analysis (PHPStan)
61-
run:
62-
- vendor/bin/phpstan --version
63-
- vendor/bin/phpstan
61+
run: |
62+
vendor/bin/phpstan --version
63+
vendor/bin/phpstan
6464
6565
- name: Run static analysis (Psalm)
66-
run:
67-
- vendor/bin/psalm --version
68-
- vendor/bin/psalm
66+
run: |
67+
vendor/bin/psalm --version
68+
vendor/bin/psalm

β€Žsrc/Option/None.phpβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public function mapOrElse(callable $callback, callable $default): mixed
141141
* @template U
142142
* @param Option<U> $option
143143
* @return $this
144+
* @psalm-suppress ImplementedReturnTypeMismatch
144145
*/
145146
public function zip(Option $option): self
146147
{

β€Žsrc/Option/Some.phpβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function zip(Option $option): Option
157157
return Option\some([$this->value, $value]);
158158
}
159159

160+
/** @psalm-suppress InvalidReturnStatement */
160161
return Option\none();
161162
}
162163

β€Žsrc/functions/option.phpβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ function tryOf(
152152
* @template U
153153
* @param Option<Option<U>> $option
154154
* @return Option<U>
155+
* @psalm-suppress InvalidReturnType
155156
*/
156157
function flatten(Option $option): Option
157158
{
159+
/** @psalm-suppress InvalidReturnStatement */
158160
return $option instanceof Option\None
159161
? $option
160162
/** @phpstan-ignore missingType.checkedException */

β€Žtests/Unit/Result/TrapTest.phpβ€Ž

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,18 @@ public function testTrapOk(mixed $value): void
2424
public function testTrapCheckedException(): void
2525
{
2626
Assert::assertEquals(
27-
new \Exception(
28-
"Failed to parse time string (nope) at position 0 (n): The timezone could not be found in the database",
29-
),
27+
new \Exception("Ooops"),
3028
// @phpstan-ignore-next-line
31-
Result\trap(static fn () => new \DateTimeImmutable("nope"))->unwrapErr(),
29+
Result\trap(static fn () => throw new \Exception("Ooops"))->unwrapErr(),
3230
);
3331
}
3432

3533
public function testTrapUncheckedException(): void
3634
{
37-
try {
38-
// @phpstan-ignore-next-line
39-
Result\trap(static fn () => 1 / 0);
40-
Assert::fail("An exception should have been thrown");
41-
} catch (\DivisionByZeroError $ex) {
42-
Assert::assertEquals(
43-
"Division by zero",
44-
$ex->getMessage(),
45-
);
46-
}
35+
$this->expectException(\DivisionByZeroError::class);
36+
$this->expectExceptionMessage("Division by zero");
37+
38+
// @phpstan-ignore-next-line
39+
Result\trap(static fn () => 1 / 0);
4740
}
4841
}

β€Žtests/type-hinting/option.phpβ€Ž

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ function test_generic_type(Option $option): int
2121
/** @psalm-suppress RedundantConditionGivenDocblockType 🎯 */
2222
// @phpstan-ignore-next-line 🎯 Call to function is_string() with string will always evaluate to true.
2323
if (\is_string($option->unwrap())) {
24-
/**
25-
* @psalm-suppress RedundantCondition πŸ™ˆ
26-
* @psalm-suppress InvalidReturnStatement 🎯
27-
*/
24+
/** @psalm-suppress InvalidReturnStatement 🎯 */
2825
// @phpstan-ignore-next-line 🎯 Function test_generic_type() should return int but returns string.
2926
return $option->unwrap();
3027
}
@@ -36,15 +33,12 @@ function test_generic_type(Option $option): int
3633
function test_is_some(Option $option): int
3734
{
3835
if ($option->isSome()) {
39-
/** @psalm-suppress MissingThrowsDocblock,RedundantCondition πŸ™ˆ */
36+
/** @psalm-suppress MissingThrowsDocblock πŸ™ˆ */
4037
// @phpstan-ignore-next-line πŸ™ˆ Function TH\Maybe\Tests\TypeHinting\test_is_some() throws checked exception RuntimeException but it's missing from the PHPDoc @throws tag.
4138
return $option->unwrap();
4239
}
4340

44-
/**
45-
* @psalm-suppress RedundantConditionGivenDocblockType πŸ™ˆ
46-
* @psalm-suppress MissingThrowsDocblock 🎯
47-
*/
41+
/** @psalm-suppress MissingThrowsDocblock 🎯 */
4842
// @phpstan-ignore-next-line 🎯 Dead catch - RuntimeException is never thrown in the try block.
4943
return $option->unwrap();
5044
}
@@ -57,13 +51,13 @@ function test_is_none(Option $option): int
5751
if ($option->isNone()) {
5852
/**
5953
* @psalm-suppress NoValue πŸ™ˆ
60-
* @psalm-suppress MissingThrowsDocblock,TypeDoesNotContainType 🎯
54+
* @psalm-suppress MissingThrowsDocblock 🎯
6155
*/
6256
// @phpstan-ignore-next-line 🎯 Function test_instanceof_none() throws checked exception RuntimeException but it's missing from the PHPDoc @throws tag.
6357
return $option->unwrap();
6458
}
6559

66-
/** @psalm-suppress MissingThrowsDocblock,RedundantCondition πŸ™ˆ */
60+
/** @psalm-suppress MissingThrowsDocblock πŸ™ˆ */
6761
// @phpstan-ignore-next-line πŸ™ˆ Function TH\Maybe\Tests\TypeHinting\test_is_none() throws checked exception RuntimeException but it's missing from the PHPDoc @throws tag.
6862
return $option->unwrap();
6963
}
@@ -74,7 +68,7 @@ function test_is_none(Option $option): int
7468
function test_instanceof_some(Option $option): int
7569
{
7670
if ($option instanceof Option\Some) {
77-
/** @psalm-suppress MissingThrowsDocblock,RedundantCondition πŸ™ˆ */
71+
/** @psalm-suppress MissingThrowsDocblock πŸ™ˆ */
7872
// @phpstan-ignore-next-line πŸ™ˆ Function TH\Maybe\Tests\TypeHinting\test_instanceof_some() throws checked exception RuntimeException but it's missing from the PHPDoc @throws tag.
7973
return $option->unwrap();
8074
}
@@ -90,7 +84,7 @@ function test_instanceof_some(Option $option): int
9084
function test_instanceof_none(Option $option): int
9185
{
9286
if ($option instanceof Option\None) {
93-
/** @psalm-suppress NoValue,MissingThrowsDocblock,TypeDoesNotContainType 🎯 */
87+
/** @psalm-suppress NoValue,MissingThrowsDocblock 🎯 */
9488
// @phpstan-ignore-next-line 🎯 Function test_instanceof_none() throws checked exception RuntimeException but it's missing from the PHPDoc @throws tag.
9589
return $option->unwrap();
9690
}
@@ -102,14 +96,15 @@ function test_instanceof_none(Option $option): int
10296

10397
function test_call_a_function_with_none(): void
10498
{
99+
/** @psalm-suppress InvalidArgument πŸ™ˆ Argument 1 of TH\Maybe\Tests\TypeHinting\option\test_is_none expects TH\Maybe\Option<int>, but TH\Maybe\Option\None provided */
105100
here\test_is_none(Option\none());
106101
}
107102

108103
function test_call_a_function_with_some(): void
109104
{
110105
here\test_is_none(Option\some(1));
111106

112-
/** @psalm-suppress InvalidArgument 🎯 */
107+
/** @psalm-suppress InvalidScalarArgument 🎯 */
113108
// @phpstan-ignore-next-line 🎯 Parameter #1 $option of function TH\Maybe\Tests\TypeHinting\option\test_is_none expects TH\Maybe\Option<int>, TH\Maybe\Option\Some<string> given.
114109
here\test_is_none(Option\some("1"));
115110
}

β€Žtests/type-hinting/result.phpβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function test_generic_type(Result $result): int
2525
return $result->unwrap();
2626
}
2727

28-
/** @psalm-suppress NoValue,TypeDoesNotContainType 🎯 This function or method call never returns output */
28+
/** @psalm-suppress NoValue 🎯 This function or method call never returns output */
2929
// @phpstan-ignore-next-line 🎯 Unreachable statement - code above always terminates.
3030
return $result->unwrapErr();
3131
}

0 commit comments

Comments
Β (0)