Skip to content

Commit 3af64e4

Browse files
committed
More Coverage
1 parent 2e61f10 commit 3af64e4

File tree

5 files changed

+5
-33
lines changed

5 files changed

+5
-33
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,6 @@ parameters:
390390
count: 2
391391
path: src/PhpWord/Shared/ZipArchive.php
392392

393-
-
394-
message: "#^Call to method addFromString\\(\\) on an unknown class PclZip\\.$#"
395-
count: 1
396-
path: src/PhpWord/Shared/ZipArchive.php
397-
398393
-
399394
message: "#^Call to method close\\(\\) on an unknown class PclZip\\.$#"
400395
count: 1
@@ -1340,11 +1335,6 @@ parameters:
13401335
count: 2
13411336
path: tests/PhpWordTests/TemplateProcessorTest.php
13421337

1343-
-
1344-
message: "#^Call to an undefined method PhpOffice\\\\PhpWord\\\\Shared\\\\ZipArchive\\:\\:AddFromString\\(\\)\\.$#"
1345-
count: 1
1346-
path: tests/PhpWordTests/TemplateProcessorTest.php
1347-
13481338
-
13491339
message: "#^Cannot access offset 'end' on array\\<int\\>\\|bool\\.$#"
13501340
count: 2

phpstan-baseline.php7.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,6 @@ parameters:
375375
count: 2
376376
path: src/PhpWord/Shared/ZipArchive.php
377377

378-
-
379-
message: "#^Call to method addFromString\\(\\) on an unknown class PclZip\\.$#"
380-
count: 1
381-
path: src/PhpWord/Shared/ZipArchive.php
382-
383378
-
384379
message: "#^Call to method close\\(\\) on an unknown class PclZip\\.$#"
385380
count: 1
@@ -1310,11 +1305,6 @@ parameters:
13101305
count: 2
13111306
path: tests/PhpWordTests/TemplateProcessorTest.php
13121307

1313-
-
1314-
message: "#^Call to an undefined method PhpOffice\\\\PhpWord\\\\Shared\\\\ZipArchive\\:\\:AddFromString\\(\\)\\.$#"
1315-
count: 1
1316-
path: tests/PhpWordTests/TemplateProcessorTest.php
1317-
13181308
-
13191309
message: "#^Cannot access offset 'end' on array\\<int\\>\\|bool\\.$#"
13201310
count: 2

phpstan-baseline.php73.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,6 @@ parameters:
375375
count: 2
376376
path: src/PhpWord/Shared/ZipArchive.php
377377

378-
-
379-
message: "#^Call to method addFromString\\(\\) on an unknown class PclZip\\.$#"
380-
count: 1
381-
path: src/PhpWord/Shared/ZipArchive.php
382-
383378
-
384379
message: "#^Call to method close\\(\\) on an unknown class PclZip\\.$#"
385380
count: 1
@@ -1310,11 +1305,6 @@ parameters:
13101305
count: 2
13111306
path: tests/PhpWordTests/TemplateProcessorTest.php
13121307

1313-
-
1314-
message: "#^Call to an undefined method PhpOffice\\\\PhpWord\\\\Shared\\\\ZipArchive\\:\\:AddFromString\\(\\)\\.$#"
1315-
count: 1
1316-
path: tests/PhpWordTests/TemplateProcessorTest.php
1317-
13181308
-
13191309
message: "#^Cannot access offset 'end' on array\\<int\\>\\|bool\\.$#"
13201310
count: 2

src/PhpWord/Shared/ZipArchive.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ public function getFromName($filename)
236236
*/
237237
public function pclzipAddFile($filename, $localname = null)
238238
{
239-
/** @var PclZip $zip Type hint */
240239
$zip = $this->zip;
241240

242241
// Bugfix GH-261 https://github.com/PHPOffice/PHPWord/pull/261
@@ -267,8 +266,10 @@ public function pclzipAddFile($filename, $localname = null)
267266
if (!$this->usePclzip) {
268267
$pathAdded = $pathAdded . '/' . ltrim(str_replace('\\', '/', substr($filename, strlen($pathRemoved))), '/');
269268
//$res = $zip->addFile($filename, $pathAdded);
270-
$res = $zip->addFromString($pathAdded, file_get_contents($filename)); // addFile can't use subfolders in some cases
269+
/** @var \ZipArchive $zip */
270+
$res = $zip->addFromString($pathAdded, (string) file_get_contents($filename)); // addFile can't use subfolders in some cases
271271
} else {
272+
/** @var PclZip $zip */
272273
$res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded);
273274
}
274275

tests/PhpWordTests/TemplateProcessorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function xtestTemplateCanBeSavedInTemporaryLocation(string $templateFqfn,
9696
}
9797

9898
$embeddingText = 'The quick Brown Fox jumped over the lazy^H^H^H^Htired unitTester';
99-
$templateProcessor->zip()->AddFromString('word/embeddings/fox.bin', $embeddingText);
99+
$templateProcessor->zip()->addFromString('word/embeddings/fox.bin', $embeddingText);
100100
$documentFqfn = $templateProcessor->save();
101101

102102
self::assertNotEmpty($documentFqfn, 'FQFN of the saved document is empty.');
@@ -855,6 +855,7 @@ public function testSetCheckboxWithCustomMacro(): void
855855

856856
/**
857857
* @covers ::setImageValue
858+
* @covers \PhpOffice\PhpWord\Shared\ZipArchive::pclzipAddFile
858859
*/
859860
public function testSetImageValue(): void
860861
{

0 commit comments

Comments
 (0)