This commit is contained in:
rugk 2016-11-08 16:56:16 +01:00
commit bfe595e1a1
No known key found for this signature in database
GPG Key ID: 05D40A636AFAB34D
36 changed files with 462 additions and 458 deletions

View File

@ -38,6 +38,6 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = false
[.travis.yml]
[*.yml]
indent_style = space
indent_size = 4
indent_size = 2

View File

@ -15,9 +15,9 @@ return Symfony\CS\Config\Config::create()
->fixers(['concat_with_spaces', 'long_array_syntax', 'standardize_not_equal',
'operators_spaces', 'duplicate_semicolon',
'remove_leading_slash_use', 'align_equals',
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_scalar',
'phpdoc_to_comment', 'phpdoc_trim',
'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_order',
'phpdoc_scalar', 'phpdoc_to_comment', 'phpdoc_trim',
'phpdoc_types', 'print_to_echo', 'self_accessor', 'single_quote',
'spaces_cast', 'ternary_spaces', 'phpdoc_order'])
'spaces_cast', 'ternary_spaces'])
->finder($finder)
;

26
.styleci.yml Normal file
View File

@ -0,0 +1,26 @@
preset: recommended
risky: false
enabled:
- no_empty_comment
- align_equals
- long_array_syntax
- concat_with_spaces
disabled:
- blank_line_after_opening_tag
- blank_line_before_return
- concat_without_spaces
- declare_equal_normalize
- heredoc_to_nowdoc
- method_argument_space
- new_with_braces
- phpdoc_align
- phpdoc_no_access
- phpdoc_separation
- phpdoc_single_line_var_spacing
- phpdoc_summary
- short_array_syntax
- single_line_after_imports
- unalign_equals

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;
/**

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,
),
);