applying patch based on StyleCI ruleset

This commit is contained in:
El RIDO 2016-10-29 10:24:08 +02:00
parent c8b1296929
commit 1f46823942
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
33 changed files with 430 additions and 452 deletions

View file

@ -9,10 +9,8 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use PrivateBin\I18n;
use Exception;
use PDO;

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Data;
use stdClass;

View file

@ -9,13 +9,12 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Data;
use PrivateBin\PrivateBin;
use Exception;
use PDO;
use PDOException;
use PrivateBin\PrivateBin;
use stdClass;
/**

View file

@ -9,11 +9,10 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Data;
use PrivateBin\Model\Paste;
use PrivateBin\Json;
use PrivateBin\Model\Paste;
/**
* Filesystem

View file

@ -9,10 +9,8 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use PrivateBin\I18n;
use Exception;
/**

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
/**
@ -296,12 +295,12 @@ class I18n
switch (self::$_language) {
case 'fr':
case 'zh':
return ($n > 1 ? 1 : 0);
return $n > 1 ? 1 : 0;
case 'pl':
return ($n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
return $n == 1 ? 0 : $n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2;
// en, de
default:
return ($n != 1 ? 1 : 0);
return $n != 1 ? 1 : 0;
}
}

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use Exception;

View file

@ -9,10 +9,8 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use PrivateBin\Data;
use PrivateBin\Model\Paste;
use PrivateBin\Persistence\PurgeLimiter;

View file

@ -9,13 +9,12 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Model;
use Exception;
use PrivateBin\Configuration;
use PrivateBin\Data\AbstractData;
use PrivateBin\Sjcl;
use Exception;
use stdClass;
/**

View file

@ -9,14 +9,13 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Model;
use PrivateBin\Sjcl;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Vizhash16x16;
use Identicon\Identicon;
use Exception;
use Identicon\Identicon;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Sjcl;
use PrivateBin\Vizhash16x16;
/**
* Comment

View file

@ -9,13 +9,12 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Model;
use PrivateBin\PrivateBin;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Sjcl;
use Exception;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\PrivateBin;
use PrivateBin\Sjcl;
/**
* Paste
@ -307,7 +306,6 @@ class Paste extends AbstractModel
$this->_data->meta->burnafterreading === true;
}
/**
* Check if paste has discussions enabled.
*

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Persistence;
use Exception;

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Persistence;
use PrivateBin\Configuration;

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Persistence;
use Exception;

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin\Persistence;
use PrivateBin\Configuration;

View file

@ -9,12 +9,11 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Persistence\ServerSalt;
use Exception;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
/**
* PrivateBin

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
/**

View file

@ -9,7 +9,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
/**
@ -31,7 +30,7 @@ class Sjcl
*/
public static function isValid($encoded)
{
$accepted_keys = array('iv','v','iter','ks','ts','mode','adata','cipher','salt','ct');
$accepted_keys = array('iv', 'v', 'iter', 'ks', 'ts', 'mode', 'adata', 'cipher', 'salt', 'ct');
// Make sure content is valid json
$decoded = json_decode($encoded);

View file

@ -9,7 +9,6 @@
* @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 1.0
*/
namespace PrivateBin;
use Exception;

View file

@ -10,7 +10,6 @@
* @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
* @version 0.0.5 beta PrivateBin 1.0
*/
namespace PrivateBin;
/**
@ -23,7 +22,6 @@ namespace PrivateBin;
* echo $data;
* exit;
*/
class Vizhash16x16
{
/**
@ -105,7 +103,7 @@ class Vizhash16x16
$op = 'v';
if (($this->getInt() % 2) == 0) {
$op = 'h';
};
}
$image = $this->degrade($image, $op, array($r0, $g0, $b0), array(0, 0, 0));
for ($i = 0; $i < 7; ++$i) {
@ -189,7 +187,7 @@ class Vizhash16x16
$diffs = array(
(($color2[0] - $color1[0]) / $size),
(($color2[1] - $color1[1]) / $size),
(($color2[2] - $color1[2]) / $size)
(($color2[2] - $color1[2]) / $size),
);
for ($i = 0; $i < $size; ++$i) {
$r = $color1[0] + ($diffs[0] * $i);
@ -217,20 +215,20 @@ class Vizhash16x16
{
switch ($action % 7) {
case 0:
ImageFilledRectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
imagefilledrectangle($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
break;
case 1:
case 2:
ImageFilledEllipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
imagefilledellipse($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $color);
break;
case 3:
$points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY());
ImageFilledPolygon($image, $points, 4, $color);
imagefilledpolygon($image, $points, 4, $color);
break;
default:
$start = $this->getInt() * 360 / 256;
$end = $start + $this->getInt() * 180 / 256;
ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
imagefilledarc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE);
}
}
}

View file

@ -9,7 +9,6 @@
* DANGER: Too many options/settings and too high max iteration setting may trigger
* a fork bomb. Please save your work before executing this script.
*/
include 'Bootstrap.php';
$vrd = array('view', 'read', 'delete');
@ -26,7 +25,7 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<div[^>]*id="opendisc"[^>]*>#',
'$content',
'outputs enabled discussion correctly'
'outputs enabled discussion correctly',
),
), array(
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
@ -35,7 +34,7 @@ new ConfigurationTestGenerator(array(
'args' => array(
1,
'$response["status"]',
'when discussions are enabled, but invalid flag posted, fail to create paste'
'when discussions are enabled, but invalid flag posted, fail to create paste',
),
), array(
'conditions' => array('steps' => array('create'), 'traffic/limit' => 10),
@ -43,11 +42,11 @@ new ConfigurationTestGenerator(array(
'type' => 'False',
'args' => array(
'$this->_model->exists(Helper::getPasteId())',
'when discussions are enabled, but invalid flag posted, paste is not created'
'when discussions are enabled, but invalid flag posted, paste is not created',
),
),
),
'affects' => $vcud
'affects' => $vcud,
), array(
'setting' => false,
'tests' => array(
@ -56,11 +55,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<div[^>]*id="opendisc"[^>]*>#',
'$content',
'outputs disabled discussion correctly'
'outputs disabled discussion correctly',
),
),
),
'affects' => $vrd
'affects' => $vrd,
),
),
'main/opendiscussion' => array(
@ -73,11 +72,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
'$content',
'outputs checked discussion correctly'
'outputs checked discussion correctly',
),
),
),
'affects' => $vrd
'affects' => $vrd,
), array(
'setting' => false,
'tests' => array(
@ -87,11 +86,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
'$content',
'outputs unchecked discussion correctly'
'outputs unchecked discussion correctly',
),
),
),
'affects' => $vrd
'affects' => $vrd,
),
),
'main/burnafterreadingselected' => array(
@ -132,11 +131,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<div[^>]*id="password"[^>]*>#',
'$content',
'outputs password input correctly'
'outputs password input correctly',
),
),
),
'affects' => $vrd
'affects' => $vrd,
), array(
'setting' => false,
'tests' => array(
@ -146,11 +145,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
'#<div[^>]*id="password"[^>]*>#',
'$content',
'removes password input correctly'
'removes password input correctly',
),
),
),
'affects' => $vrd
'affects' => $vrd,
),
),
'main/template' => array(
@ -206,11 +205,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
1,
'$response["status"]',
'when sizelimit limit exceeded, fail to create paste'
'when sizelimit limit exceeded, fail to create paste',
),
),
),
'affects' => array('create')
'affects' => array('create'),
), array(
'setting' => 2097152,
'tests' => array(
@ -221,7 +220,7 @@ new ConfigurationTestGenerator(array(
'args' => array(
0,
'$response["status"]',
'when sizelimit limit is not reached, successfully create paste'
'when sizelimit limit is not reached, successfully create paste',
),
), array(
'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true),
@ -229,11 +228,11 @@ new ConfigurationTestGenerator(array(
'type' => 'True',
'args' => array(
'$this->_model->exists($response["id"])',
'when sizelimit limit is not reached, paste exists after posting data'
'when sizelimit limit is not reached, paste exists after posting data',
),
),
),
'affects' => array('create')
'affects' => array('create'),
),
),
'traffic/limit' => array(
@ -246,18 +245,18 @@ new ConfigurationTestGenerator(array(
'args' => array(
0,
'$response["status"]',
'when traffic limit is disabled, successfully create paste'
'when traffic limit is disabled, successfully create paste',
),
), array(
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
'type' => 'True',
'args' => array(
'$this->_model->exists($response["id"])',
'when traffic limit is disabled, paste exists after posting data'
'when traffic limit is disabled, paste exists after posting data',
),
),
),
'affects' => array('create')
'affects' => array('create'),
), array(
'setting' => 10,
'tests' => array(
@ -267,11 +266,11 @@ new ConfigurationTestGenerator(array(
'args' => array(
1,
'$response["status"]',
'when traffic limit is on and we do not wait, fail to create paste'
'when traffic limit is on and we do not wait, fail to create paste',
),
),
),
'affects' => array('create')
'affects' => array('create'),
), array(
'setting' => 2,
'tests' => array(
@ -282,7 +281,7 @@ new ConfigurationTestGenerator(array(
'args' => array(
0,
'$response["status"]',
'when traffic limit is on and we wait, successfully create paste'
'when traffic limit is on and we wait, successfully create paste',
),
), array(
'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152),
@ -290,11 +289,11 @@ new ConfigurationTestGenerator(array(
'type' => 'True',
'args' => array(
'$this->_model->exists($response["id"])',
'when traffic limit is on and we wait, paste exists after posting data'
'when traffic limit is on and we wait, paste exists after posting data',
),
),
),
'affects' => array('create')
'affects' => array('create'),
),
),
));
@ -325,7 +324,7 @@ class ConfigurationTestGenerator
* @var array
*/
private $_configurations = array(
array('options' => array(), 'tests' => array(), 'affects' => array())
array('options' => array(), 'tests' => array(), 'affects' => array()),
);
/**

View file

@ -113,7 +113,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -124,7 +124,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -135,7 +135,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -146,7 +146,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -157,7 +157,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -168,7 +168,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
Database::getInstance(array(
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
));
}
@ -179,7 +179,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
public function testGetFooInstance()
{
Database::getInstance(array(
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null,
));
}
@ -231,7 +231,9 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
mkdir($this->_path);
$path = $this->_path . DIRECTORY_SEPARATOR . 'attachement-test.sq3';
if (is_file($path)) unlink($path);
if (is_file($path)) {
unlink($path);
}
$this->_options['dsn'] = 'sqlite:' . $path;
$this->_options['tbl'] = 'bar_';
$model = Database::getInstance($this->_options);
@ -274,7 +276,9 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
{
mkdir($this->_path);
$path = $this->_path . DIRECTORY_SEPARATOR . 'db-test.sq3';
if (is_file($path)) unlink($path);
if (is_file($path)) {
unlink($path);
}
$this->_options['dsn'] = 'sqlite:' . $path;
$this->_options['tbl'] = 'foo_';
$db = new PDO(
@ -294,13 +298,13 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
);
$db->exec(
'CREATE TABLE foo_comment ( ' .
"dataid CHAR(16) NOT NULL, " .
'dataid CHAR(16) NOT NULL, ' .
'pasteid CHAR(16), ' .
'parentid CHAR(16), ' .
'data BLOB, ' .
'nickname BLOB, ' .
'vizhash BLOB, ' .
"postdate INT );"
'postdate INT );'
);
$this->assertInstanceOf(Database::class, Database::getInstance($this->_options));

View file

@ -1,9 +1,9 @@
<?php
use PrivateBin\Data\Filesystem;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\PrivateBin;
use PrivateBin\Request;
use PrivateBin\Persistence\ServerSalt;
class JsonApiTest extends PHPUnit_Framework_TestCase
{

View file

@ -1,5 +1,6 @@
<?php
use Identicon\Identicon;
use PrivateBin\Configuration;
use PrivateBin\Data\Database;
use PrivateBin\Model;
@ -7,7 +8,6 @@ use PrivateBin\Model\Paste;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\Vizhash16x16;
use Identicon\Identicon;
class ModelTest extends PHPUnit_Framework_TestCase
{
@ -22,7 +22,9 @@ class ModelTest extends PHPUnit_Framework_TestCase
/* Setup Routine */
Helper::confRestore();
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
if (!is_dir($this->_path)) mkdir($this->_path);
if (!is_dir($this->_path)) {
mkdir($this->_path);
}
ServerSalt::setPath($this->_path);
$options = parse_ini_file(CONF, true);
$options['purge']['limit'] = 0;

View file

@ -1,9 +1,9 @@
<?php
use PrivateBin\Data\Filesystem;
use PrivateBin\PrivateBin;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\PrivateBin;
class PrivateBinTest extends PHPUnit_Framework_TestCase
{

View file

@ -1,9 +1,7 @@
<?php
use PrivateBin\Data\Database;
use PrivateBin\PrivateBin;
use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter;
require_once 'PrivateBinTest.php';
@ -14,7 +12,7 @@ class PrivateBinWithDbTest extends PrivateBinTest
'pwd' => null,
'opt' => array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => true
PDO::ATTR_PERSISTENT => true,
),
);