Skip to content

Commit

Permalink
Apply future Psalm defaults
Browse files Browse the repository at this point in the history
Covers some uncalled methods, removes dead code and updates doc blocks to satisfy newly discovered Psalm issues
  • Loading branch information
gsteel committed May 16, 2023
1 parent e165fc3 commit 3b4c84a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 34 deletions.
33 changes: 20 additions & 13 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.4.0@62db5d4f6a7ae0a20f7cc5a4952d730272fc0863">
<files psalm-version="5.11.0@c9b192ab8400fdaf04b2b13d110575adc879aa90">
<file src="src/ResultSet/ResultSetFactory.php">
<PossiblyUnusedMethod>
<code>withHttpResponse</code>
</PossiblyUnusedMethod>
</file>
<file src="test/Smoke/TestCase.php">
<RedundantCondition occurrences="6">
<RedundantCondition>
<code>assert(is_array($configured))</code>
<code>assert(is_array($spec))</code>
<code>is_array($configured)</code>
<code>is_array($spec)</code>
<code>is_string($spec['url'])</code>
<code>isset($spec['url']) &amp;&amp; is_string($spec['url'])</code>
<code><![CDATA[is_string($spec['url'])]]></code>
<code><![CDATA[isset($spec['url']) && is_string($spec['url'])]]></code>
<code>null</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="4">
<TypeDoesNotContainType>
<code>is_array($content)</code>
<code>is_string($spec['token'])</code>
<code>isset($spec['token'])</code>
<code>isset($spec['token']) &amp;&amp; is_string($spec['token'])</code>
<code><![CDATA[is_string($spec['token'])]]></code>
<code><![CDATA[isset($spec['token'])]]></code>
<code><![CDATA[isset($spec['token']) && is_string($spec['token'])]]></code>
<code>null</code>
</TypeDoesNotContainType>
<UnusedPsalmSuppress occurrences="1">
<UnusedPsalmSuppress>
<code>MissingFile</code>
</UnusedPsalmSuppress>
</file>
<file src="test/Unit/QueryTest.php">
<InvalidReturnStatement occurrences="2">
<InvalidReturnStatement>
<code>$queries</code>
<code>$queries</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="2">
<code>array&lt;string, array{0: Query, 1: string}&gt;</code>
<code>array&lt;string, array{0: Query, 1: string}&gt;</code>
<InvalidReturnType>
<code><![CDATA[array<string, array{0: Query, 1: string}>]]></code>
<code><![CDATA[array<string, array{0: Query, 1: string}>]]></code>
</InvalidReturnType>
</file>
</files>
22 changes: 6 additions & 16 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,21 @@
<psalm
errorLevel="1"
memoizeMethodCallResults="true"
findUnusedPsalmSuppress="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml">
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedPsalmSuppress="true"
findUnusedCode="true"
findUnusedBaselineEntry="true"
>
<projectFiles>
<directory name="src"/>
<directory name="test"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InternalMethod>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::method"/>
</errorLevel>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::willReturn"/>
</errorLevel>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::with"/>
</errorLevel>
</InternalMethod>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
Expand Down
1 change: 0 additions & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public static function get(

/**
* phpcs:disable Generic.Files.LineLength.TooLong, Squiz.Commenting.FunctionComment.SpacingAfterParamType
* @param T|null $instance
* @param class-string<ClientInterface>|class-string<RequestFactoryInterface>|class-string<UriFactoryInterface> $type
*
* @template T of object
Expand Down
4 changes: 0 additions & 4 deletions src/Document/Fragment/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ final class Factory
{
use DataAssertionBehaviour;

public function __construct()
{
}

public function __invoke(mixed $data): Fragment
{
return self::factory($data);
Expand Down
6 changes: 6 additions & 0 deletions test/Unit/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ public function testThatThePayloadIsPreservedByTheException(): void
);
}
}

public function testSuccessfulDecode(): void
{
$value = Json::decode('{"foo":"bar"}', true);
self::assertSame(['foo' => 'bar'], $value);
}
}
1 change: 1 addition & 0 deletions test/Unit/PredicateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public function testPredicatesCanBeCastToString(string $fragment, string|int|flo
/**
* @param scalar|list<scalar> $value
*
* @psalm-suppress PossiblyUnusedParam
* @dataProvider atProvider
*/
public function testSetState(string $fragment, string|int|float|bool|array $value, string $expect): void
Expand Down
2 changes: 2 additions & 0 deletions test/Unit/Value/FormSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ protected function setUp(): void

public function testBasicAccessors(): void
{
$this->assertEquals('My Form', $this->form->name());
$this->assertEquals('something', $this->form->rel());
$this->assertEquals('GET', $this->form->method());
$this->assertEquals('https://example.com', $this->form->action());
$this->assertEquals('whatever', $this->form->encType());
Expand Down
5 changes: 5 additions & 0 deletions test/Unit/Value/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function testNewInstance(): void

public function testJsonEncode(): void
{
self::assertEquals(
['baz' => 'bat'],
Type::new('baz', 'bat')->jsonSerialize(),
);

self::assertEquals(
'{"foo":"bar"}',
json_encode(Type::new('foo', 'bar'), JSON_THROW_ON_ERROR),
Expand Down

0 comments on commit 3b4c84a

Please sign in to comment.