Skip to content

Commit d44342f

Browse files
committed
Code-style cleanup.
- Public before private properties. - Magic before public before private methods.
1 parent 1bb58f2 commit d44342f

File tree

4 files changed

+405
-403
lines changed

4 files changed

+405
-403
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
5757
[2021.06.10; Maikuolan]: Added a flag for successful hits against blacklisted filetypes (needed by the upload handler for a newly added configuration directive). Also did some very minor refactoring.
5858

5959
[2021.09.05; Maikuolan]: Precaution against potential future undefined index added to fallback method.
60+
61+
[2021.10.30; Maikuolan]: Code-style cleanup: Public before private properties, magic before public before private methods.

src/Loader.php

Lines changed: 41 additions & 41 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.09.05).
11+
* This file: The loader (last modified: 2021.10.30).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -1127,46 +1127,6 @@ public function hexSafe(string $Data): string
11271127
return ($Data && !preg_match('/[^\da-f]/i', $Data) && !(strlen($Data) % 2)) ? hex2bin($Data) : '';
11281128
}
11291129

1130-
/**
1131-
* Initialise the cache.
1132-
*
1133-
* @throws Exception if using flatfiles for caching and if an appropriate
1134-
* cache directory hasn't been specified or can't be written to.
1135-
* @return void
1136-
*/
1137-
private function initialiseCache(): void
1138-
{
1139-
/** Exit early if already initialised. */
1140-
if ($this->Cache instanceof \Maikuolan\Common\Cache) {
1141-
return;
1142-
}
1143-
1144-
/** Create new cache object. */
1145-
$this->Cache = new \Maikuolan\Common\Cache();
1146-
$this->Cache->EnableAPCu = $this->Configuration['supplementary_cache_options']['enable_apcu'];
1147-
$this->Cache->EnableMemcached = $this->Configuration['supplementary_cache_options']['enable_memcached'];
1148-
$this->Cache->EnableRedis = $this->Configuration['supplementary_cache_options']['enable_redis'];
1149-
$this->Cache->EnablePDO = $this->Configuration['supplementary_cache_options']['enable_pdo'];
1150-
$this->Cache->MemcachedHost = $this->Configuration['supplementary_cache_options']['memcached_host'];
1151-
$this->Cache->MemcachedPort = $this->Configuration['supplementary_cache_options']['memcached_port'];
1152-
$this->Cache->RedisHost = $this->Configuration['supplementary_cache_options']['redis_host'];
1153-
$this->Cache->RedisPort = $this->Configuration['supplementary_cache_options']['redis_port'];
1154-
$this->Cache->RedisTimeout = $this->Configuration['supplementary_cache_options']['redis_timeout'];
1155-
$this->Cache->PDOdsn = $this->Configuration['supplementary_cache_options']['pdo_dsn'];
1156-
$this->Cache->PDOusername = $this->Configuration['supplementary_cache_options']['pdo_username'];
1157-
$this->Cache->PDOpassword = $this->Configuration['supplementary_cache_options']['pdo_password'];
1158-
1159-
/** Assign cache path. */
1160-
if ($this->CachePath) {
1161-
$this->Cache->FFDefault = $this->CachePath . DIRECTORY_SEPARATOR . 'cache.dat';
1162-
}
1163-
1164-
/** Attempt to connect. */
1165-
if (!$this->Cache->connect()) {
1166-
throw new \Exception('Cache connect failed.');
1167-
}
1168-
}
1169-
11701130
/**
11711131
* Fetch favicon.
11721132
*
@@ -1316,4 +1276,44 @@ public function atHit(string $Hash, int $Size = -1, string $Name = '', string $T
13161276
/** Update flags. */
13171277
$this->InstanceCache['CheckWasLast'] = false;
13181278
}
1279+
1280+
/**
1281+
* Initialise the cache.
1282+
*
1283+
* @throws Exception if using flatfiles for caching and if an appropriate
1284+
* cache directory hasn't been specified or can't be written to.
1285+
* @return void
1286+
*/
1287+
private function initialiseCache(): void
1288+
{
1289+
/** Exit early if already initialised. */
1290+
if ($this->Cache instanceof \Maikuolan\Common\Cache) {
1291+
return;
1292+
}
1293+
1294+
/** Create new cache object. */
1295+
$this->Cache = new \Maikuolan\Common\Cache();
1296+
$this->Cache->EnableAPCu = $this->Configuration['supplementary_cache_options']['enable_apcu'];
1297+
$this->Cache->EnableMemcached = $this->Configuration['supplementary_cache_options']['enable_memcached'];
1298+
$this->Cache->EnableRedis = $this->Configuration['supplementary_cache_options']['enable_redis'];
1299+
$this->Cache->EnablePDO = $this->Configuration['supplementary_cache_options']['enable_pdo'];
1300+
$this->Cache->MemcachedHost = $this->Configuration['supplementary_cache_options']['memcached_host'];
1301+
$this->Cache->MemcachedPort = $this->Configuration['supplementary_cache_options']['memcached_port'];
1302+
$this->Cache->RedisHost = $this->Configuration['supplementary_cache_options']['redis_host'];
1303+
$this->Cache->RedisPort = $this->Configuration['supplementary_cache_options']['redis_port'];
1304+
$this->Cache->RedisTimeout = $this->Configuration['supplementary_cache_options']['redis_timeout'];
1305+
$this->Cache->PDOdsn = $this->Configuration['supplementary_cache_options']['pdo_dsn'];
1306+
$this->Cache->PDOusername = $this->Configuration['supplementary_cache_options']['pdo_username'];
1307+
$this->Cache->PDOpassword = $this->Configuration['supplementary_cache_options']['pdo_password'];
1308+
1309+
/** Assign cache path. */
1310+
if ($this->CachePath) {
1311+
$this->Cache->FFDefault = $this->CachePath . DIRECTORY_SEPARATOR . 'cache.dat';
1312+
}
1313+
1314+
/** Attempt to connect. */
1315+
if (!$this->Cache->connect()) {
1316+
throw new \Exception('Cache connect failed.');
1317+
}
1318+
}
13191319
}

src/PdfHandler.php

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

1414
namespace phpMussel\Core;
@@ -30,35 +30,6 @@ class PdfHandler extends ArchiveHandler
3030
*/
3131
private $Index = -1;
3232

33-
/**
34-
* Needed to decode Ascii85 data (since PDF files sometimes use this).
35-
* This method adapted from the base85 class authored by Scott Baker.
36-
* @link https://bitbucket.org/scottchiefbaker/php-base85/src/master/
37-
* @license https://bitbucket.org/scottchiefbaker/php-base85/src/master/LICENSE GNU/GPLv3
38-
*
39-
* @param string $In The data to be decoded.
40-
* @return string The decoded data.
41-
*/
42-
public function base85_decode(string $In): string
43-
{
44-
$In = str_replace(["\t", "\r", "\n", "\f", '/z/', '/y/'], ['', '', '', '', '!!!!!', '+<VdL/'], $In);
45-
$Len = strlen($In);
46-
$Padding = ($Len % 5 === 0) ? 0 : 5 - ($Len % 5);
47-
$In .= str_repeat('u', $Padding);
48-
$Num = 0;
49-
$Out = '';
50-
while ($Chunk = substr($In, $Num * 5, 5)) {
51-
$Char = 0;
52-
foreach (unpack('C*', $Chunk) as $ThisChar) {
53-
$Char *= 85;
54-
$Char += $ThisChar - 33;
55-
}
56-
$Out .= pack('N', $Char);
57-
$Num++;
58-
}
59-
return substr($Out, 0, strlen($Out) - $Padding);
60-
}
61-
6233
/**
6334
* Construct the instance.
6435
*
@@ -328,6 +299,35 @@ public function __construct(string $File)
328299
$this->ErrorState = 0;
329300
}
330301

302+
/**
303+
* Needed to decode Ascii85 data (since PDF files sometimes use this).
304+
* This method adapted from the base85 class authored by Scott Baker.
305+
* @link https://bitbucket.org/scottchiefbaker/php-base85/src/master/
306+
* @license https://bitbucket.org/scottchiefbaker/php-base85/src/master/LICENSE GNU/GPLv3
307+
*
308+
* @param string $In The data to be decoded.
309+
* @return string The decoded data.
310+
*/
311+
public function base85_decode(string $In): string
312+
{
313+
$In = str_replace(["\t", "\r", "\n", "\f", '/z/', '/y/'], ['', '', '', '', '!!!!!', '+<VdL/'], $In);
314+
$Len = strlen($In);
315+
$Padding = ($Len % 5 === 0) ? 0 : 5 - ($Len % 5);
316+
$In .= str_repeat('u', $Padding);
317+
$Num = 0;
318+
$Out = '';
319+
while ($Chunk = substr($In, $Num * 5, 5)) {
320+
$Char = 0;
321+
foreach (unpack('C*', $Chunk) as $ThisChar) {
322+
$Char *= 85;
323+
$Char += $ThisChar - 33;
324+
}
325+
$Out .= pack('N', $Char);
326+
$Num++;
327+
}
328+
return substr($Out, 0, strlen($Out) - $Padding);
329+
}
330+
331331
/**
332332
* Return the actual entry in the archive at the current entry pointer.
333333
*

0 commit comments

Comments
 (0)