Skip to content

Commit ff592a7

Browse files
committed
Update psalm defaults for future version 6
Adds tests for unused code and updates baseline with false negatives Signed-off-by: George Steel <[email protected]>
1 parent ec023b8 commit ff592a7

5 files changed

+90
-4
lines changed

psalm-baseline.xml

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
2+
<files psalm-version="5.8.0@9cf4f60a333f779ad3bc704a555920e81d4fdcda">
3+
<file src="src/Persistence/CacheHeadersGeneratorTrait.php">
4+
<UnusedMethod>
5+
<code>generateCacheHeaders</code>
6+
</UnusedMethod>
7+
</file>
8+
<file src="src/RetrieveSession.php">
9+
<UnusedConstructor>
10+
<code>__construct</code>
11+
</UnusedConstructor>
12+
</file>
313
<file src="src/Session.php">
4-
<MixedInferredReturnType occurrences="1"/>
5-
<MixedReturnStatement occurrences="1">
14+
<MixedInferredReturnType>
15+
<code>null|bool|int|float|string|array</code>
16+
</MixedInferredReturnType>
17+
<MixedReturnStatement>
618
<code>json_decode(json_encode($value, JSON_PRESERVE_ZERO_FRACTION), true)</code>
719
</MixedReturnStatement>
820
</file>

psalm.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
errorLevel="1"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
6-
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml">
6+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7+
errorBaseline="psalm-baseline.xml"
8+
findUnusedBaselineEntry="true"
9+
findUnusedCode="true"
10+
findUnusedPsalmSuppress="true"
11+
>
712
<projectFiles>
813
<directory name="src"/>
914
<directory name="test"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MezzioTest\Session\Exception;
6+
7+
use Mezzio\Session\Exception\InvalidHopsValueException;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class InvalidHopsValueExceptionTest extends TestCase
11+
{
12+
public function testExpectedMessageWhenHopsTooLow(): void
13+
{
14+
$e = InvalidHopsValueException::valueTooLow('nuts', 99);
15+
16+
self::assertStringContainsString('"nuts"', $e->getMessage());
17+
self::assertStringContainsString('received 99', $e->getMessage());
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MezzioTest\Session\Exception;
6+
7+
use Mezzio\Session\Exception\InvalidSessionSegmentDataException;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class InvalidSessionSegmentDataExceptionTest extends TestCase
11+
{
12+
public function testExpectedExceptionMessage(): void
13+
{
14+
$e = InvalidSessionSegmentDataException::whenRetrieving('muppets', 'kermit');
15+
16+
self::assertEquals(
17+
'Cannot retrieve session segment "muppets"; data exists, but as a "string" instead of an array',
18+
$e->getMessage(),
19+
);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MezzioTest\Session\Exception;
6+
7+
use Mezzio\Session\Exception\SessionSegmentConflictException;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class SessionSegmentConflictExceptionTest extends TestCase
11+
{
12+
public function testWhenRetrieving(): void
13+
{
14+
$e = SessionSegmentConflictException::whenRetrieving('baz');
15+
self::assertStringContainsString('"baz"', $e->getMessage());
16+
}
17+
18+
public function testWhenSetting(): void
19+
{
20+
$e = SessionSegmentConflictException::whenSetting('qoo');
21+
self::assertStringContainsString('"qoo"', $e->getMessage());
22+
}
23+
24+
public function testWhenDeleting(): void
25+
{
26+
$e = SessionSegmentConflictException::whenDeleting('boo');
27+
self::assertStringContainsString('"boo"', $e->getMessage());
28+
}
29+
}

0 commit comments

Comments
 (0)