Skip to content

Commit b995a9d

Browse files
committed
Various minor performance improvements.
1 parent 2f3b391 commit b995a9d

File tree

8 files changed

+802
-798
lines changed

8 files changed

+802
-798
lines changed

src/CompressionHandler.php

Lines changed: 4 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: Compression handler (last modified: 2023.09.25).
11+
* This file: Compression handler (last modified: 2026.03.17).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -39,7 +39,7 @@ public function __construct(string $Data)
3939
public function TryGz(): int
4040
{
4141
/** Guard. */
42-
if (substr($this->Data, 0, 2) !== "\x1f\x8b") {
42+
if (\substr($this->Data, 0, 2) !== "\x1f\x8b") {
4343
return 2;
4444
}
4545

@@ -55,7 +55,7 @@ public function TryGz(): int
5555
public function TryBz(): int
5656
{
5757
/** Guard. */
58-
if (substr($this->Data, 0, 3) !== "\x42\x5a\x68") {
58+
if (\substr($this->Data, 0, 3) !== "\x42\x5a\x68") {
5959
return 2;
6060
}
6161

@@ -135,7 +135,7 @@ private function TryX(string $Using): int
135135
$Try = $Using($this->Data);
136136

137137
/** Success. */
138-
if ($Try !== false && is_string($Try)) {
138+
if ($Try !== false && \is_string($Try)) {
139139
$this->Data = $Try;
140140
return 0;
141141
}

src/Loader.php

Lines changed: 162 additions & 158 deletions
Large diffs are not rendered by default.

src/PdfHandler.php

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

src/RarHandler.php

Lines changed: 17 additions & 17 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.07.10).
11+
* This file: Rar handler (last modified: 2026.03.17).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -44,19 +44,19 @@ class RarHandler extends ArchiveHandler
4444
public function __construct($Pointer)
4545
{
4646
/** Rar class requirements guard. */
47-
if (!class_exists('\RarArchive') || !class_exists('\RarEntry')) {
47+
if (!\class_exists('\RarArchive') || !\class_exists('\RarEntry')) {
4848
$this->ErrorState = 1;
4949
return;
5050
}
5151

5252
/** Bad pointer guard. */
53-
if (!is_readable($Pointer)) {
53+
if (!\is_readable($Pointer)) {
5454
$this->ErrorState = 2;
5555
return;
5656
}
5757

5858
$this->RarObject = \RarArchive::open($Pointer);
59-
$this->ErrorState = is_object($this->RarObject) ? 0 : 2;
59+
$this->ErrorState = \is_object($this->RarObject) ? 0 : 2;
6060
$this->PointerSelf = $Pointer;
6161
}
6262

@@ -67,7 +67,7 @@ public function __construct($Pointer)
6767
*/
6868
public function __destruct()
6969
{
70-
if (is_object($this->RarObject) && $this->ErrorState === 0) {
70+
if (\is_object($this->RarObject) && $this->ErrorState === 0) {
7171
$this->RarObject->close();
7272
}
7373
}
@@ -86,8 +86,8 @@ public function EntryRead(int $Bytes = -1): string
8686
}
8787
$Output = '';
8888
if ($Bytes > 0 && ($Stream = $this->RarEntry->getStream())) {
89-
$Output .= fread($Stream, $this->RarEntry->getUnpackedSize());
90-
fclose($Stream);
89+
$Output .= \fread($Stream, $this->RarEntry->getUnpackedSize());
90+
\fclose($Stream);
9191
}
9292
return $Output;
9393
}
@@ -99,7 +99,7 @@ public function EntryRead(int $Bytes = -1): string
9999
*/
100100
public function EntryCompressedSize(): int
101101
{
102-
return is_object($this->RarEntry) ? (int)$this->RarEntry->getPackedSize() : 0;
102+
return \is_object($this->RarEntry) ? (int)$this->RarEntry->getPackedSize() : 0;
103103
}
104104

105105
/**
@@ -109,7 +109,7 @@ public function EntryCompressedSize(): int
109109
*/
110110
public function EntryActualSize(): int
111111
{
112-
return is_object($this->RarEntry) ? (int)$this->RarEntry->getUnpackedSize() : 0;
112+
return \is_object($this->RarEntry) ? (int)$this->RarEntry->getUnpackedSize() : 0;
113113
}
114114

115115
/**
@@ -119,7 +119,7 @@ public function EntryActualSize(): int
119119
*/
120120
public function EntryIsDirectory(): bool
121121
{
122-
return is_object($this->RarEntry) ? $this->RarEntry->isDirectory() : false;
122+
return \is_object($this->RarEntry) ? $this->RarEntry->isDirectory() : false;
123123
}
124124

125125
/**
@@ -129,7 +129,7 @@ public function EntryIsDirectory(): bool
129129
*/
130130
public function EntryIsEncrypted(): bool
131131
{
132-
return is_object($this->RarEntry) ? $this->RarEntry->isEncrypted() : false;
132+
return \is_object($this->RarEntry) ? $this->RarEntry->isEncrypted() : false;
133133
}
134134

135135
/**
@@ -139,7 +139,7 @@ public function EntryIsEncrypted(): bool
139139
*/
140140
public function EntryCRC(): string
141141
{
142-
return is_object($this->RarEntry) ? (string)$this->RarEntry->getCrc() : '';
142+
return \is_object($this->RarEntry) ? (string)$this->RarEntry->getCrc() : '';
143143
}
144144

145145
/**
@@ -150,9 +150,9 @@ public function EntryCRC(): string
150150
*/
151151
public function EntryName(): string
152152
{
153-
if (is_object($this->RarEntry)) {
153+
if (\is_object($this->RarEntry)) {
154154
$Try = $this->RarEntry->getName();
155-
if (is_string($Try)) {
155+
if (\is_string($Try)) {
156156
return $Try;
157157
}
158158
}
@@ -166,11 +166,11 @@ public function EntryName(): string
166166
*/
167167
public function EntryNext(): bool
168168
{
169-
if (!is_array($this->RarEntries)) {
169+
if (!\is_array($this->RarEntries)) {
170170
$this->RarEntries = scandir('rar://' . $this->PointerSelf);
171171
}
172-
if (is_array($this->RarEntries) && !empty($this->RarEntries)) {
173-
$this->RarEntry = $this->RarObject->getEntry(array_shift($this->RarEntries));
172+
if (\is_array($this->RarEntries) && !empty($this->RarEntries)) {
173+
$this->RarEntry = $this->RarObject->getEntry(\array_shift($this->RarEntries));
174174
return true;
175175
}
176176
return false;

0 commit comments

Comments
 (0)