Skip to content

Commit 7bd68b2

Browse files
committed
Very minor refactoring.
1 parent b0d100b commit 7bd68b2

9 files changed

+68
-23
lines changed

src/ArchiveHandlerInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Archive handler (last modified: 2021.03.11).
11+
* This file: Archive handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -24,6 +24,7 @@ interface ArchiveHandlerInterface
2424
* Return the actual entry in the archive at the current entry pointer.
2525
*
2626
* @param int $Bytes Optionally, how many bytes to read from the entry.
27+
* @return string The entry's content or an empty string.
2728
*/
2829
public function EntryRead(int $Bytes = -1);
2930

@@ -64,8 +65,11 @@ public function EntryCRC(): string;
6465

6566
/**
6667
* Return the name of the entry at the current entry pointer.
68+
*
69+
* @return string The name of the entry at the current entry pointer, or an
70+
* empty string if there's no entry or if the entry pointer is invalid.
6771
*/
68-
public function EntryName();
72+
public function EntryName(): string;
6973

7074
/**
7175
* Move the entry pointer ahead.

src/CompressionHandler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Compression handler (last modified: 2020.11.27).
11+
* This file: Compression handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -21,7 +21,10 @@ class CompressionHandler
2121
public $Data = '';
2222

2323
/**
24+
* Constructor.
25+
*
2426
* @param string $Data The data to be worked upon.
27+
* @return void
2528
*/
2629
public function __construct(string $Data)
2730
{

src/Loader.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The loader (last modified: 2021.05.28).
11+
* This file: The loader (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -88,7 +88,7 @@ class Loader
8888
/**
8989
* @var string phpMussel version number (SemVer).
9090
*/
91-
public $ScriptVersion = '3.2.1';
91+
public $ScriptVersion = '3.2.2';
9292

9393
/**
9494
* @var string phpMussel version identifier (complete notation).
@@ -190,6 +190,7 @@ class Loader
190190
* @throws Exception if the PHP version requirements aren't met, if the
191191
* vendor directory can't be located, or if the phpMussel
192192
* configuration file can't be located.
193+
* @return void
193194
*/
194195
public function __construct(
195196
string $ConfigurationPath = '',
@@ -418,6 +419,8 @@ public function __construct(
418419

419420
/**
420421
* Destruct the loader.
422+
*
423+
* @return void
421424
*/
422425
public function __destruct()
423426
{

src/PdfHandler.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Pdf handler (last modified: 2021.03.11).
11+
* This file: Pdf handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -63,6 +63,7 @@ public function base85_decode(string $In): string
6363
* Construct the instance.
6464
*
6565
* @param string $File
66+
* @return void
6667
*/
6768
public function __construct(string $File)
6869
{
@@ -384,7 +385,7 @@ public function EntryIsEncrypted(): bool
384385
/**
385386
* Return the reported internal CRC hash for the entry, if it exists.
386387
*
387-
* @return string Empty because PDF doesn't provide internal CRCs.
388+
* @return string Empty because Pdf doesn't provide internal CRCs.
388389
*/
389390
public function EntryCRC(): string
390391
{
@@ -394,11 +395,11 @@ public function EntryCRC(): string
394395
/**
395396
* Return the name of the entry at the current entry pointer.
396397
*
397-
* @return string
398+
* @return string Using 'PDFStream' because entries here don't have names.
398399
*/
399400
public function EntryName(): string
400401
{
401-
return $this->Objects[$this->Index]['EntryName'] ?? 'PDFStream';
402+
return 'PDFStream';
402403
}
403404

404405
/**

src/RarHandler.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Rar handler (last modified: 2021.03.11).
11+
* This file: Rar handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -39,6 +39,7 @@ class RarHandler extends ArchiveHandler
3939
* Construct the rar archive object.
4040
*
4141
* @param string $Pointer
42+
* @return void
4243
*/
4344
public function __construct($Pointer)
4445
{
@@ -59,7 +60,11 @@ public function __construct($Pointer)
5960
$this->PointerSelf = $Pointer;
6061
}
6162

62-
/** Destruct the Rar archive object. */
63+
/**
64+
* Destruct the Rar archive object.
65+
*
66+
* @return void
67+
*/
6368
public function __destruct()
6469
{
6570
if (is_object($this->RarObject) && $this->ErrorState === 0) {
@@ -139,10 +144,19 @@ public function EntryCRC(): string
139144

140145
/**
141146
* Return the name of the entry at the current entry pointer.
147+
*
148+
* @return string The name of the entry at the current entry pointer, or an
149+
* empty string if there's no entry or if the entry pointer is invalid.
142150
*/
143-
public function EntryName()
151+
public function EntryName(): string
144152
{
145-
return is_object($this->RarEntry) ? $this->RarEntry->getName() : false;
153+
if (is_object($this->RarEntry)) {
154+
$Try = $this->RarEntry->getName();
155+
if (is_string($Try)) {
156+
return $Try;
157+
}
158+
}
159+
return '';
146160
}
147161

148162
/**

src/Scanner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The scanner (last modified: 2021.06.10).
11+
* This file: The scanner (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -60,6 +60,7 @@ class Scanner
6060
* Construct the scanner.
6161
*
6262
* @param \phpMussel\Core\Loader $Loader The instantiated loader object, passed by reference.
63+
* @return void
6364
*/
6465
public function __construct(\phpMussel\Core\Loader &$Loader)
6566
{

src/TarHandler.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Tar handler (last modified: 2021.03.11).
11+
* This file: Tar handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -39,6 +39,7 @@ class TarHandler extends ArchiveHandler
3939
* Construct the tar archive object.
4040
*
4141
* @param string $File
42+
* @return void
4243
*/
4344
public function __construct($File)
4445
{
@@ -119,7 +120,7 @@ public function EntryIsEncrypted(): bool
119120
/**
120121
* Return the reported internal CRC hash for the entry, if it exists.
121122
*
122-
* @return string Empty because TAR doesn't provide internal CRCs.
123+
* @return string Empty because Tar doesn't provide internal CRCs.
123124
*/
124125
public function EntryCRC(): string
125126
{
@@ -128,8 +129,11 @@ public function EntryCRC(): string
128129

129130
/**
130131
* Return the name of the entry at the current entry pointer.
132+
*
133+
* @return string The name of the entry at the current entry pointer, or an
134+
* empty string if there's no entry or if the entry pointer is invalid.
131135
*/
132-
public function EntryName()
136+
public function EntryName(): string
133137
{
134138
return preg_replace('/[^\x20-\xff]/', '', substr($this->Data, $this->Offset, 100));
135139
}

src/TemporaryFileHandler.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Temporary file handler (last modified: 2020.07.04).
11+
* This file: Temporary file handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -21,8 +21,11 @@ class TemporaryFileHandler
2121
public $Filename = '';
2222

2323
/**
24+
* Constructor.
25+
*
2426
* @param string $Content The temporary file content.
2527
* @param string $Location The temporary file location.
28+
* @return void
2629
*/
2730
public function __construct(string $Content, string $Location)
2831
{
@@ -49,7 +52,11 @@ public function __construct(string $Content, string $Location)
4952
}
5053
}
5154

52-
/** Destructor will unlink the temporary file upon object destruction. */
55+
/**
56+
* Destructor will unlink the temporary file upon object destruction.
57+
*
58+
* @return void
59+
*/
5360
public function __destruct()
5461
{
5562
if ($this->Filename && file_exists($this->Filename)) {

src/ZipHandler.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Zip handler (last modified: 2021.03.11).
11+
* This file: Zip handler (last modified: 2021.07.10).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -39,6 +39,7 @@ class ZipHandler extends ArchiveHandler
3939
* Construct the zip archive object.
4040
*
4141
* @param string $Pointer
42+
* @return void
4243
*/
4344
public function __construct($Pointer)
4445
{
@@ -63,7 +64,11 @@ public function __construct($Pointer)
6364
$this->NumFiles = $this->ZipObject->numFiles;
6465
}
6566

66-
/** Destruct the Zip archive object. */
67+
/**
68+
* Destruct the Zip archive object.
69+
*
70+
* @return void
71+
*/
6772
public function __destruct()
6873
{
6974
if (is_object($this->ZipObject) && $this->ErrorState === 0) {
@@ -138,10 +143,13 @@ public function EntryCRC(): string
138143

139144
/**
140145
* Return the name of the entry at the current entry pointer.
146+
*
147+
* @return string The name of the entry at the current entry pointer, or an
148+
* empty string if there's no entry or if the entry pointer is invalid.
141149
*/
142-
public function EntryName()
150+
public function EntryName(): string
143151
{
144-
return isset($this->StatIndex['name']) ? $this->StatIndex['name'] : '';
152+
return (isset($this->StatIndex['name']) && is_string($this->StatIndex['name'])) ? $this->StatIndex['name'] : '';
145153
}
146154

147155
/**

0 commit comments

Comments
 (0)