Ver código fonte

style: make StyleCI happy

rugk 2 semanas atrás
pai
commit
9bdae9f3b8

+ 5 - 5
lib/Controller.php

@@ -189,7 +189,7 @@ class Controller
      */
     private function _init()
     {
-        $this->_model   = new Model($this->_conf);
+        $this->_model = new Model($this->_conf);
         $this->_request = new Request;
         $this->_urlBase = $this->_request->getRequestUri();
 
@@ -226,7 +226,7 @@ class Controller
     private function _setDefaultTemplate()
     {
         $templates = $this->_conf->getKey('availabletemplates');
-        $template  = $this->_conf->getKey('template');
+        $template = $this->_conf->getKey('template');
         if (!in_array($template, $templates, true)) {
             $templates[] = $template;
         }
@@ -287,7 +287,7 @@ class Controller
             return;
         }
 
-        $data      = $this->_request->getData();
+        $data = $this->_request->getData();
         $isComment = array_key_exists('pasteid', $data) &&
             !empty($data['pasteid']) &&
             array_key_exists('parentid', $data) &&
@@ -356,7 +356,7 @@ class Controller
                 if (hash_equals($paste->getDeleteToken(), $deletetoken)) {
                     // Document exists and deletion token is valid: Delete the it.
                     $paste->delete();
-                    $this->_status     = 'Document was properly deleted.';
+                    $this->_status = 'Document was properly deleted.';
                     $this->_is_deleted = true;
                 } else {
                     $this->_error = 'Wrong deletion token. Document was not deleted.';
@@ -517,7 +517,7 @@ class Controller
             $type = '';
         }
         $content = '{}';
-        $file    = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $type . '.jsonld';
+        $file = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $type . '.jsonld';
         if (is_readable($file)) {
             $content = str_replace(
                 '?jsonld=',

+ 20 - 20
lib/Data/Database.php

@@ -71,12 +71,12 @@ class Database extends AbstractData
             array_key_exists('opt', $options)
         ) {
             // set default options
-            $options['opt'][PDO::ATTR_ERRMODE]          = PDO::ERRMODE_EXCEPTION;
+            $options['opt'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
             $options['opt'][PDO::ATTR_EMULATE_PREPARES] = false;
             if (!array_key_exists(PDO::ATTR_PERSISTENT, $options['opt'])) {
                 $options['opt'][PDO::ATTR_PERSISTENT] = true;
             }
-            $db_tables_exist                            = true;
+            $db_tables_exist = true;
 
             // setup type and dabase connection
             $this->_type = strtolower(
@@ -93,7 +93,7 @@ class Database extends AbstractData
                 }
             }
             $tableQuery = $this->_getTableQuery($this->_type);
-            $this->_db  = new PDO(
+            $this->_db = new PDO(
                 $options['dsn'],
                 $options['usr'],
                 $options['pwd'],
@@ -148,8 +148,8 @@ class Database extends AbstractData
      */
     public function create($pasteid, array &$paste)
     {
-        $expire_date      = 0;
-        $meta             = $paste['meta'];
+        $expire_date = 0;
+        $meta = $paste['meta'];
         if (array_key_exists('expire_date', $meta)) {
             $expire_date = (int) $meta['expire_date'];
             unset($meta['expire_date']);
@@ -316,11 +316,11 @@ class Database extends AbstractData
                     error_log('Error while reading a comment from the database: ' . $e->getMessage());
                     $data = [];
                 }
-                $i                          = $this->getOpenSlot($comments, (int) $row['postdate']);
-                $comments[$i]               = $data;
-                $comments[$i]['id']         = $row['dataid'];
-                $comments[$i]['parentid']   = $row['parentid'];
-                $comments[$i]['meta']       = ['created' => (int) $row['postdate']];
+                $i = $this->getOpenSlot($comments, (int) $row['postdate']);
+                $comments[$i] = $data;
+                $comments[$i]['id'] = $row['dataid'];
+                $comments[$i]['parentid'] = $row['parentid'];
+                $comments[$i]['meta'] = ['created' => (int) $row['postdate']];
                 if (array_key_exists('vizhash', $row) && !empty($row['vizhash'])) {
                     $comments[$i]['meta']['icon'] = $row['vizhash'];
                 }
@@ -389,7 +389,7 @@ class Database extends AbstractData
     public function getValue($namespace, $key = '')
     {
         $configKey = strtoupper($namespace);
-        $value     = $this->_getConfig($configKey);
+        $value = $this->_getConfig($configKey);
         if ($value === '') {
             // initialize the row, so that setValue can rely on UPDATE queries
             $this->_exec(
@@ -401,7 +401,7 @@ class Database extends AbstractData
             // migrate filesystem based salt into database
             $file = 'data' . DIRECTORY_SEPARATOR . 'salt.php';
             if ($namespace === 'salt' && is_readable($file)) {
-                $fs    = new Filesystem(['dir' => 'data']);
+                $fs = new Filesystem(['dir' => 'data']);
                 $value = $fs->getValue('salt');
                 $this->setValue($value, 'salt');
                 if (!unlink($file)) {
@@ -469,7 +469,7 @@ class Database extends AbstractData
     private function _exec($sql, array $params)
     {
         $statement = $this->_db->prepare($sql);
-        $position  = 1;
+        $position = 1;
         foreach ($params as &$parameter) {
             if (is_int($parameter)) {
                 $statement->bindParam($position, $parameter, PDO::PARAM_INT);
@@ -672,8 +672,8 @@ class Database extends AbstractData
     private function _createPasteTable()
     {
         list($main_key, $after_key) = $this->_getPrimaryKeyClauses();
-        $attachmentType             = $this->_getAttachmentType();
-        $metaType                   = $this->_getMetaType();
+        $attachmentType = $this->_getAttachmentType();
+        $metaType = $this->_getMetaType();
         $this->_db->exec(
             'CREATE TABLE "' . $this->_sanitizeIdentifier('paste') . '" ( ' .
             "\"dataid\" CHAR(16) NOT NULL$main_key, " .
@@ -691,7 +691,7 @@ class Database extends AbstractData
     private function _createCommentTable()
     {
         list($main_key, $after_key) = $this->_getPrimaryKeyClauses();
-        $dataType                   = $this->_getDataType();
+        $dataType = $this->_getDataType();
         $this->_db->exec(
             'CREATE TABLE "' . $this->_sanitizeIdentifier('comment') . '" ( ' .
             "\"dataid\" CHAR(16) NOT NULL$main_key, " .
@@ -733,8 +733,8 @@ class Database extends AbstractData
     private function _createConfigTable()
     {
         list($main_key, $after_key) = $this->_getPrimaryKeyClauses('id');
-        $charType                   = $this->_type === 'oci' ? 'VARCHAR2(16)' : 'CHAR(16)';
-        $textType                   = $this->_getMetaType();
+        $charType = $this->_type === 'oci' ? 'VARCHAR2(16)' : 'CHAR(16)';
+        $textType = $this->_getMetaType();
         $this->_db->exec(
             'CREATE TABLE "' . $this->_sanitizeIdentifier('config') .
             "\" ( \"id\" $charType NOT NULL$main_key, \"value\" $textType$after_key )"
@@ -787,7 +787,7 @@ class Database extends AbstractData
         $supportsDropColumn = true;
         if ($this->_type === 'sqlite') {
             try {
-                $row                = $this->_select('SELECT sqlite_version() AS "v"', [], true);
+                $row = $this->_select('SELECT sqlite_version() AS "v"', [], true);
                 $supportsDropColumn = (bool) version_compare($row['v'], '3.35.0', '>=');
             } catch (PDOException $e) {
                 $supportsDropColumn = false;
@@ -804,7 +804,7 @@ class Database extends AbstractData
      */
     private function _upgradeDatabase($oldversion)
     {
-        $dataType       = $this->_getDataType();
+        $dataType = $this->_getDataType();
         $attachmentType = $this->_getAttachmentType();
         if (version_compare($oldversion, '0.21', '<=')) {
             // create the meta column if necessary (pre 0.21 change)

+ 12 - 12
lib/Data/Filesystem.php

@@ -95,7 +95,7 @@ class Filesystem extends AbstractData
     public function create($pasteid, array &$paste)
     {
         $storagedir = $this->_dataid2path($pasteid);
-        $file       = $storagedir . $pasteid . '.php';
+        $file = $storagedir . $pasteid . '.php';
         if (is_file($file)) {
             return false;
         }
@@ -163,7 +163,7 @@ class Filesystem extends AbstractData
      */
     public function exists($pasteid)
     {
-        $basePath  = $this->_dataid2path($pasteid) . $pasteid;
+        $basePath = $this->_dataid2path($pasteid) . $pasteid;
         $pastePath = $basePath . '.php';
         // convert to PHP protected files if needed
         if (is_readable($basePath)) {
@@ -197,7 +197,7 @@ class Filesystem extends AbstractData
     public function createComment($pasteid, $parentid, $commentid, array &$comment)
     {
         $storagedir = $this->_dataid2discussionpath($pasteid);
-        $file       = $storagedir . $pasteid . '.' . $commentid . '.' . $parentid . '.php';
+        $file = $storagedir . $pasteid . '.' . $commentid . '.' . $parentid . '.php';
         if (is_file($file)) {
             return false;
         }
@@ -217,7 +217,7 @@ class Filesystem extends AbstractData
     public function readComments($pasteid)
     {
         $comments = [];
-        $discdir  = $this->_dataid2discussionpath($pasteid);
+        $discdir = $this->_dataid2discussionpath($pasteid);
         if (is_dir($discdir)) {
             foreach (new GlobIterator($discdir . DIRECTORY_SEPARATOR . $pasteid .
                 '.' . self::ID_PATTERN . '.' . self::ID_PATTERN . '.php') as $file
@@ -237,11 +237,11 @@ class Filesystem extends AbstractData
                     }
                     $items = explode('.', $file->getBasename('.php'));
                     // Add some meta information not contained in file.
-                    $comment['id']       = $items[1];
+                    $comment['id'] = $items[1];
                     $comment['parentid'] = $items[2];
 
                     // Store in array
-                    $key            = $this->getOpenSlot(
+                    $key = $this->getOpenSlot(
                         $comments,
                         $comment['meta']['created']
                     );
@@ -293,7 +293,7 @@ class Filesystem extends AbstractData
                 break;
             case 'traffic_limiter':
                 $this->_last_cache[$key] = $value;
-                $content                 = '<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';';
+                $content = '<?php' . PHP_EOL . '$GLOBALS[\'traffic_limiter\'] = ' . var_export($this->_last_cache, true) . ';';
                 break;
             default:
                 return false;
@@ -377,11 +377,11 @@ class Filesystem extends AbstractData
     protected function _getExpiredPastes($batchsize)
     {
         $pastes = [];
-        $count  = 0;
+        $count = 0;
         $opened = 0;
-        $limit  = $batchsize * 10; // try at most 10 times $batchsize pastes before giving up
-        $time   = time();
-        $files  = $this->getAllPastes();
+        $limit = $batchsize * 10; // try at most 10 times $batchsize pastes before giving up
+        $time = time();
+        $files = $this->getAllPastes();
         shuffle($files);
         foreach ($files as $pasteid) {
             if ($this->exists($pasteid)) {
@@ -506,7 +506,7 @@ class Filesystem extends AbstractData
             }
         }
 
-        $fileCreated  = true;
+        $fileCreated = true;
         $writtenBytes = 0;
         if (!is_file($filename)) {
             $fileCreated = @touch($filename);

+ 7 - 7
lib/Data/GoogleCloudStorage.php

@@ -151,7 +151,7 @@ class GoogleCloudStorage extends AbstractData
     public function read($pasteid)
     {
         try {
-            $o    = $this->_bucket->object($this->_getKey($pasteid));
+            $o = $this->_bucket->object($this->_getKey($pasteid));
             $data = $o->downloadAsString();
             return Json::decode($data);
         } catch (NotFoundException $e) {
@@ -216,18 +216,18 @@ class GoogleCloudStorage extends AbstractData
     public function readComments($pasteid)
     {
         $comments = [];
-        $prefix   = $this->_getKey($pasteid) . '/discussion/';
+        $prefix = $this->_getKey($pasteid) . '/discussion/';
         try {
             foreach ($this->_bucket->objects(['prefix' => $prefix]) as $key) {
-                $data            = $this->_bucket->object($key->name())->downloadAsString();
+                $data = $this->_bucket->object($key->name())->downloadAsString();
                 try {
                     $comment = Json::decode($data);
                 } catch (JsonException $e) {
                     error_log('failed to read comment from ' . $key->name() . ', ' . $e->getMessage());
                     $comment = [];
                 }
-                $comment['id']   = basename($key->name());
-                $slot            = $this->getOpenSlot($comments, (int) $comment['meta']['created']);
+                $comment['id'] = basename($key->name());
+                $slot = $this->getOpenSlot($comments, (int) $comment['meta']['created']);
                 $comments[$slot] = $comment;
             }
         } catch (NotFoundException $e) {
@@ -242,7 +242,7 @@ class GoogleCloudStorage extends AbstractData
     public function existsComment($pasteid, $parentid, $commentid)
     {
         $name = $this->_getKey($pasteid) . '/discussion/' . $parentid . '/' . $commentid;
-        $o    = $this->_bucket->object($name);
+        $o = $this->_bucket->object($name);
         return $o->exists();
     }
 
@@ -335,7 +335,7 @@ class GoogleCloudStorage extends AbstractData
     {
         $expired = [];
 
-        $now    = time();
+        $now = time();
         $prefix = $this->_prefix;
         if (!empty($prefix)) {
             $prefix .= '/';

+ 13 - 13
lib/Data/S3Storage.php

@@ -87,7 +87,7 @@ class S3Storage extends AbstractData
         if (isset($options['accesskey']) && isset($options['secretkey'])) {
             $this->_options['credentials'] = [];
 
-            $this->_options['credentials']['key']    = $options['accesskey'];
+            $this->_options['credentials']['key'] = $options['accesskey'];
             $this->_options['credentials']['secret'] = $options['secretkey'];
         }
         if (array_key_exists('region', $options)) {
@@ -122,16 +122,16 @@ class S3Storage extends AbstractData
     private function _listAllObjects($prefix)
     {
         $allObjects = [];
-        $options    = [
+        $options = [
             'Bucket' => $this->_bucket,
             'Prefix' => $prefix,
         ];
 
         do {
             $objectsListResponse = $this->_client->listObjects($options);
-            $objects             = $objectsListResponse['Contents'] ?? [];
+            $objects = $objectsListResponse['Contents'] ?? [];
             foreach ($objects as $object) {
-                $allObjects[]      = $object;
+                $allObjects[] = $object;
                 $options['Marker'] = $object['Key'];
             }
         } while ($objectsListResponse['IsTruncated']);
@@ -280,7 +280,7 @@ class S3Storage extends AbstractData
     public function readComments($pasteid)
     {
         $comments = [];
-        $prefix   = $this->_getKey($pasteid) . '/discussion/';
+        $prefix = $this->_getKey($pasteid) . '/discussion/';
         try {
             $entries = $this->_listAllObjects($prefix);
             foreach ($entries as $entry) {
@@ -288,13 +288,13 @@ class S3Storage extends AbstractData
                     'Bucket' => $this->_bucket,
                     'Key'    => $entry['Key'],
                 ]);
-                $data             = $object['Body']->getContents();
-                $body             = JSON::decode($data);
-                $items            = explode('/', $entry['Key']);
-                $body['id']       = $items[3];
+                $data = $object['Body']->getContents();
+                $body = JSON::decode($data);
+                $items = explode('/', $entry['Key']);
+                $body['id'] = $items[3];
                 $body['parentid'] = $items[2];
-                $slot             = $this->getOpenSlot($comments, (int) $object['Metadata']['created']);
-                $comments[$slot]  = $body;
+                $slot = $this->getOpenSlot($comments, (int) $object['Metadata']['created']);
+                $comments[$slot] = $body;
             }
         } catch (S3Exception $e) {
             // no comments found
@@ -420,8 +420,8 @@ class S3Storage extends AbstractData
     protected function _getExpiredPastes($batchsize)
     {
         $expired = [];
-        $now     = time();
-        $prefix  = $this->_prefix;
+        $now = time();
+        $prefix = $this->_prefix;
         if (!empty($prefix)) {
             $prefix .= '/';
         }

+ 1 - 1
lib/Filter.php

@@ -60,7 +60,7 @@ class Filter
     public static function formatHumanReadableSize($size)
     {
         $iec = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
-        $i   = 0;
+        $i = 0;
         while (($size / 1000) >= 1) {
             $size = $size / 1000;
             ++$i;

+ 1 - 1
lib/Model.php

@@ -80,7 +80,7 @@ class Model
     public function getStore()
     {
         if ($this->_store === null) {
-            $class        = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
+            $class = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
             $this->_store = new $class($this->_conf->getSection('model_options'));
         }
         return $this->_store;

+ 2 - 2
lib/Model/AbstractModel.php

@@ -77,8 +77,8 @@ abstract class AbstractModel
      */
     public function __construct(Configuration $configuration, AbstractData $storage)
     {
-        $this->_conf       = $configuration;
-        $this->_store      = $storage;
+        $this->_conf = $configuration;
+        $this->_store = $storage;
     }
 
     /**

+ 5 - 5
lib/Model/Comment.php

@@ -94,7 +94,7 @@ class Comment extends AbstractModel
      */
     public function setPaste(Paste &$paste)
     {
-        $this->_paste           = $paste;
+        $this->_paste = $paste;
         $this->_data['pasteid'] = $paste->getId();
     }
 
@@ -150,10 +150,10 @@ class Comment extends AbstractModel
         $icon = $this->_conf->getKey('icon');
         if ($icon !== 'none') {
             $pngdata = '';
-            $hmac    = TrafficLimiter::getHash();
+            $hmac = TrafficLimiter::getHash();
             if ($icon === 'identicon') {
                 $identicon = new Identicon();
-                $pngdata   = $identicon->getImageDataUri($hmac, 16);
+                $pngdata = $identicon->getImageDataUri($hmac, 16);
             } elseif ($icon === 'jdenticon') {
                 $jdenticon = new Jdenticon([
                     'hash'  => $hmac,
@@ -163,9 +163,9 @@ class Comment extends AbstractModel
                         'padding'           => 0,
                     ],
                 ]);
-                $pngdata   = $jdenticon->getImageDataUri('png');
+                $pngdata = $jdenticon->getImageDataUri('png');
             } elseif ($icon === 'vizhash') {
-                $vh      = new Vizhash16x16();
+                $vh = new Vizhash16x16();
                 $pngdata = 'data:image/png;base64,' . base64_encode(
                     $vh->generate($hmac)
                 );

+ 4 - 4
lib/Model/Paste.php

@@ -77,11 +77,11 @@ class Paste extends AbstractModel
             $this->delete();
         }
 
-        $data['comments']       = array_values($this->getComments());
-        $data['comment_count']  = count($data['comments']);
+        $data['comments'] = array_values($this->getComments());
+        $data['comment_count'] = count($data['comments']);
         $data['comment_offset'] = 0;
-        $data['@context']       = '?jsonld=paste';
-        $this->_data            = $data;
+        $data['@context'] = '?jsonld=paste';
+        $this->_data = $data;
 
         return $this->_data;
     }

+ 2 - 2
lib/Persistence/PurgeLimiter.php

@@ -67,8 +67,8 @@ class PurgeLimiter extends AbstractPersistence
             return true;
         }
 
-        $now  = time();
-        $pl   = (int) self::$_store->getValue('purge_limiter');
+        $now = time();
+        $pl = (int) self::$_store->getValue('purge_limiter');
         if ($pl + self::$_limit >= $now) {
             return false;
         }

+ 3 - 3
lib/Persistence/TrafficLimiter.php

@@ -144,7 +144,7 @@ class TrafficLimiter extends AbstractPersistence
             $ipRange = trim($ipRange);
         }
         $address = Factory::parseAddressString($_SERVER[self::$_ipKey]);
-        $range   = Factory::parseRangeString(
+        $range = Factory::parseRangeString(
             $ipRange,
             ParseStringFlag::IPV4_MAYBE_NON_DECIMAL | ParseStringFlag::IPV4SUBNET_MAYBE_COMPACT | ParseStringFlag::IPV4ADDRESS_MAYBE_NON_QUAD_DOTTED
         );
@@ -200,8 +200,8 @@ class TrafficLimiter extends AbstractPersistence
 
         // used as array key, which are limited in length, hence using algo with shorter range
         $hash = self::getHash('sha256');
-        $now  = time();
-        $tl   = (int) self::$_store->getValue('traffic_limiter', $hash);
+        $now = time();
+        $tl = (int) self::$_store->getValue('traffic_limiter', $hash);
         self::$_store->purgeValues('traffic_limiter', $now - self::$_limit);
         if ($tl === 0 || ($tl + self::$_limit) < $now) {
             if (!self::$_store->setValue((string) $now, 'traffic_limiter', $hash)) {

+ 1 - 1
lib/Proxy/AbstractProxy.php

@@ -87,7 +87,7 @@ abstract class AbstractProxy
 
         if ($data === false) {
             $http_response_header = $http_response_header ?? [];
-            $statusCode           = '';
+            $statusCode = '';
             if (!empty($http_response_header) && preg_match('/HTTP\/\d+\.\d+\s+(\d+)/', $http_response_header[0], $matches)) {
                 $statusCode = $matches[1];
             }

+ 3 - 3
lib/Request.php

@@ -111,7 +111,7 @@ class Request
                 // it might be a creation or a deletion, the latter is detected below
                 $this->_operation = 'create';
                 try {
-                    $data          = file_get_contents(self::$_inputStream);
+                    $data = file_get_contents(self::$_inputStream);
                     $this->_params = Json::decode($data);
                     // a valid JSON scalar (number, bool or string) decodes
                     // without error, but is not a usable set of parameters
@@ -204,7 +204,7 @@ class Request
             'adata' => $this->getParam('adata'),
         ];
         $required_keys = ['v', 'ct'];
-        $meta          = $this->getParam('meta');
+        $meta = $this->getParam('meta');
         if (empty($meta)) {
             $required_keys[] = 'pasteid';
             $required_keys[] = 'parentid';
@@ -250,7 +250,7 @@ class Request
      */
     public function getRequestUri()
     {
-        $uri  = array_key_exists('REQUEST_URI', $_SERVER) ? filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL) : '';
+        $uri = array_key_exists('REQUEST_URI', $_SERVER) ? filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL) : '';
         $path = empty($uri) ? '' : parse_url($uri, PHP_URL_PATH);
         return is_string($path) && $path !== '' ? $path : '/';
     }

+ 1 - 1
lib/View.php

@@ -49,7 +49,7 @@ class View
      */
     public function draw($template)
     {
-        $dir  = PATH . 'tpl' . DIRECTORY_SEPARATOR;
+        $dir = PATH . 'tpl' . DIRECTORY_SEPARATOR;
         $file = substr($template, 0, 10) === 'bootstrap-' ? 'bootstrap' : $template;
         $path = $dir . $file . '.php';
         if (!is_file($path)) {

+ 8 - 8
lib/Vizhash16x16.php

@@ -63,7 +63,7 @@ class Vizhash16x16
      */
     public function __construct()
     {
-        $this->width  = 16;
+        $this->width = 16;
         $this->height = 16;
     }
 
@@ -110,10 +110,10 @@ class Vizhash16x16
 
         for ($i = 0; $i < 7; ++$i) {
             $action = $this->getInt();
-            $color  = imagecolorallocate($image, $r, $g, $b);
-            $r      = $r0      = (int) ($r0 + $this->getInt() / 25) % 256;
-            $g      = $g0      = (int) ($g0 + $this->getInt() / 25) % 256;
-            $b      = $b0      = (int) ($b0 + $this->getInt() / 25) % 256;
+            $color = imagecolorallocate($image, $r, $g, $b);
+            $r = $r0 = (int) ($r0 + $this->getInt() / 25) % 256;
+            $g = $g0 = (int) ($g0 + $this->getInt() / 25) % 256;
+            $b = $b0 = (int) ($b0 + $this->getInt() / 25) % 256;
             $this->drawshape($image, $action, $color);
         }
 
@@ -180,10 +180,10 @@ class Vizhash16x16
     private function degrade($img, $direction, $color1, $color2)
     {
         if ($direction === 'h') {
-            $size    = imagesx($img);
+            $size = imagesx($img);
             $sizeinv = imagesy($img);
         } else {
-            $size    = imagesy($img);
+            $size = imagesy($img);
             $sizeinv = imagesx($img);
         }
         $diffs = [
@@ -228,7 +228,7 @@ class Vizhash16x16
                 break;
             default:
                 $start = (int) ($this->getInt() * 360 / 256);
-                $end   = (int) ($start + $this->getInt() * 180 / 256);
+                $end = (int) ($start + $this->getInt() * 180 / 256);
                 imagefilledarc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
         }
     }

+ 1 - 1
tst/AdministrationEmptyDirsTest.php

@@ -17,7 +17,7 @@ class AdministrationEmptyDirsTest extends TestCase
         mkdir($dataPath . DIRECTORY_SEPARATOR . 'empty' . DIRECTORY_SEPARATOR . 'nested', 0777, true);
         file_put_contents($dataPath . DIRECTORY_SEPARATOR . 'keep.txt', 'keep');
 
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['model_options']['dir'] = $dataPath;
         Helper::createIniFile(
             $this->_path . DIRECTORY_SEPARATOR . 'cfg' . DIRECTORY_SEPARATOR . 'conf.php',

+ 25 - 25
tst/Bootstrap.php

@@ -112,9 +112,9 @@ class Helper
      */
     public static function getPaste(array $meta = []): array
     {
-        $example                 = self::$pasteV2;
+        $example = self::$pasteV2;
         $example['meta']['salt'] = ServerSalt::generate();
-        $example['meta']         = array_merge($example['meta'], $meta);
+        $example['meta'] = array_merge($example['meta'], $meta);
         return $example;
     }
 
@@ -126,7 +126,7 @@ class Helper
      */
     public static function getPastePost(array $meta = []): array
     {
-        $example         = self::getPaste($meta);
+        $example = self::getPaste($meta);
         $example['meta'] = ['expire' => $example['meta']['expire']];
         return $example;
     }
@@ -160,8 +160,8 @@ class Helper
      */
     public static function getComment(array $meta = []): array
     {
-        $example            = self::$pasteV2;
-        $example['adata']   = $example['adata'][0];
+        $example = self::$pasteV2;
+        $example['adata'] = $example['adata'][0];
         $example['pasteid'] = $example['parentid'] = self::getPasteId();
         unset($example['meta']['expire']);
         $example['meta'] = array_merge($example['meta'], self::$commentV2);
@@ -351,7 +351,7 @@ class Helper
         }
 
         $counter = 0;
-        $file    = PATH . 'lib' . DIRECTORY_SEPARATOR . 'Configuration.php';
+        $file = PATH . 'lib' . DIRECTORY_SEPARATOR . 'Configuration.php';
         $content = preg_replace_callback(
             '#\'js/([a-z0-9.-]+.js)(\' +)=\> \'[^\']*\',#',
             function ($matches) use (&$counter) {
@@ -385,11 +385,11 @@ class BucketStub extends Bucket
 
     public function __construct(ConnectionInterface $connection, $name, array $info = [], $client = null)
     {
-        $this->_name       = $name;
-        $this->_info       = $info;
+        $this->_name = $name;
+        $this->_info = $info;
         $this->_connection = $connection;
-        $this->_objects    = [];
-        $this->_client     = $client;
+        $this->_objects = [];
+        $this->_client = $client;
     }
 
     public function acl()
@@ -413,9 +413,9 @@ class BucketStub extends Bucket
             throw new BadMethodCallException('not supported by this stub');
         }
 
-        $name                             = $options['name'];
-        $generation                       = '1';
-        $o                                = new StorageObjectStub($this->_connection, $name, $this, $generation, $options);
+        $name = $options['name'];
+        $generation = '1';
+        $o = new StorageObjectStub($this->_connection, $name, $this, $generation, $options);
         $this->_objects[$options['name']] = $o;
         $o->setData($data);
     }
@@ -548,12 +548,12 @@ class StorageObjectStub extends StorageObject
 
     public function __construct(ConnectionInterface $connection, $name, $bucket, $generation = null, array $info = [], $encryptionKey = null, $encryptionKeySHA256 = null)
     {
-        $this->_name                            = $name;
-        $this->_bucket                          = $bucket;
-        $this->_generation                      = $generation;
-        $this->_info                            = $info;
-        $this->_connection                      = $connection;
-        $timeCreated                            = new DateTime();
+        $this->_name = $name;
+        $this->_bucket = $bucket;
+        $this->_generation = $generation;
+        $this->_info = $info;
+        $this->_connection = $connection;
+        $timeCreated = new DateTime();
         $this->_info['metadata']['timeCreated'] = $timeCreated->format('Y-m-d\TH:i:s.u\Z');
     }
 
@@ -677,7 +677,7 @@ class StorageObjectStub extends StorageObject
 
     public function setData($data)
     {
-        $this->_data   = $data;
+        $this->_data = $data;
         $this->_exists = true;
     }
 }
@@ -878,14 +878,14 @@ class ConnectionInterfaceStub implements ConnectionInterface
  */
 class StorageClientStub extends StorageClient
 {
-    private $_config         = null;
-    private $_connection     = null;
+    private $_config = null;
+    private $_connection = null;
     private static $_buckets = [];
 
     public function __construct(array $config = [])
     {
-        $this->_config     = $config;
-        $this->_connection =  new ConnectionInterfaceStub();
+        $this->_config = $config;
+        $this->_connection = new ConnectionInterfaceStub();
     }
 
     public function bucket($name, $userProject = false, array $config = [])
@@ -958,7 +958,7 @@ class StorageClientStub extends StorageClient
         if (array_key_exists($name, self::$_buckets)) {
             throw new BadRequestException('already exists');
         }
-        $b                     = new BucketStub($this->_connection, $name, [], $this);
+        $b = new BucketStub($this->_connection, $name, [], $this);
         self::$_buckets[$name] = $b;
         return $b;
     }

+ 20 - 20
tst/ConfigurationTest.php

@@ -15,10 +15,10 @@ class ConfigurationTest extends TestCase
     {
         /* Setup Routine */
         Helper::confBackup();
-        $this->_minimalConfig                   = '[main]' . PHP_EOL . '[model]' . PHP_EOL . '[model_options]';
-        $this->_options                         = Configuration::getDefaults();
+        $this->_minimalConfig = '[main]' . PHP_EOL . '[model]' . PHP_EOL . '[model_options]';
+        $this->_options = Configuration::getDefaults();
         $this->_options['model_options']['dir'] = PATH . $this->_options['model_options']['dir'];
-        $this->_path                            = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_cfg';
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_cfg';
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
@@ -98,19 +98,19 @@ class ConfigurationTest extends TestCase
 
     public function testHandleWrongTypes()
     {
-        $original_options                                    = $this->_options;
+        $original_options = $this->_options;
         $original_options['main']['syntaxhighlightingtheme'] = 'foo';
-        $options                                             = $original_options;
-        $options['main']['discussion']                       = 'true';
-        $options['main']['opendiscussion']                   = 0;
-        $options['main']['password']                         = -1; // evaluates to TRUE
-        $options['main']['fileupload']                       = 'false';
-        $options['expire_options']['foo']                    = 'bar';
-        $options['formatter_options'][]                      = 'foo';
+        $options = $original_options;
+        $options['main']['discussion'] = 'true';
+        $options['main']['opendiscussion'] = 0;
+        $options['main']['password'] = -1; // evaluates to TRUE
+        $options['main']['fileupload'] = 'false';
+        $options['expire_options']['foo'] = 'bar';
+        $options['formatter_options'][] = 'foo';
         Helper::createIniFile(CONF, $options);
-        $conf                                      = new Configuration;
+        $conf = new Configuration;
         $original_options['expire_options']['foo'] = intval('bar');
-        $original_options['formatter_options'][0]  = 'foo';
+        $original_options['formatter_options'][0] = 'foo';
         $this->assertEquals($original_options, $conf->get(), 'incorrect types are corrected');
     }
 
@@ -120,23 +120,23 @@ class ConfigurationTest extends TestCase
         unset($options['expire_options']['1week']);
         unset($options['expire_options']['1year']);
         unset($options['expire_options']['never']);
-        $sri_key                         = array_key_first($options['sri']);
-        $valid_sri                       = $options['sri'][$sri_key];
-        $options['sri'][$sri_key]        = ''; // empty string should get replaced with default
+        $sri_key = array_key_first($options['sri']);
+        $valid_sri = $options['sri'][$sri_key];
+        $options['sri'][$sri_key] = ''; // empty string should get replaced with default
         $options['sri']['js/example.js'] = 'some invalid SRI hash';
         Helper::createIniFile(CONF, $options);
-        $conf                         = new Configuration;
+        $conf = new Configuration;
         // restore expected results
         $options['expire']['default'] = '5min';
-        $options['sri'][$sri_key]     = $valid_sri;
+        $options['sri'][$sri_key] = $valid_sri;
         $this->assertEquals($options, $conf->get(), 'not overriding "missing" subkeys');
     }
 
     public function testConfigPath()
     {
         // setup
-        $configFile              = $this->_path . DIRECTORY_SEPARATOR . 'conf.php';
-        $options                 = $this->_options;
+        $configFile = $this->_path . DIRECTORY_SEPARATOR . 'conf.php';
+        $options = $this->_options;
         $options['main']['name'] = 'OtherBin';
         Helper::createIniFile($configFile, $options);
 

+ 120 - 120
tst/ControllerTest.php

@@ -17,8 +17,8 @@ class ControllerTest extends TestCase
     public function setUp(): void
     {
         /* Setup Routine */
-        $this->_path  = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
-        $this->_data  = new Filesystem(['dir' => $this->_path]);
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
+        $this->_data = new Filesystem(['dir' => $this->_path]);
         ServerSalt::setStore($this->_data);
         TrafficLimiter::setStore($this->_data);
         $this->reset();
@@ -34,13 +34,13 @@ class ControllerTest extends TestCase
 
     public function reset()
     {
-        $_POST   = [];
-        $_GET    = [];
+        $_POST = [];
+        $_GET = [];
         $_SERVER = [];
         if ($this->_data->exists(Helper::getPasteId())) {
             $this->_data->delete(Helper::getPasteId());
         }
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['model_options']['dir'] = $this->_path;
         Helper::createIniFile(CONF, $options);
     }
@@ -50,9 +50,9 @@ class ControllerTest extends TestCase
      */
     public function testView()
     {
-        $_SERVER['HTTP_HOST']             = 'example.com';
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['HTTP_HOST'] = 'example.com';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -79,7 +79,7 @@ class ControllerTest extends TestCase
      */
     public function testViewLanguageSelection()
     {
-        $options                              = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['languageselection'] = true;
         Helper::createIniFile(CONF, $options);
         $_COOKIE['lang'] = 'de';
@@ -99,9 +99,9 @@ class ControllerTest extends TestCase
      */
     public function testViewForceLanguageDefault()
     {
-        $options                              = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['languageselection'] = false;
-        $options['main']['languagedefault']   = 'fr';
+        $options['main']['languagedefault'] = 'fr';
         Helper::createIniFile(CONF, $options);
         $_COOKIE['lang'] = 'de';
         ob_start();
@@ -120,9 +120,9 @@ class ControllerTest extends TestCase
      */
     public function testViewForceRegionalLanguageDefault()
     {
-        $options                              = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['languageselection'] = false;
-        $options['main']['languagedefault']   = 'zh-tw';
+        $options['main']['languagedefault'] = 'zh-tw';
         Helper::createIniFile(CONF, $options);
         $_COOKIE['lang'] = 'de';
         ob_start();
@@ -142,8 +142,8 @@ class ControllerTest extends TestCase
      */
     public function testViewUrlShortener()
     {
-        $shortener                       = 'https://shortener.example.com/api?link=';
-        $options                         = parse_ini_file(CONF, true);
+        $shortener = 'https://shortener.example.com/api?link=';
+        $options = parse_ini_file(CONF, true);
         $options['main']['urlshortener'] = $shortener;
         Helper::createIniFile(CONF, $options);
         $_COOKIE['lang'] = 'de';
@@ -171,7 +171,7 @@ class ControllerTest extends TestCase
      */
     public function testNonDefaultConf()
     {
-        $newConfig   = new class extends Configuration {};
+        $newConfig = new class extends Configuration {};
         $configValue = (new ReflectionClass(Controller::class))->getProperty('_conf');
         if (version_compare(PHP_VERSION, '8.1') < 0) {
             // > This function has been DEPRECATED as of PHP 8.5.0. [...]
@@ -190,16 +190,16 @@ class ControllerTest extends TestCase
      */
     public function testCreate()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -221,16 +221,16 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidTimelimit()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson(['expire' => 25]);
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         // Explicitly invoke TrafficLimiter to ensure limit applies to this test
         TrafficLimiter::canPass();
         ob_start();
@@ -253,17 +253,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidSize()
     {
-        $options                      = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['sizelimit'] = 10;
-        $options['traffic']['limit']  = 0;
+        $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -278,17 +278,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateProxyHeader()
     {
-        $options                      = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['header'] = 'X_FORWARDED_FOR';
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
-        $_SERVER['HTTP_X_FORWARDED_FOR']  = '::2';
+        $_SERVER['HTTP_X_FORWARDED_FOR'] = '::2';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -309,18 +309,18 @@ class ControllerTest extends TestCase
      */
     public function testCreateDuplicateId()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -335,17 +335,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateValidExpire()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $time                             = time();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $time = time();
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -367,17 +367,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateValidExpireWithDiscussion()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $time                             = time();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $time = time();
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -400,16 +400,16 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidExpire()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson(['expire' => 'foo']);
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -430,17 +430,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidBurn()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
-        $paste             = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][3] = 'neither 1 nor 0';
-        $file              = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode($paste));
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -455,17 +455,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidOpenDiscussion()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
-        $paste             = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][2] = 'neither 1 nor 0';
-        $file              = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode($paste));
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -484,12 +484,12 @@ class ControllerTest extends TestCase
     public function testCreateBrokenUpload()
     {
         $paste = substr(Helper::getPasteJson(), 0, -10);
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste does not exists before posting data');
         ob_start();
         new Controller;
@@ -506,12 +506,12 @@ class ControllerTest extends TestCase
     public function testCreateTooSoon()
     {
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         ob_end_clean();
@@ -530,15 +530,15 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidFormat()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $file = Helper::createTempFile();
         file_put_contents($file, '{"data":"","meta":{}}');
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -553,17 +553,17 @@ class ControllerTest extends TestCase
      */
     public function testCreateComment()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $comment = Helper::getCommentJson();
-        $file    = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $comment);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $paste                            = Helper::getPaste();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
         ob_start();
         new Controller;
@@ -579,18 +579,18 @@ class ControllerTest extends TestCase
      */
     public function testCreateInvalidComment()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
-        $comment             = Helper::getCommentPost();
+        $comment = Helper::getCommentPost();
         $comment['parentid'] = 'foo';
-        $file                = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode($comment));
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $paste                            = Helper::getPaste();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
         ob_start();
         new Controller;
@@ -606,18 +606,18 @@ class ControllerTest extends TestCase
      */
     public function testCreateCommentDiscussionDisabled()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $comment = Helper::getCommentJson();
-        $file    = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $comment);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $paste                            = Helper::getPaste();
-        $paste['adata'][2]                = 0;
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $paste = Helper::getPaste();
+        $paste['adata'][2] = 0;
         $this->_data->create(Helper::getPasteId(), $paste);
         ob_start();
         new Controller;
@@ -633,16 +633,16 @@ class ControllerTest extends TestCase
      */
     public function testCreateCommentInvalidPaste()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $comment = Helper::getCommentJson();
-        $file    = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $comment);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -657,7 +657,7 @@ class ControllerTest extends TestCase
      */
     public function testCreateDuplicateComment()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPaste();
@@ -666,12 +666,12 @@ class ControllerTest extends TestCase
         $this->_data->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getPasteId(), $comment);
         $this->assertTrue($this->_data->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getPasteId()), 'comment exists before posting data');
         $comment = Helper::getCommentJson();
-        $file    = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $comment);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -686,8 +686,8 @@ class ControllerTest extends TestCase
      */
     public function testReadInvalidId()
     {
-        $_SERVER['QUERY_STRING']          = 'foo';
-        $_GET['foo']                      = '';
+        $_SERVER['QUERY_STRING'] = 'foo';
+        $_GET['foo'] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -703,8 +703,8 @@ class ControllerTest extends TestCase
      */
     public function testReadNonexisting()
     {
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -722,8 +722,8 @@ class ControllerTest extends TestCase
     {
         $expiredPaste = Helper::getPaste(['expire_date' => 1344803344]);
         $this->_data->create(Helper::getPasteId(), $expiredPaste);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -739,11 +739,11 @@ class ControllerTest extends TestCase
      */
     public function testReadBurn()
     {
-        $paste             = Helper::getPaste();
+        $paste = Helper::getPaste();
         $paste['adata'][3] = 1;
         $this->_data->create(Helper::getPasteId(), $paste);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -771,8 +771,8 @@ class ControllerTest extends TestCase
     {
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -796,12 +796,12 @@ class ControllerTest extends TestCase
      */
     public function testReadBurnAfterReading()
     {
-        $burnPaste             = Helper::getPaste();
+        $burnPaste = Helper::getPaste();
         $burnPaste['adata'][3] = 1;
         $this->_data->create(Helper::getPasteId(), $burnPaste);
         $this->assertTrue($this->_data->exists(Helper::getPasteId()), 'paste exists before deleting data');
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -820,8 +820,8 @@ class ControllerTest extends TestCase
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
         $this->assertTrue($this->_data->exists(Helper::getPasteId()), 'paste exists before deleting data');
-        $paste               = $this->_data->read(Helper::getPasteId());
-        $_GET['pasteid']     = Helper::getPasteId();
+        $paste = $this->_data->read(Helper::getPasteId());
+        $_GET['pasteid'] = Helper::getPasteId();
         $_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), $paste['meta']['salt']);
         ob_start();
         new Controller;
@@ -842,7 +842,7 @@ class ControllerTest extends TestCase
     {
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
-        $_GET['pasteid']     = 'foo';
+        $_GET['pasteid'] = 'foo';
         $_GET['deletetoken'] = 'bar';
         ob_start();
         new Controller;
@@ -861,7 +861,7 @@ class ControllerTest extends TestCase
      */
     public function testDeleteInexistantId()
     {
-        $_GET['pasteid']     = Helper::getPasteId();
+        $_GET['pasteid'] = Helper::getPasteId();
         $_GET['deletetoken'] = 'bar';
         ob_start();
         new Controller;
@@ -881,7 +881,7 @@ class ControllerTest extends TestCase
     {
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
-        $_GET['pasteid']     = Helper::getPasteId();
+        $_GET['pasteid'] = Helper::getPasteId();
         $_GET['deletetoken'] = 'bar';
         ob_start();
         new Controller;
@@ -903,15 +903,15 @@ class ControllerTest extends TestCase
         $paste = Helper::getPaste();
         $this->_data->create(Helper::getPasteId(), $paste);
         $this->assertTrue($this->_data->exists(Helper::getPasteId()), 'paste exists before deleting data');
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode([
             'deletetoken' => 'burnafterreading',
         ]));
         Request::setInputStream($file);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -930,7 +930,7 @@ class ControllerTest extends TestCase
         $this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste does not exist before being created');
         $this->_data->create(Helper::getPasteId(), $expiredPaste);
         $this->assertTrue($this->_data->exists(Helper::getPasteId()), 'paste exists before deleting data');
-        $_GET['pasteid']     = Helper::getPasteId();
+        $_GET['pasteid'] = Helper::getPasteId();
         $_GET['deletetoken'] = 'does not matter in this context, but has to be set';
         ob_start();
         new Controller;

+ 2 - 2
tst/ControllerWithDbTest.php

@@ -25,7 +25,7 @@ class ControllerWithDbTest extends ControllerTest
             mkdir($this->_path);
         }
         $this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
-        $this->_data           = new Database($this->_options);
+        $this->_data = new Database($this->_options);
         ServerSalt::setStore($this->_data);
         TrafficLimiter::setStore($this->_data);
         $this->reset();
@@ -35,7 +35,7 @@ class ControllerWithDbTest extends ControllerTest
     {
         parent::reset();
         // but then inject a db config
-        $options          = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['model'] = [
             'class' => 'Database',
         ];

+ 4 - 4
tst/ControllerWithGcsTest.php

@@ -17,9 +17,9 @@ class ControllerWithGcsTest extends ControllerTest
     public static function setUpBeforeClass(): void
     {
         $httpClient = new Client(['debug'=>false]);
-        $handler    = HttpHandlerFactory::build($httpClient);
+        $handler = HttpHandlerFactory::build($httpClient);
 
-        $name     = 'pb-';
+        $name = 'pb-';
         $alphabet = 'abcdefghijklmnopqrstuvwxyz';
         for ($i = 0; $i < 29; ++$i) {
             $name .= $alphabet[rand(0, strlen($alphabet) - 1)];
@@ -39,7 +39,7 @@ class ControllerWithGcsTest extends ControllerTest
             'bucket' => self::$_bucket->name(),
             'prefix' => 'pastes',
         ];
-        $this->_data    = new GoogleCloudStorage($this->_options);
+        $this->_data = new GoogleCloudStorage($this->_options);
         ServerSalt::setStore($this->_data);
         TrafficLimiter::setStore($this->_data);
         $this->reset();
@@ -49,7 +49,7 @@ class ControllerWithGcsTest extends ControllerTest
     {
         parent::reset();
         // but then inject a db config
-        $options          = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['model'] = [
             'class' => 'GoogleCloudStorage',
         ];

+ 21 - 21
tst/Data/DatabaseTest.php

@@ -22,7 +22,7 @@ class DatabaseTest extends TestCase
     public function setUp(): void
     {
         /* Setup Routine */
-        $this->_path  = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
         $this->_model = new Database($this->_options);
     }
 
@@ -63,22 +63,22 @@ class DatabaseTest extends TestCase
         $this->assertEquals($paste, $this->_model->read(Helper::getPasteId()));
 
         // storing comments
-        $comment1             = Helper::getComment();
-        $comment2             = Helper::getComment();
-        $meta1                = $comment1['meta'];
-        $meta2                = $comment2['meta'];
+        $comment1 = Helper::getComment();
+        $comment2 = Helper::getComment();
+        $meta1 = $comment1['meta'];
+        $meta2 = $comment2['meta'];
         $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment 1 does not yet exist');
         $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment1) !== false, 'store comment 1');
         $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment 2 exists after storing it');
         $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getPasteId()), 'comment 2 does not yet exist');
         $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getPasteId(), $comment2) !== false, 'store comment 2');
         $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getPasteId()), 'comment 2 exists after storing it');
-        $comment1['id']       = Helper::getCommentId();
+        $comment1['id'] = Helper::getCommentId();
         $comment1['parentid'] = Helper::getPasteId();
-        $comment1['meta']     = $meta1;
-        $comment2['id']       = Helper::getPasteId();
+        $comment1['meta'] = $meta1;
+        $comment2['id'] = Helper::getPasteId();
         $comment2['parentid'] = Helper::getPasteId();
-        $comment2['meta']     = $meta2;
+        $comment2['meta'] = $meta2;
         $this->assertEquals(
             [
                 $comment1['meta']['created']        => $comment1,
@@ -98,7 +98,7 @@ class DatabaseTest extends TestCase
     {
         $error_log_setting = ini_get('error_log');
         $this->_model->delete(Helper::getPasteId());
-        $original                          = $paste                                = Helper::getPaste(['expire_date' => 1344803344]);
+        $original = $paste = Helper::getPaste(['expire_date' => 1344803344]);
         $paste['meta']['burnafterreading'] = $original['meta']['burnafterreading'] = true;
         $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
         $this->assertTrue($this->_model->create(Helper::getPasteId(), $paste), 'store new paste');
@@ -112,16 +112,16 @@ class DatabaseTest extends TestCase
     public function testCommentsWithSameTimestampRemainInInsertionOrder()
     {
         $pasteid = Helper::getPasteId();
-        $paste   = Helper::getPaste();
+        $paste = Helper::getPaste();
         $this->_model->delete($pasteid);
         $this->assertTrue($this->_model->create($pasteid, $paste));
 
         $expectedIds = [];
         for ($i = 1; $i <= 12; ++$i) {
-            $comment                    = Helper::getComment();
+            $comment = Helper::getComment();
             $comment['meta']['created'] = 1735689600;
-            $commentid                  = sprintf('%016x', $i);
-            $expectedIds[]              = $commentid;
+            $commentid = sprintf('%016x', $i);
+            $expectedIds[] = $commentid;
             $this->assertTrue(
                 $this->_model->createComment($pasteid, $pasteid, $commentid, $comment)
             );
@@ -145,9 +145,9 @@ class DatabaseTest extends TestCase
     {
         $this->_model->delete(Helper::getPasteId());
         $expired = Helper::getPaste(['expire_date' => 1344803344]);
-        $paste   = Helper::getPaste(['expire_date' => time() + 3600]);
-        $keys    = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
-        $ids     = [];
+        $paste = Helper::getPaste(['expire_date' => time() + 3600]);
+        $keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
+        $ids = [];
         foreach ($keys as $key) {
             $ids[$key] = hash('fnv164', $key);
             $this->_model->delete($ids[$key]);
@@ -189,7 +189,7 @@ class DatabaseTest extends TestCase
     {
         $error_log_setting = ini_get('error_log');
         $this->_model->delete(Helper::getPasteId());
-        $data    = Helper::getPaste();
+        $data = Helper::getPaste();
         $comment = Helper::getComment(['icon' => "Invalid UTF-8 sequence: \xB1\x31"]);
         $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
         $this->assertTrue($this->_model->create(Helper::getPasteId(), $data), 'store new paste');
@@ -309,7 +309,7 @@ class DatabaseTest extends TestCase
         }
         $this->_options['dsn'] = 'sqlite:' . $path;
         $this->_options['tbl'] = 'foo_';
-        $db                    = new PDO(
+        $db = new PDO(
             $this->_options['dsn'],
             $this->_options['usr'],
             $this->_options['pwd'],
@@ -347,9 +347,9 @@ class DatabaseTest extends TestCase
 
     public function testOciClob()
     {
-        $int    = (int) random_bytes(1);
+        $int = (int) random_bytes(1);
         $string = random_bytes(10);
-        $clob   = fopen('php://memory', 'r+');
+        $clob = fopen('php://memory', 'r+');
         fwrite($clob, $string);
         rewind($clob);
         $this->assertEquals($int, Database::_sanitizeClob($int));

+ 16 - 16
tst/Data/FilesystemTest.php

@@ -14,9 +14,9 @@ class FilesystemTest extends TestCase
     public function setUp(): void
     {
         /* Setup Routine */
-        $this->_path        = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
         $this->_invalidPath = $this->_path . DIRECTORY_SEPARATOR . 'bar';
-        $this->_model       = new Filesystem(['dir' => $this->_path]);
+        $this->_model = new Filesystem(['dir' => $this->_path]);
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
@@ -45,12 +45,12 @@ class FilesystemTest extends TestCase
         $this->assertEquals($paste, $this->_model->read(Helper::getPasteId()));
 
         // storing comments
-        $comment             = Helper::getComment();
+        $comment = Helper::getComment();
         $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
         $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'store comment');
         $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it');
         $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'unable to store the same comment twice');
-        $comment['id']       = Helper::getCommentId();
+        $comment['id'] = Helper::getCommentId();
         $comment['parentid'] = Helper::getPasteId();
         $this->assertEquals(
             [$comment['meta']['created'] => $comment],
@@ -77,9 +77,9 @@ class FilesystemTest extends TestCase
 
     public function testCorruptCommentsAreIgnored()
     {
-        $pasteid   = Helper::getPasteId();
+        $pasteid = Helper::getPasteId();
         $commentid = Helper::getCommentId();
-        $comment   = Helper::getComment();
+        $comment = Helper::getComment();
         $this->assertTrue($this->_model->createComment($pasteid, $pasteid, $commentid, $comment));
 
         $discussionPath = $this->_path . DIRECTORY_SEPARATOR . substr($pasteid, 0, 2) .
@@ -117,9 +117,9 @@ class FilesystemTest extends TestCase
     {
         mkdir($this->_path . DIRECTORY_SEPARATOR . '00', 0777, true);
         $expired = Helper::getPaste(['expire_date' => 1344803344]);
-        $paste   = Helper::getPaste(['expire_date' => time() + 3600]);
-        $keys    = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
-        $ids     = [];
+        $paste = Helper::getPaste(['expire_date' => time() + 3600]);
+        $keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
+        $ids = [];
         foreach ($keys as $key) {
             $ids[$key] = hash('fnv164', $key);
             $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
@@ -161,7 +161,7 @@ class FilesystemTest extends TestCase
     {
         $error_log_setting = ini_get('error_log');
         $this->_model->delete(Helper::getPasteId());
-        $data    = Helper::getPaste();
+        $data = Helper::getPaste();
         $comment = Helper::getComment(['icon' => "Invalid UTF-8 sequence: \xB1\x31"]);
         $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
         $this->assertTrue($this->_model->create(Helper::getPasteId(), $data), 'store new paste');
@@ -176,12 +176,12 @@ class FilesystemTest extends TestCase
     public function testOldFilesGetConverted()
     {
         // generate 10 (default purge batch size) pastes in the old format
-        $paste     = Helper::getPaste();
-        $comment   = Helper::getComment();
+        $paste = Helper::getPaste();
+        $comment = Helper::getComment();
         $commentid = Helper::getCommentId();
-        $ids       = [];
+        $ids = [];
         for ($i = 0, $max = 10; $i < $max; ++$i) {
-            $dataid     = Helper::getRandomId();
+            $dataid = Helper::getRandomId();
             $storagedir = $this->_path . DIRECTORY_SEPARATOR . substr($dataid, 0, 2) .
                 DIRECTORY_SEPARATOR . substr($dataid, 2, 2) . DIRECTORY_SEPARATOR;
             $ids[$dataid] = $storagedir;
@@ -225,8 +225,8 @@ class FilesystemTest extends TestCase
             );
             $this->assertFileDoesNotExist($storagedir . $dataid . '.' . $commentid . '.' . $dataid, "old format comment of $dataid got removed");
             $this->assertTrue($this->_model->existsComment($dataid, $dataid, $commentid), "comment in paste $dataid exists");
-            $comment             = $comment;
-            $comment['id']       = $commentid;
+            $comment = $comment;
+            $comment['id'] = $commentid;
             $comment['parentid'] = $dataid;
             $this->assertEquals($this->_model->readComments($dataid), [$comment['meta']['created'] => $comment], "comment of $dataid wasn't modified in the conversion");
         }

+ 9 - 9
tst/Data/GoogleCloudStorageTest.php

@@ -14,9 +14,9 @@ class GoogleCloudStorageTest extends TestCase
     public static function setUpBeforeClass(): void
     {
         $httpClient = new Client(['debug'=>false]);
-        $handler    = HttpHandlerFactory::build($httpClient);
+        $handler = HttpHandlerFactory::build($httpClient);
 
-        $name     = 'pb-';
+        $name = 'pb-';
         $alphabet = 'abcdefghijklmnopqrstuvwxyz';
         for ($i = 0; $i < 29; ++$i) {
             $name .= $alphabet[rand(0, strlen($alphabet) - 1)];
@@ -59,12 +59,12 @@ class GoogleCloudStorageTest extends TestCase
         $this->assertEquals($paste, $this->_model->read(Helper::getPasteId()));
 
         // storing comments
-        $comment             = Helper::getComment();
+        $comment = Helper::getComment();
         $this->assertFalse($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment does not yet exist');
         $this->assertTrue($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'store comment');
         $this->assertTrue($this->_model->existsComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId()), 'comment exists after storing it');
         $this->assertFalse($this->_model->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $comment), 'unable to store the same comment twice');
-        $comment['id']       = Helper::getCommentId();
+        $comment['id'] = Helper::getCommentId();
         $comment['parentid'] = Helper::getPasteId();
         $this->assertEquals(
             [$comment['meta']['created'] => $comment],
@@ -84,9 +84,9 @@ class GoogleCloudStorageTest extends TestCase
     public function testPurge()
     {
         $expired = Helper::getPaste(['expire_date' => 1344803344]);
-        $paste   = Helper::getPaste(['expire_date' => time() + 3600]);
-        $keys    = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
-        $ids     = [];
+        $paste = Helper::getPaste(['expire_date' => time() + 3600]);
+        $keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'x', 'y', 'z'];
+        $ids = [];
         foreach ($keys as $key) {
             $ids[$key] = hash('fnv164', $key);
             $this->assertFalse($this->_model->exists($ids[$key]), "paste $key does not yet exist");
@@ -123,7 +123,7 @@ class GoogleCloudStorageTest extends TestCase
     public function testCommentErrorDetection()
     {
         $this->_model->delete(Helper::getPasteId());
-        $data    = Helper::getPaste();
+        $data = Helper::getPaste();
         $comment = Helper::getComment(['icon' => "Invalid UTF-8 sequence: \xB1\x31"]);
         $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not yet exist');
         $this->assertTrue($this->_model->create(Helper::getPasteId(), $data), 'store new paste');
@@ -170,7 +170,7 @@ class GoogleCloudStorageTest extends TestCase
      */
     public function testKeyValuePurgeTrafficLimiter()
     {
-        $salt   = bin2hex(random_bytes(256));
+        $salt = bin2hex(random_bytes(256));
         $client = hash_hmac('sha512', '127.0.0.1', $salt);
         $expire = time();
         $this->_model->setValue(strval($expire), 'traffic_limiter', $client);

+ 27 - 27
tst/FormatV2Test.php

@@ -7,7 +7,7 @@ class FormatV2Test extends TestCase
 {
     public function testFormatV2ValidatorValidatesCorrectly()
     {
-        $paste   = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $comment = Helper::getCommentPost();
         $this->assertTrue(FormatV2::isValid($paste), 'valid format');
         $this->assertTrue(FormatV2::isValid($comment, true), 'valid format');
@@ -15,57 +15,57 @@ class FormatV2Test extends TestCase
         $paste['adata'][0][0] = '$';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid base64 encoding of iv');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][1] = '$';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid base64 encoding of salt');
 
-        $paste       = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['ct'] = '$';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid base64 encoding of ct');
 
-        $paste       = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['ct'] = 'bm9kYXRhbm9kYXRhbm9kYXRhbm9kYXRhbm9kYXRhCg==';
         $this->assertFalse(FormatV2::isValid($paste), 'low ct entropy');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][0] = 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTA=';
         $this->assertFalse(FormatV2::isValid($paste), 'iv too long');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][1] = 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTA=';
         $this->assertFalse(FormatV2::isValid($paste), 'salt too long');
 
-        $paste        = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['foo'] = 'bar';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid additional key');
         unset($paste['meta']);
         $this->assertFalse(FormatV2::isValid($paste), 'invalid missing key');
 
-        $paste      = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['v'] = 0.9;
         $this->assertFalse(FormatV2::isValid($paste), 'unsupported version');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][2] = 1000;
         $this->assertFalse(FormatV2::isValid($paste), 'not enough iterations');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][3] = 127;
         $this->assertFalse(FormatV2::isValid($paste), 'invalid key size');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][4] = 63;
         $this->assertFalse(FormatV2::isValid($paste), 'invalid tag length');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][5] = '!#@';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid algorithm');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][6] = '!#@';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid mode');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][7] = '!#@';
         $this->assertFalse(FormatV2::isValid($paste), 'invalid compression');
 
@@ -77,36 +77,36 @@ class FormatV2Test extends TestCase
     {
         // malformed input must yield "false" (Invalid data) rather than a
         // fatal type error under strict_types
-        $paste          = Helper::getPastePost();
-        $paste['v']     = 'abc';
+        $paste = Helper::getPastePost();
+        $paste['v'] = 'abc';
         $this->assertFalse(FormatV2::isValid($paste), 'non-numeric version');
 
-        $paste          = Helper::getPastePost();
-        $paste['v']     = [];
+        $paste = Helper::getPastePost();
+        $paste['v'] = [];
         $this->assertFalse(FormatV2::isValid($paste), 'array version');
 
-        $paste          = Helper::getPastePost();
-        $paste['ct']    = ['not', 'a', 'string'];
+        $paste = Helper::getPastePost();
+        $paste['ct'] = ['not', 'a', 'string'];
         $this->assertFalse(FormatV2::isValid($paste), 'non-string ciphertext');
 
-        $paste          = Helper::getPastePost();
-        $paste['meta']  = 'not-an-array';
+        $paste = Helper::getPastePost();
+        $paste['meta'] = 'not-an-array';
         $this->assertFalse(FormatV2::isValid($paste), 'non-array meta');
 
-        $paste             = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0] = 'not-an-array';
         $this->assertFalse(FormatV2::isValid($paste), 'non-array cipher parameters');
 
-        $paste             = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0] = [];
         $this->assertFalse(FormatV2::isValid($paste), 'empty cipher parameters');
 
-        $paste                = Helper::getPastePost();
+        $paste = Helper::getPastePost();
         $paste['adata'][0][0] = [];
         $this->assertFalse(FormatV2::isValid($paste), 'non-string iv');
 
-        $comment           = Helper::getCommentPost();
-        $comment['ct']     = 42;
+        $comment = Helper::getCommentPost();
+        $comment['ct'] = 42;
         $this->assertFalse(FormatV2::isValid($comment, true), 'non-string comment ciphertext');
     }
 }

+ 55 - 55
tst/JsonApiTest.php

@@ -15,20 +15,20 @@ class JsonApiTest extends TestCase
     public function setUp(): void
     {
         /* Setup Routine */
-        $this->_path  = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
         $this->_model = new Filesystem(['dir' => $this->_path]);
         ServerSalt::setStore($this->_model);
 
-        $_POST   = [];
-        $_GET    = [];
+        $_POST = [];
+        $_GET = [];
         $_SERVER = [];
         if ($this->_model->exists(Helper::getPasteId())) {
             $this->_model->delete(Helper::getPasteId());
         }
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['model_options']['dir'] = $this->_path;
         Helper::confBackup();
         Helper::createIniFile(CONF, $options);
@@ -47,17 +47,17 @@ class JsonApiTest extends TestCase
      */
     public function testCreate()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $_SERVER['REMOTE_ADDR']           = '::1';
-        $_SERVER['REQUEST_URI']           = '/';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $_SERVER['REMOTE_ADDR'] = '::1';
+        $_SERVER['REQUEST_URI'] = '/';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -79,18 +79,18 @@ class JsonApiTest extends TestCase
      */
     public function testPut()
     {
-        $options                     = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['traffic']['limit'] = 0;
         Helper::createIniFile(CONF, $options);
         $paste = Helper::getPasteJson();
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, $paste);
         Request::setInputStream($file);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'PUT';
-        $_SERVER['REMOTE_ADDR']           = '::1';
+        $_SERVER['REQUEST_METHOD'] = 'PUT';
+        $_SERVER['REMOTE_ADDR'] = '::1';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -118,15 +118,15 @@ class JsonApiTest extends TestCase
         $this->_model->create(Helper::getPasteId(), $data);
         $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
         $paste = $this->_model->read(Helper::getPasteId());
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode([
             'deletetoken' => hash_hmac('sha256', Helper::getPasteId(), $paste['meta']['salt']),
         ]));
         Request::setInputStream($file);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'DELETE';
+        $_SERVER['REQUEST_METHOD'] = 'DELETE';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -146,14 +146,14 @@ class JsonApiTest extends TestCase
         $this->_model->create(Helper::getPasteId(), $data);
         $this->assertTrue($this->_model->exists(Helper::getPasteId()), 'paste exists before deleting data');
         $paste = $this->_model->read(Helper::getPasteId());
-        $file  = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode([
             'pasteid'     => Helper::getPasteId(),
             'deletetoken' => hash_hmac('sha256', Helper::getPasteId(), $paste['meta']['salt']),
         ]));
         Request::setInputStream($file);
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['REQUEST_METHOD']        = 'POST';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -168,10 +168,10 @@ class JsonApiTest extends TestCase
      */
     public function testRead()
     {
-        $paste                            = Helper::getPaste();
+        $paste = Helper::getPaste();
         $this->_model->create(Helper::getPasteId(), $paste);
-        $_SERVER['QUERY_STRING']          = Helper::getPasteId();
-        $_GET[Helper::getPasteId()]       = '';
+        $_SERVER['QUERY_STRING'] = Helper::getPasteId();
+        $_GET[Helper::getPasteId()] = '';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
         ob_start();
         new Controller;
@@ -278,7 +278,7 @@ class JsonApiTest extends TestCase
     public function testJsonLdPathBypass()
     {
         $_SERVER['REQUEST_URI'] = '/","bypass\\';
-        $_GET['jsonld']         = 'paste';
+        $_GET['jsonld'] = 'paste';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -309,18 +309,18 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaYourls($baseUri)
     {
-        $mock_yourls_service                = $this->_path . DIRECTORY_SEPARATOR . 'yourls.json';
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
-        $options['main']['urlshortener']    = 'https://example.com' . $baseUri . 'link=';
-        $options['yourls']['apiurl']        = $mock_yourls_service;
+        $mock_yourls_service = $this->_path . DIRECTORY_SEPARATOR . 'yourls.json';
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options['main']['urlshortener'] = 'https://example.com' . $baseUri . 'link=';
+        $options['yourls']['apiurl'] = $mock_yourls_service;
         Helper::createIniFile(CONF, $options);
 
         // the real service answer is more complex, but we only look for the shorturl & statusCode
         file_put_contents($mock_yourls_service, '{"shorturl":"https:\/\/example.com\/1","statusCode":200}');
 
         $_SERVER['REQUEST_URI'] = $baseUri . 'link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         if (str_contains($baseUri, '?shortenviayourls')) {
             $_GET['shortenviayourls'] = null;
         }
@@ -337,18 +337,18 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaShlink($baseUri)
     {
-        $mock_shlink_service                = $this->_path . DIRECTORY_SEPARATOR . 'shlink.json';
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
-        $options['main']['urlshortener']    = 'https://example.com' . $baseUri . 'link=';
-        $options['shlink']['apiurl']        = $mock_shlink_service;
+        $mock_shlink_service = $this->_path . DIRECTORY_SEPARATOR . 'shlink.json';
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options['main']['urlshortener'] = 'https://example.com' . $baseUri . 'link=';
+        $options['shlink']['apiurl'] = $mock_shlink_service;
         Helper::createIniFile(CONF, $options);
 
         // the real service answer is more complex, but we only look for the shorturl & statusCode
         file_put_contents($mock_shlink_service, '{"shortUrl":"https:\/\/example.com\/1"}');
 
         $_SERVER['REQUEST_URI'] = $baseUri . 'link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         if (str_contains($baseUri, '?shortenviashlink')) {
             $_GET['shortenviashlink'] = null;
         }
@@ -365,15 +365,15 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaShlinkFailureHttp($baseUri)
     {
-        $mock_shlink_service                = 'https://httpbin.org/status/403';
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
-        $options['main']['urlshortener']    = 'https://example.com' . $baseUri . 'link=';
-        $options['shlink']['apiurl']        = $mock_shlink_service;
+        $mock_shlink_service = 'https://httpbin.org/status/403';
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options['main']['urlshortener'] = 'https://example.com' . $baseUri . 'link=';
+        $options['shlink']['apiurl'] = $mock_shlink_service;
         Helper::createIniFile(CONF, $options);
 
         $_SERVER['REQUEST_URI'] = $baseUri . 'link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         if (str_contains($baseUri, '?shortenviashlink')) {
             $_GET['shortenviashlink'] = null;
         }
@@ -391,18 +391,18 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaShlinkSuccessButMissingShortUrl($baseUri)
     {
-        $mock_shlink_service                = $this->_path . DIRECTORY_SEPARATOR . 'shlink.json';
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
-        $options['main']['urlshortener']    = 'https://example.com' . $baseUri . 'link=';
-        $options['shlink']['apiurl']        = $mock_shlink_service;
+        $mock_shlink_service = $this->_path . DIRECTORY_SEPARATOR . 'shlink.json';
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options['main']['urlshortener'] = 'https://example.com' . $baseUri . 'link=';
+        $options['shlink']['apiurl'] = $mock_shlink_service;
         Helper::createIniFile(CONF, $options);
 
         // Ideally, this should never happen, just in case "shortUrl" is somehow missing in the 200 response
         file_put_contents($mock_shlink_service, '{}');
 
         $_SERVER['REQUEST_URI'] = $baseUri . 'link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         if (str_contains($baseUri, '?shortenviashlink')) {
             $_GET['shortenviashlink'] = null;
         }
@@ -436,11 +436,11 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaYourlsFailure()
     {
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
         Helper::createIniFile(CONF, $options);
         $_SERVER['REQUEST_URI'] = '/path/shortenviayourls?link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         ob_start();
         new Controller;
         $content = ob_get_contents();
@@ -453,11 +453,11 @@ class JsonApiTest extends TestCase
      */
     public function testShortenViaShlinkFailure()
     {
-        $options                            = parse_ini_file(CONF, true);
-        $options['main']['basepath']        = 'https://example.com/path'; // missing slash gets added by Configuration constructor
+        $options = parse_ini_file(CONF, true);
+        $options['main']['basepath'] = 'https://example.com/path'; // missing slash gets added by Configuration constructor
         Helper::createIniFile(CONF, $options);
         $_SERVER['REQUEST_URI'] = '/path/shortenviashlink?link=https%3A%2F%2Fexample.com%2Fpath%2F%3Ffoo%23bar';
-        $_GET['link']           = 'https://example.com/path/?foo#bar';
+        $_GET['link'] = 'https://example.com/path/?foo#bar';
         ob_start();
         new Controller;
         $content = ob_get_contents();

+ 7 - 7
tst/MigrateForceOverwriteTest.php

@@ -18,16 +18,16 @@ class MigrateForceOverwriteTest extends TestCase
         mkdir($this->_path . DIRECTORY_SEPARATOR . 'source_cfg');
         mkdir($this->_path . DIRECTORY_SEPARATOR . 'destination_cfg');
 
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['model_options']['dir'] = $this->_path . DIRECTORY_SEPARATOR . 'source';
-        $this->_source                   = new Filesystem($options['model_options']);
+        $this->_source = new Filesystem($options['model_options']);
         Helper::createIniFile(
             $this->_path . DIRECTORY_SEPARATOR . 'source_cfg' . DIRECTORY_SEPARATOR . 'conf.php',
             $options
         );
 
         $options['model_options']['dir'] = $this->_path . DIRECTORY_SEPARATOR . 'destination';
-        $this->_destination              = new Filesystem($options['model_options']);
+        $this->_destination = new Filesystem($options['model_options']);
         Helper::createIniFile(
             $this->_path . DIRECTORY_SEPARATOR . 'destination_cfg' . DIRECTORY_SEPARATOR . 'conf.php',
             $options
@@ -41,10 +41,10 @@ class MigrateForceOverwriteTest extends TestCase
 
     public function testForceReplacesPasteAndDiscussion()
     {
-        $sourcePaste       = Helper::getPaste();
+        $sourcePaste = Helper::getPaste();
         $sourcePaste['ct'] = 'source paste';
         $this->_source->create(Helper::getPasteId(), $sourcePaste);
-        $sourceComment       = Helper::getComment();
+        $sourceComment = Helper::getComment();
         $sourceComment['ct'] = 'source comment';
         $this->_source->createComment(
             Helper::getPasteId(),
@@ -53,10 +53,10 @@ class MigrateForceOverwriteTest extends TestCase
             $sourceComment
         );
 
-        $destinationPaste       = Helper::getPaste();
+        $destinationPaste = Helper::getPaste();
         $destinationPaste['ct'] = 'old paste';
         $this->_destination->create(Helper::getPasteId(), $destinationPaste);
-        $destinationComment       = Helper::getComment();
+        $destinationComment = Helper::getComment();
         $destinationComment['ct'] = 'old comment';
         $this->_destination->createComment(
             Helper::getPasteId(),

+ 7 - 7
tst/MigrateTest.php

@@ -18,7 +18,7 @@ class MigrateTest extends TestCase
     public function setUp(): void
     {
         /* Setup Routine */
-        $this->_path            = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
+        $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
         $this->_path_instance_1 = $this->_path . DIRECTORY_SEPARATOR . 'instance_1';
         $this->_path_instance_2 = $this->_path . DIRECTORY_SEPARATOR . 'instance_2';
         if (!is_dir($this->_path)) {
@@ -28,13 +28,13 @@ class MigrateTest extends TestCase
         mkdir($this->_path_instance_1 . DIRECTORY_SEPARATOR . 'cfg');
         mkdir($this->_path_instance_2);
         mkdir($this->_path_instance_2 . DIRECTORY_SEPARATOR . 'cfg');
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
-        $options['purge']['limit']       = 0;
+        $options = parse_ini_file(CONF_SAMPLE, true);
+        $options['purge']['limit'] = 0;
         $options['model_options']['dir'] = $this->_path_instance_1 . DIRECTORY_SEPARATOR . 'data';
-        $this->_model_1                  = new Filesystem($options['model_options']);
+        $this->_model_1 = new Filesystem($options['model_options']);
         Helper::createIniFile($this->_path_instance_1 . DIRECTORY_SEPARATOR . 'cfg' . DIRECTORY_SEPARATOR . 'conf.php', $options);
 
-        $options['model']          = [
+        $options['model'] = [
             'class' => 'Database',
         ];
         $options['model_options'] = [
@@ -65,7 +65,7 @@ class MigrateTest extends TestCase
         $this->_model_1->createComment(Helper::getPasteId(), Helper::getPasteId(), Helper::getCommentId(), $data);
 
         // migrate files to database
-        $output    = null;
+        $output = null;
         $exit_code = 255;
         exec('php ' . PATH . 'bin' . DIRECTORY_SEPARATOR . 'migrate --delete-after ' . $this->_path_instance_1 . DIRECTORY_SEPARATOR . 'cfg ' . $this->_path_instance_2 . DIRECTORY_SEPARATOR . 'cfg', $output, $exit_code);
         $this->assertEquals(0, $exit_code, 'migrate script exits 0');
@@ -95,7 +95,7 @@ class MigrateTest extends TestCase
             Filesystem::PROTECTION_LINE . PHP_EOL . '{'
         );
 
-        $output    = null;
+        $output = null;
         $exit_code = 0;
         exec(
             'php ' . PATH . 'bin' . DIRECTORY_SEPARATOR . 'migrate --delete-after ' .

+ 2 - 2
tst/MigrateWriteFailureTest.php

@@ -18,9 +18,9 @@ class MigrateWriteFailureTest extends TestCase
         mkdir($this->_path . DIRECTORY_SEPARATOR . 'source_cfg');
         mkdir($this->_path . DIRECTORY_SEPARATOR . 'destination_cfg');
 
-        $options                         = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['model_options']['dir'] = $this->_path . DIRECTORY_SEPARATOR . 'source';
-        $this->_source                   = new Filesystem($options['model_options']);
+        $this->_source = new Filesystem($options['model_options']);
         Helper::createIniFile(
             $this->_path . DIRECTORY_SEPARATOR . 'source_cfg' . DIRECTORY_SEPARATOR . 'conf.php',
             $options

+ 39 - 39
tst/ModelTest.php

@@ -26,9 +26,9 @@ class ModelTest extends TestCase
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
-        $options                   = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['purge']['limit'] = 0;
-        $options['model']          = [
+        $options['model'] = [
             'class' => 'Database',
         ];
         $options['model_options'] = [
@@ -40,8 +40,8 @@ class ModelTest extends TestCase
         Helper::confBackup();
         Helper::createIniFile(CONF, $options);
         ServerSalt::setStore(new Database($options['model_options']));
-        $this->_conf            = new Configuration;
-        $this->_model           = new Model($this->_conf);
+        $this->_conf = new Configuration;
+        $this->_model = new Model($this->_conf);
         $_SERVER['REMOTE_ADDR'] = '::1';
     }
 
@@ -81,8 +81,8 @@ class ModelTest extends TestCase
 
         // storing comments
         $commentData = Helper::getCommentPost();
-        $paste       = $this->_model->getPaste(Helper::getPasteId());
-        $comment     = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
+        $paste = $this->_model->getPaste(Helper::getPasteId());
+        $comment = $paste->getComment(Helper::getPasteId(), Helper::getCommentId());
         $this->assertFalse($comment->exists(), 'comment does not yet exist');
 
         $comment = $paste->getComment(Helper::getPasteId());
@@ -91,9 +91,9 @@ class ModelTest extends TestCase
 
         $comments = $this->_model->getPaste(Helper::getPasteId())->get()['comments'];
         $this->assertTrue(count($comments) === 1, 'comment exists after storing it');
-        $commentData['id']              = Helper::getPasteId();
+        $commentData['id'] = Helper::getPasteId();
         $commentData['meta']['created'] = current($comments)['meta']['created'];
-        $commentData['meta']['icon']    = current($comments)['meta']['icon'];
+        $commentData['meta']['icon'] = current($comments)['meta']['icon'];
         $this->assertEquals($commentData, current($comments));
 
         // deleting pastes
@@ -105,7 +105,7 @@ class ModelTest extends TestCase
 
     public function testCommentDefaults()
     {
-        $class   = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
+        $class = 'PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model');
         $comment = new Comment(
             $this->_conf,
             new $class(
@@ -139,9 +139,9 @@ class ModelTest extends TestCase
         if (is_file($path)) {
             unlink($path);
         }
-        $options                   = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['purge']['limit'] = 0;
-        $options['model']          = [
+        $options['model'] = [
             'class' => 'Database',
         ];
         $options['model_options'] = [
@@ -153,7 +153,7 @@ class ModelTest extends TestCase
         Helper::createIniFile(CONF, $options);
         $model = new Model(new Configuration);
 
-        $pasteData   = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $model->getPaste(Helper::getPasteId())->delete();
         $model->getPaste(Helper::getPasteId())->exists();
 
@@ -180,9 +180,9 @@ class ModelTest extends TestCase
         if (is_file($path)) {
             unlink($path);
         }
-        $options                   = parse_ini_file(CONF_SAMPLE, true);
+        $options = parse_ini_file(CONF_SAMPLE, true);
         $options['purge']['limit'] = 0;
-        $options['model']          = [
+        $options['model'] = [
             'class' => 'Database',
         ];
         $options['model_options'] = [
@@ -194,7 +194,7 @@ class ModelTest extends TestCase
         Helper::createIniFile(CONF, $options);
         $model = new Model(new Configuration);
 
-        $pasteData   = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $commentData = Helper::getCommentPost();
         $model->getPaste(Helper::getPasteId())->delete();
 
@@ -223,7 +223,7 @@ class ModelTest extends TestCase
 
     public function testCommentDuplicate()
     {
-        $pasteData   = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $commentData = Helper::getCommentPost();
         $this->_model->getPaste(Helper::getPasteId())->delete();
 
@@ -244,7 +244,7 @@ class ModelTest extends TestCase
 
     public function testImplicitDefaults()
     {
-        $pasteData   = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $commentData = Helper::getCommentPost();
         $this->_model->getPaste(Helper::getPasteId())->delete();
 
@@ -292,9 +292,9 @@ class ModelTest extends TestCase
 
     public function testInvalidPasteFormat()
     {
-        $pasteData             = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $pasteData['adata'][1] = 'format does not exist';
-        $paste                 = $this->_model->getPaste();
+        $paste = $this->_model->getPaste();
         $this->expectException(Exception::class);
         $this->expectExceptionCode(75);
         $paste->setData($pasteData);
@@ -318,7 +318,7 @@ class ModelTest extends TestCase
     public function testInvalidCommentDeletedPaste()
     {
         $pasteData = Helper::getPastePost();
-        $paste     = $this->_model->getPaste(Helper::getPasteId());
+        $paste = $this->_model->getPaste(Helper::getPasteId());
         $paste->setData($pasteData);
         $paste->store();
 
@@ -331,9 +331,9 @@ class ModelTest extends TestCase
 
     public function testInvalidCommentData()
     {
-        $pasteData             = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $pasteData['adata'][2] = 0;
-        $paste                 = $this->_model->getPaste(Helper::getPasteId());
+        $paste = $this->_model->getPaste(Helper::getPasteId());
         $paste->setData($pasteData);
         $paste->store();
 
@@ -345,7 +345,7 @@ class ModelTest extends TestCase
 
     public function testInvalidCommentParent()
     {
-        $paste     = $this->_model->getPaste(Helper::getPasteId());
+        $paste = $this->_model->getPaste(Helper::getPasteId());
         $this->expectException(Exception::class);
         $this->expectExceptionCode(65);
         $paste->getComment('');
@@ -368,13 +368,13 @@ class ModelTest extends TestCase
 
     public function testPurge()
     {
-        $conf  = new Configuration;
+        $conf = new Configuration;
         $store = new Database($conf->getSection('model_options'));
         $store->delete(Helper::getPasteId());
         $expired = Helper::getPaste(['expire_date' => 1344803344]);
-        $paste   = Helper::getPaste(['expire_date' => time() + 3600]);
-        $keys    = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z'];
-        $ids     = [];
+        $paste = Helper::getPaste(['expire_date' => time() + 3600]);
+        $keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'x', 'y', 'z'];
+        $ids = [];
         foreach ($keys as $key) {
             $ids[$key] = hash('fnv164', $key);
             $store->delete($ids[$key]);
@@ -399,13 +399,13 @@ class ModelTest extends TestCase
 
     public function testCommentWithDisabledVizhash()
     {
-        $options                                  = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['discussiondatedisplay'] = 'false';
-        $options['main']['icon']                  = 'none';
-        $options['model']                         = [
+        $options['main']['icon'] = 'none';
+        $options['model'] = [
             'class' => 'Database',
         ];
-        $options['model_options']                 = [
+        $options['model_options'] = [
             'dsn' => 'sqlite::memory:',
             'usr' => null,
             'pwd' => null,
@@ -429,8 +429,8 @@ class ModelTest extends TestCase
         // storing comments
         $commentData = Helper::getCommentPost();
         unset($commentData['meta']['icon']);
-        $paste       = $model->getPaste(Helper::getPasteId());
-        $comment     = $paste->getComment(Helper::getPasteId(), Helper::getPasteId());
+        $paste = $model->getPaste(Helper::getPasteId());
+        $comment = $paste->getComment(Helper::getPasteId(), Helper::getPasteId());
         $this->assertFalse($comment->exists(), 'comment does not yet exist');
 
         $comment = $paste->getComment(Helper::getPasteId());
@@ -450,9 +450,9 @@ class ModelTest extends TestCase
 
     public function testCommentVizhash()
     {
-        $options                 = parse_ini_file(CONF, true);
+        $options = parse_ini_file(CONF, true);
         $options['main']['icon'] = 'vizhash';
-        $options['model']        = [
+        $options['model'] = [
             'class' => 'Database',
         ];
         $options['model_options'] = [
@@ -464,7 +464,7 @@ class ModelTest extends TestCase
         Helper::createIniFile(CONF, $options);
         $model = new Model(new Configuration);
 
-        $pasteData   = Helper::getPastePost();
+        $pasteData = Helper::getPastePost();
         $commentData = Helper::getCommentPost();
         $model->getPaste(Helper::getPasteId())->delete();
 
@@ -476,9 +476,9 @@ class ModelTest extends TestCase
         $comment->setData($commentData);
         $comment->store();
 
-        $vz        = new Vizhash16x16();
-        $pngdata   = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash()));
-        $comment   = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']);
+        $vz = new Vizhash16x16();
+        $pngdata = 'data:image/png;base64,' . base64_encode($vz->generate(TrafficLimiter::getHash()));
+        $comment = current($this->_model->getPaste(Helper::getPasteId())->get()['comments']);
         $this->assertEquals($pngdata, $comment['meta']['icon'], 'vizhash was generated');
     }
 }

+ 1 - 1
tst/Persistence/TrafficLimiterTest.php

@@ -13,7 +13,7 @@ class TrafficLimiterTest extends TestCase
     {
         /* Setup Routine */
         $this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'trafficlimit';
-        $store       = new Filesystem(['dir' => $this->_path]);
+        $store = new Filesystem(['dir' => $this->_path]);
         ServerSalt::setStore($store);
         TrafficLimiter::setStore($store);
     }

+ 6 - 6
tst/Proxy/ChhotoProxyTest.php

@@ -19,12 +19,12 @@ class ChhotoProxyTest extends TestCase
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
-        $this->_mock_chhoto_service           = $this->_path . DIRECTORY_SEPARATOR . 'chhoto.json';
-        $options                              = parse_ini_file(CONF_SAMPLE, true);
-        $options['main']['basepath']          = 'https://example.com/';
-        $options['main']['urlshortener']      = 'https://example.com/shortenviachhoto?link=';
-        $options['chhoto']['apiurl']          = $this->_mock_chhoto_service;
-        $options['chhoto']['apikey']          = 'test_api_key';
+        $this->_mock_chhoto_service = $this->_path . DIRECTORY_SEPARATOR . 'chhoto.json';
+        $options = parse_ini_file(CONF_SAMPLE, true);
+        $options['main']['basepath'] = 'https://example.com/';
+        $options['main']['urlshortener'] = 'https://example.com/shortenviachhoto?link=';
+        $options['chhoto']['apiurl'] = $this->_mock_chhoto_service;
+        $options['chhoto']['apikey'] = 'test_api_key';
         Helper::confBackup();
         Helper::createIniFile(CONF, $options);
         $this->_conf = new Configuration;

+ 5 - 5
tst/Proxy/YourlsProxyTest.php

@@ -19,11 +19,11 @@ class YourlsProxyTest extends TestCase
         if (!is_dir($this->_path)) {
             mkdir($this->_path);
         }
-        $this->_mock_yourls_service         = $this->_path . DIRECTORY_SEPARATOR . 'yourls.json';
-        $options                            = parse_ini_file(CONF_SAMPLE, true);
-        $options['main']['basepath']        = 'https://example.com/';
-        $options['main']['urlshortener']    = 'https://example.com/shortenviayourls?link=';
-        $options['yourls']['apiurl']        = $this->_mock_yourls_service;
+        $this->_mock_yourls_service = $this->_path . DIRECTORY_SEPARATOR . 'yourls.json';
+        $options = parse_ini_file(CONF_SAMPLE, true);
+        $options['main']['basepath'] = 'https://example.com/';
+        $options['main']['urlshortener'] = 'https://example.com/shortenviayourls?link=';
+        $options['yourls']['apiurl'] = $this->_mock_yourls_service;
         Helper::confBackup();
         Helper::createIniFile(CONF, $options);
         $this->_conf = new Configuration;

+ 65 - 65
tst/RequestTest.php

@@ -8,8 +8,8 @@ class RequestTest extends TestCase
     public function reset()
     {
         $_SERVER = [];
-        $_GET    = [];
-        $_POST   = [];
+        $_GET = [];
+        $_POST = [];
     }
 
     /**
@@ -20,10 +20,10 @@ class RequestTest extends TestCase
      */
     public function getRandomQueryChars()
     {
-        $queryChars     = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=-_.!~*()';
+        $queryChars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=-_.!~*()';
         $queryCharCount = strlen($queryChars) - 1;
-        $resultLength   = random_int(1, 10);
-        $result         = '';
+        $resultLength = random_int(1, 10);
+        $result = '';
         for ($i = 0; $i < $resultLength; ++$i) {
             $result .= $queryChars[random_int(0, $queryCharCount)];
         }
@@ -34,7 +34,7 @@ class RequestTest extends TestCase
     {
         $this->reset();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $request                   = new Request;
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals('view', $request->getOperation());
     }
@@ -66,11 +66,11 @@ class RequestTest extends TestCase
     public function testRead()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -84,11 +84,11 @@ class RequestTest extends TestCase
     public function testReadNumeric()
     {
         $this->reset();
-        $id                        = '1234567812345678';
+        $id = '1234567812345678';
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -97,11 +97,11 @@ class RequestTest extends TestCase
     public function testDelete()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_GET['pasteid']           = $id;
-        $_GET['deletetoken']       = 'bar';
-        $request                   = new Request;
+        $_GET['pasteid'] = $id;
+        $_GET['deletetoken'] = 'bar';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals('delete', $request->getOperation());
         $this->assertEquals($id, $request->getParam('pasteid'));
@@ -111,9 +111,9 @@ class RequestTest extends TestCase
     public function testApiCreate()
     {
         $this->reset();
-        $_SERVER['REQUEST_METHOD']        = 'PUT';
+        $_SERVER['REQUEST_METHOD'] = 'PUT';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $file                             = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, '{"ct":"foo"}');
         Request::setInputStream($file);
         $request = new Request;
@@ -127,8 +127,8 @@ class RequestTest extends TestCase
     {
         $this->reset();
         $_SERVER['REQUEST_METHOD'] = 'POST';
-        $_SERVER['HTTP_ACCEPT']    = 'application/json, text/javascript, */*; q=0.01';
-        $file                      = Helper::createTempFile();
+        $_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
+        $file = Helper::createTempFile();
         file_put_contents($file, '{"ct":"foo"}');
         Request::setInputStream($file);
         $request = new Request;
@@ -140,12 +140,12 @@ class RequestTest extends TestCase
     public function testApiRead()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['HTTP_ACCEPT']    = 'application/json, text/javascript, */*; q=0.01';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertTrue($request->isJsonApiCall(), 'is JSON API call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -154,12 +154,12 @@ class RequestTest extends TestCase
     public function testApiDelete()
     {
         $this->reset();
-        $id                               = Helper::getRandomId();
-        $_SERVER['REQUEST_METHOD']        = 'POST';
+        $id = Helper::getRandomId();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $_SERVER['QUERY_STRING']          = $id;
-        $_GET                             = [$id => ''];
-        $file                             = Helper::createTempFile();
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET = [$id => ''];
+        $file = Helper::createTempFile();
         file_put_contents($file, '{"deletetoken":"bar"}');
         Request::setInputStream($file);
         $request = new Request;
@@ -172,8 +172,8 @@ class RequestTest extends TestCase
     public function testPostGarbage()
     {
         $this->reset();
-        $_SERVER['REQUEST_METHOD']        = 'POST';
-        $file                             = Helper::createTempFile();
+        $_SERVER['REQUEST_METHOD'] = 'POST';
+        $file = Helper::createTempFile();
         file_put_contents($file, random_bytes(256));
         Request::setInputStream($file);
         $request = new Request;
@@ -189,9 +189,9 @@ class RequestTest extends TestCase
         // instead of triggering a type error further down
         foreach (['1', '0.0', 'true', 'false', '"example"'] as $scalar) {
             $this->reset();
-            $_SERVER['REQUEST_METHOD']        = 'POST';
+            $_SERVER['REQUEST_METHOD'] = 'POST';
             $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-            $file                             = Helper::createTempFile();
+            $file = Helper::createTempFile();
             file_put_contents($file, $scalar);
             Request::setInputStream($file);
             $request = new Request;
@@ -208,9 +208,9 @@ class RequestTest extends TestCase
     public function testPostInvalidRoutingParameters($parameters)
     {
         $this->reset();
-        $_SERVER['REQUEST_METHOD']        = 'POST';
+        $_SERVER['REQUEST_METHOD'] = 'POST';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
-        $file                             = Helper::createTempFile();
+        $file = Helper::createTempFile();
         file_put_contents($file, json_encode($parameters));
         Request::setInputStream($file);
         $request = new Request;
@@ -233,12 +233,12 @@ class RequestTest extends TestCase
     public function testReadWithNegotiation()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['HTTP_ACCEPT']    = 'text/html,text/html; charset=UTF-8,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['HTTP_ACCEPT'] = 'text/html,text/html; charset=UTF-8,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -247,12 +247,12 @@ class RequestTest extends TestCase
     public function testReadWithXhtmlNegotiation()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['HTTP_ACCEPT']    = 'application/xhtml+xml,text/html,text/html; charset=UTF-8, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['HTTP_ACCEPT'] = 'application/xhtml+xml,text/html,text/html; charset=UTF-8, application/xml;q=0.9,*/*;q=0.8, text/csv,application/json';
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -261,12 +261,12 @@ class RequestTest extends TestCase
     public function testApiReadWithNegotiation()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['HTTP_ACCEPT']    = 'text/plain,text/csv, application/xml;q=0.9, application/json, text/html,text/html; charset=UTF-8,application/xhtml+xml, */*;q=0.8';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, application/json, text/html,text/html; charset=UTF-8,application/xhtml+xml, */*;q=0.8';
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertTrue($request->isJsonApiCall(), 'is JSON Api call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -275,12 +275,12 @@ class RequestTest extends TestCase
     public function testReadWithFailedNegotiation()
     {
         $this->reset();
-        $id                        = Helper::getRandomId();
+        $id = Helper::getRandomId();
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['HTTP_ACCEPT']    = 'text/plain,text/csv, application/xml;q=0.9, */*;q=0.8';
-        $_SERVER['QUERY_STRING']   = $id;
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['HTTP_ACCEPT'] = 'text/plain,text/csv, application/xml;q=0.9, */*;q=0.8';
+        $_SERVER['QUERY_STRING'] = $id;
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertFalse($request->isJsonApiCall(), 'is HTML call');
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals('read', $request->getOperation());
@@ -289,19 +289,19 @@ class RequestTest extends TestCase
     public function testPasteIdExtraction()
     {
         $this->reset();
-        $id              = Helper::getRandomId();
-        $path            = '/' . $this->getRandomQueryChars() . '/';
-        $queryParams     = [$id];
+        $id = Helper::getRandomId();
+        $path = '/' . $this->getRandomQueryChars() . '/';
+        $queryParams = [$id];
         $queryParamCount = random_int(1, 5);
         for ($i = 0; $i < $queryParamCount; ++$i) {
             array_push($queryParams, $this->getRandomQueryChars());
         }
         shuffle($queryParams);
         $_SERVER['REQUEST_METHOD'] = 'GET';
-        $_SERVER['QUERY_STRING']   = implode('&', $queryParams);
-        $_SERVER['REQUEST_URI']    = $path . '?' . $_SERVER['QUERY_STRING'];
-        $_GET[$id]                 = '';
-        $request                   = new Request;
+        $_SERVER['QUERY_STRING'] = implode('&', $queryParams);
+        $_SERVER['REQUEST_URI'] = $path . '?' . $_SERVER['QUERY_STRING'];
+        $_GET[$id] = '';
+        $request = new Request;
         $this->assertEquals($id, $request->getParam('pasteid'));
         $this->assertEquals($path, $request->getRequestUri());
     }

+ 7 - 7
tst/TemplateSwitcherTest.php

@@ -10,10 +10,10 @@ class TemplateSwitcherTest extends TestCase
     {
         $conf = new Configuration;
 
-        $defaultTemplateFallback        = 'bootstrap5';
-        $existingTemplateFallback       = 'bootstrap-dark';
+        $defaultTemplateFallback = 'bootstrap5';
+        $existingTemplateFallback = 'bootstrap-dark';
         $wrongBootstrapTemplateFallback = 'bootstrap-wrong';
-        $wrongTemplateFallback          = 'wrong-template';
+        $wrongTemplateFallback = 'wrong-template';
 
         TemplateSwitcher::setAvailableTemplates($conf->getKey('availabletemplates'));
 
@@ -29,7 +29,7 @@ class TemplateSwitcherTest extends TestCase
 
     public function testSetAvailableTemplates()
     {
-        $conf               = new Configuration;
+        $conf = new Configuration;
         $availableTemplates = $conf->getKey('availabletemplates');
 
         TemplateSwitcher::setAvailableTemplates($availableTemplates);
@@ -39,8 +39,8 @@ class TemplateSwitcherTest extends TestCase
     public function testGetTemplate()
     {
         $defaultTemplateFallback = 'bootstrap5';
-        $customTemplate          = 'bootstrap-dark';
-        $customWrongTemplate     = 'bootstrap-wrong';
+        $customTemplate = 'bootstrap-dark';
+        $customWrongTemplate = 'bootstrap-wrong';
         $escapeTemplateDirectory = '../index';
 
         TemplateSwitcher::setTemplateFallback($defaultTemplateFallback);
@@ -67,7 +67,7 @@ class TemplateSwitcherTest extends TestCase
     {
         $conf = new Configuration;
 
-        $existingTemplate    = 'bootstrap';
+        $existingTemplate = 'bootstrap';
         $nonExistentTemplate = 'bootstrap-wrong';
 
         TemplateSwitcher::setAvailableTemplates($conf->getKey('availabletemplates'));

+ 1 - 1
tst/Vizhash16x16Test.php

@@ -31,7 +31,7 @@ class Vizhash16x16Test extends TestCase
 
     public function testVizhashGeneratesUniquePngsPerIp()
     {
-        $vz      = new Vizhash16x16();
+        $vz = new Vizhash16x16();
         $pngdata = $vz->generate(hash('sha512', '127.0.0.1'));
         file_put_contents($this->_file, $pngdata);
         $finfo = new finfo(FILEINFO_MIME_TYPE);