Skip to content

Commit 4607da8

Browse files
committed
Fix PHPUnit compatibility and a range of minor SA issues
Signed-off-by: George Steel <george@net-glue.co.uk>
1 parent a2b0a13 commit 4607da8

File tree

5 files changed

+47
-94
lines changed

5 files changed

+47
-94
lines changed

psalm-baseline.xml

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,42 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.24.0@06dd975cb55d36af80f242561738f16c5f58264f">
3-
<file src="src/AutoComposer.php">
4-
<DocblockTypeContradiction occurrences="2">
5-
<code>$this-&gt;composerDevMode === false</code>
6-
<code>$this-&gt;composerDevMode === false</code>
7-
</DocblockTypeContradiction>
8-
<PossiblyFalsePropertyAssignmentValue occurrences="1">
9-
<code>getenv(self::COMPOSER_DEV_MODE)</code>
10-
</PossiblyFalsePropertyAssignmentValue>
11-
</file>
2+
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015">
123
<file src="src/Command.php">
13-
<MixedAssignment occurrences="1">
4+
<MixedAssignment>
145
<code>$argument</code>
156
</MixedAssignment>
167
</file>
178
<file src="src/ConfigDiscoveryTrait.php">
18-
<MissingReturnType occurrences="1">
9+
<MissingReturnType>
1910
<code>removeConfigCacheFile</code>
2011
</MissingReturnType>
21-
<MixedAssignment occurrences="1">
22-
<code>$this-&gt;applicationConfig</code>
12+
<MixedAssignment>
13+
<code><![CDATA[$this->applicationConfig]]></code>
2314
</MixedAssignment>
24-
<MixedInferredReturnType occurrences="3">
15+
<MixedInferredReturnType>
2516
<code>false|string</code>
2617
<code>null|string</code>
2718
<code>null|string</code>
2819
</MixedInferredReturnType>
29-
<RedundantPropertyInitializationCheck occurrences="2">
30-
<code>$this-&gt;applicationConfigPath</code>
31-
<code>isset($this-&gt;projectDir)</code>
32-
</RedundantPropertyInitializationCheck>
33-
<RedundantConditionGivenDocblockType occurrences="1">
34-
<code>isset($this-&gt;projectDir)</code>
20+
<RedundantConditionGivenDocblockType>
21+
<code><![CDATA[isset($this->projectDir)]]></code>
3522
</RedundantConditionGivenDocblockType>
36-
<DocblockTypeContradiction occurrences="1">
37-
<code>$this-&gt;applicationConfigPath</code>
23+
<DocblockTypeContradiction>
24+
<code><![CDATA[$this->applicationConfigPath]]></code>
3825
</DocblockTypeContradiction>
3926
</file>
4027
<file src="test/AutoComposerTest.php">
41-
<InvalidPropertyAssignmentValue occurrences="1">
42-
<code>$this-&gt;errorStream</code>
28+
<InvalidPropertyAssignmentValue>
29+
<code><![CDATA[$this->errorStream]]></code>
4330
</InvalidPropertyAssignmentValue>
44-
<RedundantConditionGivenDocblockType occurrences="1">
45-
<code>is_resource($this-&gt;errorStream)</code>
46-
</RedundantConditionGivenDocblockType>
4731
</file>
4832
<file src="test/DisableTest.php">
49-
<InvalidPropertyAssignmentValue occurrences="1">
50-
<code>$this-&gt;errorStream</code>
33+
<InvalidPropertyAssignmentValue>
34+
<code><![CDATA[$this->errorStream]]></code>
5135
</InvalidPropertyAssignmentValue>
52-
<RedundantConditionGivenDocblockType occurrences="1">
53-
<code>is_resource($this-&gt;errorStream)</code>
54-
</RedundantConditionGivenDocblockType>
5536
</file>
5637
<file src="test/EnableTest.php">
57-
<DeprecatedMethod occurrences="1">
58-
<code>setMethods</code>
59-
</DeprecatedMethod>
60-
<InvalidPropertyAssignmentValue occurrences="1">
61-
<code>$this-&gt;errorStream</code>
38+
<InvalidPropertyAssignmentValue>
39+
<code><![CDATA[$this->errorStream]]></code>
6240
</InvalidPropertyAssignmentValue>
63-
<RedundantConditionGivenDocblockType occurrences="1">
64-
<code>is_resource($this-&gt;errorStream)</code>
65-
</RedundantConditionGivenDocblockType>
66-
</file>
67-
<file src="test/RemoveCacheFileTrait.php">
68-
<MissingReturnType occurrences="3">
69-
<code>setUpCustomCacheFile</code>
70-
<code>setUpDefaultCacheFile</code>
71-
<code>setUpDefaultMezzioCacheFile</code>
72-
</MissingReturnType>
7341
</file>
7442
</files>

test/AutoComposerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use function fclose;
1313
use function fopen;
14-
use function is_resource;
1514
use function putenv;
1615

1716
use const PHP_EOL;
@@ -39,9 +38,7 @@ public function setUp(): void
3938

4039
public function tearDown(): void
4140
{
42-
if (is_resource($this->errorStream)) {
43-
fclose($this->errorStream);
44-
}
41+
fclose($this->errorStream);
4542
}
4643

4744
public function testIndicatesEnvironmentVariableNotSet(): void

test/DisableTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use function fopen;
1616
use function fread;
1717
use function fseek;
18-
use function is_resource;
1918

2019
use const PHP_EOL;
2120

@@ -47,15 +46,10 @@ protected function setUp(): void
4746

4847
protected function tearDown(): void
4948
{
50-
if (is_resource($this->errorStream)) {
51-
fclose($this->errorStream);
52-
}
49+
fclose($this->errorStream);
5350
}
5451

55-
/**
56-
* @return bool|string
57-
*/
58-
public function readErrorStream()
52+
public function readErrorStream(): false|string
5953
{
6054
fseek($this->errorStream, 0);
6155
return fread($this->errorStream, 4096);
@@ -101,7 +95,7 @@ public function testWillRemoveLocalAutoloadDistConfigIfPresent(): void
10195
$this->assertSame(
10296
0,
10397
$result,
104-
'Did not get expected return value from invoking disable; errors: ' . $this->readErrorStream()
98+
'Did not get expected return value from invoking disable; errors: ' . (string) $this->readErrorStream()
10599
);
106100
$this->assertFalse(
107101
file_exists(vfsStream::url('project/config/development.config.php')),

test/EnableTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use function fopen;
1515
use function fread;
1616
use function fseek;
17-
use function is_resource;
1817

1918
use const PHP_EOL;
2019

@@ -41,22 +40,17 @@ protected function setUp(): void
4140
$this->errorStream = fopen('php://memory', 'w+');
4241
$this->command = $this->getMockBuilder(Enable::class)
4342
->setConstructorArgs([vfsStream::url('project'), $this->errorStream])
44-
->setMethods(['supportsSymlinks'])
43+
->onlyMethods(['supportsSymlinks'])
4544
->getMock();
4645
$this->command->method('supportsSymlinks')->willReturn(false);
4746
}
4847

4948
protected function tearDown(): void
5049
{
51-
if (is_resource($this->errorStream)) {
52-
fclose($this->errorStream);
53-
}
50+
fclose($this->errorStream);
5451
}
5552

56-
/**
57-
* @return bool|string
58-
*/
59-
public function readErrorStream()
53+
public function readErrorStream(): false|string
6054
{
6155
fseek($this->errorStream, 0);
6256
return fread($this->errorStream, 4096);
@@ -124,7 +118,7 @@ public function testWillCopyLocalAutoloadDistConfigIfPresent(): void
124118
$this->assertSame(
125119
0,
126120
$result,
127-
'Did not get expected return value from invoking enable; errors: ' . $this->readErrorStream()
121+
'Did not get expected return value from invoking enable; errors: ' . (string) $this->readErrorStream()
128122
);
129123
$this->assertTrue(
130124
file_exists(vfsStream::url('project') . '/config/development.config.php'),

test/RemoveCacheFileTrait.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,48 @@
1010

1111
trait RemoveCacheFileTrait
1212
{
13-
public function setUpDefaultCacheFile()
13+
public function setUpDefaultCacheFile(): void
1414
{
1515
$base = vfsStream::url('project');
1616
$config = <<<EOC
17-
<?php
18-
return [
19-
'module_listener_options' => [
20-
'cache_dir' => '{$base}/cache',
21-
],
22-
];
23-
EOC;
17+
<?php
18+
return [
19+
'module_listener_options' => [
20+
'cache_dir' => '{$base}/cache',
21+
],
22+
];
23+
EOC;
2424

2525
file_put_contents(vfsStream::url('project/config/application.config.php'), $config);
2626
file_put_contents(vfsStream::url('project/cache/module-config-cache.php'), '<' . "?php\nreturn [];");
2727
}
2828

29-
public function setUpCustomCacheFile()
29+
public function setUpCustomCacheFile(): void
3030
{
3131
$base = vfsStream::url('project');
3232
$config = <<<EOC
33-
<?php
34-
return [
35-
'module_listener_options' => [
36-
'cache_dir' => '{$base}/cache',
37-
'config_cache_key' => 'custom',
38-
],
39-
];
40-
EOC;
33+
<?php
34+
return [
35+
'module_listener_options' => [
36+
'cache_dir' => '{$base}/cache',
37+
'config_cache_key' => 'custom',
38+
],
39+
];
40+
EOC;
4141

4242
file_put_contents(vfsStream::url('project/config/application.config.php'), $config);
4343
file_put_contents(vfsStream::url('project/cache/module-config-cache.custom.php'), '<' . "?php\nreturn [];");
4444
}
4545

46-
public function setUpDefaultMezzioCacheFile()
46+
public function setUpDefaultMezzioCacheFile(): void
4747
{
4848
$cache = vfsStream::url('project/data/config-cache.php');
4949
$config = <<<EOC
50-
<?php
51-
return [
52-
'config_cache_path' => '{$cache}',
53-
];
54-
EOC;
50+
<?php
51+
return [
52+
'config_cache_path' => '{$cache}',
53+
];
54+
EOC;
5555

5656
file_put_contents(vfsStream::url('project/config/application.config.php'), $config);
5757
file_put_contents($cache, '<' . "?php\nreturn [];");

0 commit comments

Comments
 (0)