Skip to content

Commit

Permalink
Use strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Feb 24, 2022
1 parent 6fd46b4 commit 968d359
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/AbstractManifest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

use Normalizer;
Expand Down
2 changes: 2 additions & 0 deletions src/Bag.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

use Archive_Tar;
Expand Down
4 changes: 3 additions & 1 deletion src/BagUtils.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

use TypeError;
Expand Down Expand Up @@ -413,7 +415,7 @@ public static function encodeFilepath(string $line): string
*/
public static function checkUnencodedFilepath(string $filepath): bool
{
return preg_match_all("/%(?!(25|0A|0D))/", $filepath);
return (bool) preg_match_all("/%(?!(25|0A|0D))/", $filepath);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/ValidateCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Commands;

use Symfony\Component\Console\Command\Command;
Expand Down
2 changes: 2 additions & 0 deletions src/Exceptions/BagItException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Exceptions;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions src/Exceptions/FilesystemException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Exceptions;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Fetch.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

use Normalizer;
Expand Down
24 changes: 14 additions & 10 deletions src/PayloadManifest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

/**
Expand All @@ -11,16 +13,18 @@
*/
class PayloadManifest extends AbstractManifest
{
/**
* PayloadManifest constructor.
*
* @param \whikloj\BagItTools\Bag $bag
* The bag this manifest is part of.
* @param string $algorithm
* The BagIt name of the hash algorithm.
* @param bool $load
* Whether we are loading an existing file
*/
/**
* PayloadManifest constructor.
*
* @param \whikloj\BagItTools\Bag $bag
* The bag this manifest is part of.
* @param string $algorithm
* The BagIt name of the hash algorithm.
* @param bool $load
* Whether we are loading an existing file
* @throws \whikloj\BagItTools\Exceptions\FilesystemException
* Unable to read manifest file.
*/
public function __construct(Bag $bag, string $algorithm, bool $load = false)
{
parent::__construct($bag, $algorithm, "manifest-$algorithm.txt", $load);
Expand Down
24 changes: 14 additions & 10 deletions src/TagManifest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools;

/**
Expand All @@ -11,16 +13,18 @@
*/
class TagManifest extends AbstractManifest
{
/**
* PayloadManifest constructor.
*
* @param \whikloj\BagItTools\Bag $bag
* The bag this manifest is part of.
* @param string $algorithm
* The BagIt name of the hash algorithm.
* @param boolean $load
* Whether we are loading an existing file
*/
/**
* PayloadManifest constructor.
*
* @param \whikloj\BagItTools\Bag $bag
* The bag this manifest is part of.
* @param string $algorithm
* The BagIt name of the hash algorithm.
* @param boolean $load
* Whether we are loading an existing file
* @throws \whikloj\BagItTools\Exceptions\FilesystemException
* Unable to read manifest file.
*/
public function __construct(Bag $bag, string $algorithm, bool $load = false)
{
parent::__construct($bag, $algorithm, "tagmanifest-$algorithm.txt", $load);
Expand Down
2 changes: 2 additions & 0 deletions tests/BagInternalTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use ReflectionClass;
Expand Down
2 changes: 2 additions & 0 deletions tests/BagItTestFramework.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use PHPUnit\Framework\TestCase;
Expand Down
6 changes: 4 additions & 2 deletions tests/BagTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use whikloj\BagItTools\Bag;
Expand Down Expand Up @@ -823,7 +825,7 @@ public function testUpdateV07(): void
$this->assertTrue($bag->validate());
$fp = fopen($bag->getBagRoot() . DIRECTORY_SEPARATOR . 'bag-info.txt', 'r');
while (!feof($fp)) {
$line = fgets($fp);
$line = (string) fgets($fp);
$line = trim($line);
if (empty($line)) {
continue;
Expand All @@ -837,7 +839,7 @@ public function testUpdateV07(): void
$this->assertTrue($bag->validate());
$fp = fopen($bag->getBagRoot() . DIRECTORY_SEPARATOR . 'bag-info.txt', 'r');
while (!feof($fp)) {
$line = fgets($fp);
$line = (string) fgets($fp);
$line = trim($line);
if (empty($line)) {
continue;
Expand Down
2 changes: 2 additions & 0 deletions tests/BagUtilsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions tests/CommandTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use Symfony\Component\Console\Application;
Expand Down
2 changes: 2 additions & 0 deletions tests/ExtendedBagTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use whikloj\BagItTools\Bag;
Expand Down
2 changes: 2 additions & 0 deletions tests/FetchTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use donatj\MockWebServer\MockWebServer;
Expand Down
2 changes: 2 additions & 0 deletions tests/ManifestTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace whikloj\BagItTools\Test;

use whikloj\BagItTools\Bag;
Expand Down

0 comments on commit 968d359

Please sign in to comment.