Skip to content

Commit 4afaa96

Browse files
committed
Fixed PHPStan errors up to level 7
1 parent 1db2fac commit 4afaa96

10 files changed

+41
-8
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parameters:
44
- tests
55
parallel:
66
maximumNumberOfProcesses: 4
7-
level: 6
7+
level: 7
88
inferPrivatePropertyTypeFromConstructor: true
99
bootstrapFiles:
1010
- tools/bootstrap.php

src/Parameters/CreateMeetingParameters.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public function getPresentations(): array
363363
return $this->presentations;
364364
}
365365

366-
public function getPresentationsAsXML(): string|false
366+
public function getPresentationsAsXML(): string
367367
{
368368
$result = '';
369369

@@ -389,6 +389,10 @@ public function getPresentationsAsXML(): string|false
389389
$result = $xml->asXML();
390390
}
391391

392+
if (false === $result) {
393+
throw new \LogicException('Could not generate XML.');
394+
}
395+
392396
return $result;
393397
}
394398

src/Parameters/InsertDocumentParameters.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function removePresentation(string $url): self
5252
return $this;
5353
}
5454

55-
public function getPresentationsAsXML(): string|false
55+
public function getPresentationsAsXML(): string
5656
{
5757
$result = '';
5858

@@ -77,6 +77,10 @@ public function getPresentationsAsXML(): string|false
7777
$result = $xml->asXML();
7878
}
7979

80+
if (false === $result) {
81+
throw new \LogicException('Could not generate XML.');
82+
}
83+
8084
return $result;
8185
}
8286
}

tests/unit/Parameters/CreateMeetingParametersTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,13 @@ public function testGetPresentationsAsXMLWithFile(): void
216216
{
217217
$params = $this->generateCreateParams();
218218
$createMeetingParams = $this->getCreateMock($params);
219-
$createMeetingParams->addPresentation('bbb_logo.png', file_get_contents(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'bbb_logo.png'));
219+
220+
$content = file_get_contents(
221+
__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'fixtures' . \DIRECTORY_SEPARATOR . 'bbb_logo.png'
222+
);
223+
$this->assertIsString($content);
224+
225+
$createMeetingParams->addPresentation('bbb_logo.png', $content);
220226
$this->assertXmlStringEqualsXmlFile(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'presentation_with_embedded_file.xml', $createMeetingParams->getPresentationsAsXML());
221227
}
222228

tests/unit/Responses/GetMeetingsResponseTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ public function testGetMeetingsNoMeetings(): void
8585
{
8686
// scalelite response no meetings
8787
$xml = simplexml_load_string('<response><returncode>SUCCESS</returncode><messageKey>noMeetings</messageKey><message>No meetings were found on this server.</message></response>');
88+
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
89+
8890
$this->meetings = new GetMeetingsResponse($xml);
8991
$this->assertEquals('SUCCESS', $this->meetings->getReturnCode());
9092
$this->assertCount(0, $this->meetings->getMeetings());
9193

9294
// normal bbb response no meetings
9395
$xml = simplexml_load_string('<response><returncode>SUCCESS</returncode><meetings/><messageKey>noMeetings</messageKey><message>No meetings were found on this server.</message></response>');
96+
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
97+
9498
$this->meetings = new GetMeetingsResponse($xml);
9599
$this->assertEquals('SUCCESS', $this->meetings->getReturnCode());
96100
$this->assertCount(0, $this->meetings->getMeetings());

tests/unit/Responses/GetRecordingsResponseTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ public function testHasNoRecordings(): void
128128
<message>There are no recordings for the meeting(s).</message>
129129
</response>';
130130

131-
$response = new GetRecordingsResponse(simplexml_load_string($xml));
131+
$xml = simplexml_load_string($xml);
132+
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
133+
134+
$response = new GetRecordingsResponse($xml);
132135

133136
$this->assertTrue($response->hasNoRecordings());
134137
}

tests/unit/Responses/HooksDestroyResponseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function testHooksDestroyResponseTypes(): void
5353
public function testHookDestroyMissingHook(): void
5454
{
5555
$xml = simplexml_load_string('<response><returncode>FAILED</returncode><messageKey>destroyMissingHook</messageKey><message>The hook informed was not found.</message></response>');
56+
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
5657

5758
$destroyResponse = new HooksDestroyResponse($xml);
5859
$this->assertTrue($destroyResponse->failed());
@@ -62,6 +63,7 @@ public function testHookDestroyMissingHook(): void
6263
public function testHookDestroyHookError(): void
6364
{
6465
$xml = simplexml_load_string('<response><returncode>FAILED</returncode><messageKey>destroyHookError</messageKey><message>An error happened while removing your hook. Check the logs.</message></response>');
66+
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
6567

6668
$destroyResponse = new HooksDestroyResponse($xml);
6769
$this->assertTrue($destroyResponse->failed());

tests/unit/Responses/InsertDocumentResponseTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ public function testIsMeetingRunningResponseContent(): void
4141
{
4242
$this->assertEquals('SUCCESS', $this->running->getReturnCode());
4343

44-
$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode></response>', $this->minifyString($this->running->getRawXml()->asXML()));
44+
$xml = $this->running->getRawXml()->asXML();
45+
$this->assertIsString($xml);
46+
47+
$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode></response>', $this->minifyString(
48+
$xml
49+
));
4550
}
4651

4752
public function testIsMeetingRunningResponseTypes(): void

tests/unit/Responses/IsMeetingRunningResponseTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public function testIsMeetingRunningResponseContent(): void
4343
$this->assertEquals('SUCCESS', $this->running->getReturnCode());
4444
$this->assertTrue($this->running->isRunning());
4545

46-
$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode><running>true</running></response>', $this->minifyString($this->running->getRawXml()->asXML()));
46+
$xml = $this->running->getRawXml()->asXML();
47+
$this->assertIsString($xml);
48+
49+
$this->assertEquals('<?xmlversion="1.0"?><response><returncode>SUCCESS</returncode><running>true</running></response>', $this->minifyString(
50+
$xml
51+
));
4752
}
4853

4954
public function testIsMeetingRunningResponseTypes(): void

tests/unit/Util/ArrayHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
final class ArrayHelperTest extends TestCase
3131
{
32-
/** @return iterable<string,array<string|array-key,string|bool>> */
32+
/** @return iterable<array<mixed>> */
3333
public function provideArrays(): iterable
3434
{
3535
yield 'simple flat arrays' => [

0 commit comments

Comments
 (0)