reformat (phpcs)

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

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

@ -847,11 +847,9 @@ function generate_password() {
// add random characters to $password until $length is reached
$password = "";
while (strlen($password) < $length) {
if(function_exists('random_int')) {
if (function_exists('random_int')) {
$random = random_int(0, strlen($possible) -1);
}
else {
} else {
$random = mt_rand(0, strlen($possible) - 1);
}
$char = substr($possible, $random, 1);
@ -1064,7 +1062,7 @@ function _pacrypt_php_crypt($pw, $pw_db) {
} else {
$salt_method = 'MD5'; // default.
// no pw provided. create new password hash
if(strpos($CONF['encrypt'], ':') !== false) {
if (strpos($CONF['encrypt'], ':') !== false) {
// use specified hash method
$split_method = explode(':', $CONF['encrypt']);
$salt_method = $split_method[1];
@ -1127,17 +1125,15 @@ function _php_crypt_generate_crypt_salt($hash_type='MD5') {
// used for php_crypt method
function _php_crypt_random_string($characters, $length) {
$random_int_exists = true;
if(!function_exists('random_int')) {
if (!function_exists('random_int')) {
$random_int_exists = false;
}
$string = '';
for ($p = 0; $p < $length; $p++) {
if($random_int_exists) {
if ($random_int_exists) {
$string .= $characters[random_int(0, strlen($characters) -1)];
}
else {
} else {
// should really use a stronger randomness source
$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
# Therefore the class is marked as final to prevent someone accidently does this ;-)
final class Config {
private static $instance = null;
/**
@ -67,7 +66,6 @@ final class Config {
}
}
$_this->setAll($newConfig);
}
/**
@ -97,7 +95,7 @@ final class Config {
$zero = $name[0];
$one = $name[1];
$two = $name[2];
if(isset($config[$zero], $config[$zero][$one], $config[$zero][$one][$two])) {
if (isset($config[$zero], $config[$zero][$one], $config[$zero][$one][$two])) {
return $config[$zero][$one][$two];
}
break;

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

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

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

@ -15,11 +15,11 @@ abstract class RemoteTest extends PHPUnit_Framework_TestCase {
public function setUp() {
parent::setUp();
if($this->server_url == 'http://change.me/to/work') {
if ($this->server_url == 'http://change.me/to/work') {
$this->markTestSkipped("Test skipped; Configuration change to \$this->server_url required");
}
if(!class_exists('Zend_XmlRpc_Client', true)) {
if (!class_exists('Zend_XmlRpc_Client', true)) {
$this->markTestSkipped("Test skipped; Zend_XmlRpc_Client not found");
}

@ -2,14 +2,11 @@
require_once('common.php');
class ValidatePasswordTest extends PHPUnit_Framework_TestCase
{
public function testBasic()
{
class ValidatePasswordTest extends PHPUnit_Framework_TestCase {
public function testBasic() {
$config = Config::getInstance();
// Set to the defaults, just to make sure.
// Set to the defaults, just to make sure.
Config::write('password_validation', array(
# '/regular expression/' => '$PALANG key (optional: + parameter)',
'/.{5}/' => 'password_too_short 5', # minimum length 5 characters

Loading…
Cancel
Save