Skip to content

Commit 968d359

Browse files
committed
Use strict types
1 parent 6fd46b4 commit 968d359

17 files changed

+61
-23
lines changed

src/AbstractManifest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
use Normalizer;

src/Bag.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
use Archive_Tar;

src/BagUtils.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
use TypeError;
@@ -413,7 +415,7 @@ public static function encodeFilepath(string $line): string
413415
*/
414416
public static function checkUnencodedFilepath(string $filepath): bool
415417
{
416-
return preg_match_all("/%(?!(25|0A|0D))/", $filepath);
418+
return (bool) preg_match_all("/%(?!(25|0A|0D))/", $filepath);
417419
}
418420

419421
/**

src/Commands/ValidateCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Commands;
46

57
use Symfony\Component\Console\Command\Command;

src/Exceptions/BagItException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Exceptions;
46

57
use Exception;

src/Exceptions/FilesystemException.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Exceptions;
46

57
/**

src/Fetch.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
use Normalizer;

src/PayloadManifest.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
/**
@@ -11,16 +13,18 @@
1113
*/
1214
class PayloadManifest extends AbstractManifest
1315
{
14-
/**
15-
* PayloadManifest constructor.
16-
*
17-
* @param \whikloj\BagItTools\Bag $bag
18-
* The bag this manifest is part of.
19-
* @param string $algorithm
20-
* The BagIt name of the hash algorithm.
21-
* @param bool $load
22-
* Whether we are loading an existing file
23-
*/
16+
/**
17+
* PayloadManifest constructor.
18+
*
19+
* @param \whikloj\BagItTools\Bag $bag
20+
* The bag this manifest is part of.
21+
* @param string $algorithm
22+
* The BagIt name of the hash algorithm.
23+
* @param bool $load
24+
* Whether we are loading an existing file
25+
* @throws \whikloj\BagItTools\Exceptions\FilesystemException
26+
* Unable to read manifest file.
27+
*/
2428
public function __construct(Bag $bag, string $algorithm, bool $load = false)
2529
{
2630
parent::__construct($bag, $algorithm, "manifest-$algorithm.txt", $load);

src/TagManifest.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools;
46

57
/**
@@ -11,16 +13,18 @@
1113
*/
1214
class TagManifest extends AbstractManifest
1315
{
14-
/**
15-
* PayloadManifest constructor.
16-
*
17-
* @param \whikloj\BagItTools\Bag $bag
18-
* The bag this manifest is part of.
19-
* @param string $algorithm
20-
* The BagIt name of the hash algorithm.
21-
* @param boolean $load
22-
* Whether we are loading an existing file
23-
*/
16+
/**
17+
* PayloadManifest constructor.
18+
*
19+
* @param \whikloj\BagItTools\Bag $bag
20+
* The bag this manifest is part of.
21+
* @param string $algorithm
22+
* The BagIt name of the hash algorithm.
23+
* @param boolean $load
24+
* Whether we are loading an existing file
25+
* @throws \whikloj\BagItTools\Exceptions\FilesystemException
26+
* Unable to read manifest file.
27+
*/
2428
public function __construct(Bag $bag, string $algorithm, bool $load = false)
2529
{
2630
parent::__construct($bag, $algorithm, "tagmanifest-$algorithm.txt", $load);

tests/BagInternalTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use ReflectionClass;

tests/BagItTestFramework.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use PHPUnit\Framework\TestCase;

tests/BagTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use whikloj\BagItTools\Bag;
@@ -823,7 +825,7 @@ public function testUpdateV07(): void
823825
$this->assertTrue($bag->validate());
824826
$fp = fopen($bag->getBagRoot() . DIRECTORY_SEPARATOR . 'bag-info.txt', 'r');
825827
while (!feof($fp)) {
826-
$line = fgets($fp);
828+
$line = (string) fgets($fp);
827829
$line = trim($line);
828830
if (empty($line)) {
829831
continue;
@@ -837,7 +839,7 @@ public function testUpdateV07(): void
837839
$this->assertTrue($bag->validate());
838840
$fp = fopen($bag->getBagRoot() . DIRECTORY_SEPARATOR . 'bag-info.txt', 'r');
839841
while (!feof($fp)) {
840-
$line = fgets($fp);
842+
$line = (string) fgets($fp);
841843
$line = trim($line);
842844
if (empty($line)) {
843845
continue;

tests/BagUtilsTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use Exception;

tests/CommandTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use Symfony\Component\Console\Application;

tests/ExtendedBagTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use whikloj\BagItTools\Bag;

tests/FetchTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use donatj\MockWebServer\MockWebServer;

tests/ManifestTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace whikloj\BagItTools\Test;
46

57
use whikloj\BagItTools\Bag;

0 commit comments

Comments
 (0)