reformat (phpcs)

pull/181/head
David Goodwin 6 years ago
parent e7f9d536d9
commit b48f99d4c6

@ -1,7 +1,7 @@
<?php <?php
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()
->exclude('smarty') ->exclude('lib')
->exclude('vendor') ->exclude('vendor')
->exclude('templates') ->exclude('templates')
->exclude('templates_c') ->exclude('templates_c')

@ -847,11 +847,9 @@ function generate_password() {
// add random characters to $password until $length is reached // add random characters to $password until $length is reached
$password = ""; $password = "";
while (strlen($password) < $length) { while (strlen($password) < $length) {
if (function_exists('random_int')) { if (function_exists('random_int')) {
$random = random_int(0, strlen($possible) -1); $random = random_int(0, strlen($possible) -1);
} } else {
else {
$random = mt_rand(0, strlen($possible) - 1); $random = mt_rand(0, strlen($possible) - 1);
} }
$char = substr($possible, $random, 1); $char = substr($possible, $random, 1);
@ -1127,7 +1125,6 @@ function _php_crypt_generate_crypt_salt($hash_type='MD5') {
// used for php_crypt method // used for php_crypt method
function _php_crypt_random_string($characters, $length) { function _php_crypt_random_string($characters, $length) {
$random_int_exists = true; $random_int_exists = true;
if (!function_exists('random_int')) { if (!function_exists('random_int')) {
$random_int_exists = false; $random_int_exists = false;
@ -1136,8 +1133,7 @@ function _php_crypt_random_string($characters, $length) {
for ($p = 0; $p < $length; $p++) { for ($p = 0; $p < $length; $p++) {
if ($random_int_exists) { if ($random_int_exists) {
$string .= $characters[random_int(0, strlen($characters) -1)]; $string .= $characters[random_int(0, strlen($characters) -1)];
} } else {
else {
// should really use a stronger randomness source // should really use a stronger randomness source
$string .= $characters[mt_rand(0, strlen($characters) - 1)]; $string .= $characters[mt_rand(0, strlen($characters) - 1)];
} }

@ -4,7 +4,6 @@
# This class is too static - if you inherit a class from it, it will share the static $instance and all its contents # This class is too static - if you inherit a class from it, it will share the static $instance and all its contents
# Therefore the class is marked as final to prevent someone accidently does this ;-) # Therefore the class is marked as final to prevent someone accidently does this ;-)
final class Config { final class Config {
private static $instance = null; private static $instance = null;
/** /**
@ -67,7 +66,6 @@ final class Config {
} }
} }
$_this->setAll($newConfig); $_this->setAll($newConfig);
} }
/** /**

@ -149,7 +149,6 @@ class PostfixAdmin {
* Dispatches a CLI request * Dispatches a CLI request
*/ */
public function dispatch() { public function dispatch() {
check_db_version(); # ensure the database layout is up to date check_db_version(); # ensure the database layout is up to date
if (!isset($this->args[0])) { if (!isset($this->args[0])) {

@ -2,12 +2,8 @@
require_once('common.php'); require_once('common.php');
class GeneratePasswordTest extends PHPUnit_Framework_TestCase class GeneratePasswordTest extends PHPUnit_Framework_TestCase {
{ public function testBasic() {
public function testBasic()
{
$one = generate_password(); $one = generate_password();
$two = generate_password(); $two = generate_password();
@ -15,7 +11,5 @@ class GeneratePasswordTest extends PHPUnit_Framework_TestCase
$this->assertNotEquals($one, $two); $this->assertNotEquals($one, $two);
$this->assertNotEmpty($one); $this->assertNotEmpty($one);
$this->assertNotEmpty($two); $this->assertNotEmpty($two);
} }
} }

@ -2,10 +2,8 @@
require_once('common.php'); require_once('common.php');
class PaCryptTest extends PHPUnit_Framework_TestCase class PaCryptTest extends PHPUnit_Framework_TestCase {
{ public function testMd5Crypt() {
public function testMd5Crypt()
{
$hash = _pacrypt_md5crypt('test', ''); $hash = _pacrypt_md5crypt('test', '');
$this->assertNotEmpty($hash); $this->assertNotEmpty($hash);
@ -14,8 +12,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertEquals($hash, _pacrypt_md5crypt('test', $hash)); $this->assertEquals($hash, _pacrypt_md5crypt('test', $hash));
} }
public function testCrypt() public function testCrypt() {
{
// E_NOTICE if we pass in '' for the salt // E_NOTICE if we pass in '' for the salt
$hash = _pacrypt_crypt('test', 'sa'); $hash = _pacrypt_crypt('test', 'sa');
@ -24,11 +21,9 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertNotEquals('test', $hash); $this->assertNotEquals('test', $hash);
$this->assertEquals($hash, _pacrypt_crypt('test', $hash)); $this->assertEquals($hash, _pacrypt_crypt('test', $hash));
} }
public function testMySQLEncrypt() public function testMySQLEncrypt() {
{
if (!db_mysql()) { if (!db_mysql()) {
$this->markTestSkipped('Not using MySQL'); $this->markTestSkipped('Not using MySQL');
} }
@ -48,8 +43,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertEquals($hash2, _pacrypt_mysql_encrypt('test', 'salt')); $this->assertEquals($hash2, _pacrypt_mysql_encrypt('test', 'salt'));
} }
public function testAuthlib() public function testAuthlib() {
{
// too many options! // too many options!
foreach ( foreach (
@ -67,8 +61,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
} }
} }
public function testPacryptDovecot() public function testPacryptDovecot() {
{
global $CONF; global $CONF;
if (!file_exists('/usr/bin/doveadm')) { if (!file_exists('/usr/bin/doveadm')) {
$this->markTestSkipped("No /usr/bin/doveadm"); $this->markTestSkipped("No /usr/bin/doveadm");
@ -84,8 +77,7 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected_hash, _pacrypt_dovecot('test', $expected_hash)); $this->assertEquals($expected_hash, _pacrypt_dovecot('test', $expected_hash));
} }
public function testPhpCrypt() public function testPhpCrypt() {
{
global $CONF; global $CONF;
$config = Config::getInstance(); $config = Config::getInstance();
@ -104,7 +96,6 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertNotEquals($fail, $expected); $this->assertNotEquals($fail, $expected);
} }
public function testPhpCryptRandomString() { public function testPhpCryptRandomString() {
@ -114,8 +105,6 @@ class PaCryptTest extends PHPUnit_Framework_TestCase
$this->assertNotEmpty($str1); $this->assertNotEmpty($str1);
$this->assertNotEmpty($str2); $this->assertNotEmpty($str2);
$this->assertNotEquals($str1, $str2); $this->assertNotEquals($str1, $str2);
} }
} }

@ -2,11 +2,8 @@
require_once('common.php'); require_once('common.php');
class ValidatePasswordTest extends PHPUnit_Framework_TestCase class ValidatePasswordTest extends PHPUnit_Framework_TestCase {
{ public function testBasic() {
public function testBasic()
{
$config = Config::getInstance(); $config = Config::getInstance();
// Set to the defaults, just to make sure. // Set to the defaults, just to make sure.

Loading…
Cancel
Save