mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 11:12:15 +02:00
PSR2 -> PSR12 formatting
This commit is contained in:
parent
bed0300fae
commit
2d6ded2786
@ -14,7 +14,7 @@ $config = new PhpCsFixer\Config();
|
||||
return $config
|
||||
->setFinder($finder)
|
||||
->setRules(array(
|
||||
'@PSR2' => true,
|
||||
'@PSR12' => true,
|
||||
'method_argument_space' => false, # don't break formatting in initStruct()
|
||||
'no_spaces_inside_parenthesis' => false, # don't break formatting in initStruct()
|
||||
));
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// vim:ts=4:sw=4:et
|
||||
ini_set('include_path', get_include_path() . ':' . dirname(__FILE__));
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/common.php');
|
||||
|
||||
$xmlrpc = get_xmlrpc();
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// vim:ts=4:sw=4:et
|
||||
if (!defined('SM_PATH')) {
|
||||
die("Invalid internal state (don't access file directly)");
|
||||
|
@ -1983,7 +1983,7 @@ function db_delete($table, $where, $delete, $additionalwhere='')
|
||||
* @param boolean $throw_exceptions
|
||||
* @return int - number of inserted rows
|
||||
*/
|
||||
function db_insert(string $table, array $values, array $timestamp = array('created', 'modified'), bool $throw_exceptions = false) : int
|
||||
function db_insert(string $table, array $values, array $timestamp = array('created', 'modified'), bool $throw_exceptions = false): int
|
||||
{
|
||||
$table = table_by_key($table);
|
||||
|
||||
@ -2027,7 +2027,7 @@ function db_insert(string $table, array $values, array $timestamp = array('creat
|
||||
* @param array $timestamp (optional) - array of fields to set to now() - default: array('modified')
|
||||
* @return int - number of updated rows
|
||||
*/
|
||||
function db_update(string $table, string $where_col, string $where_value, array $values, array $timestamp = array('modified'), bool $throw_exceptions = false):int
|
||||
function db_update(string $table, string $where_col, string $where_value, array $values, array $timestamp = array('modified'), bool $throw_exceptions = false): int
|
||||
{
|
||||
$table_key = table_by_key($table);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// Postfix Admin
|
||||
// by Mischa Peters <mischa at high5 dot net>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
class AdminHandler extends PFAHandler
|
||||
@ -129,7 +130,7 @@ class AdminHandler extends PFAHandler
|
||||
* called by $this->store() after storing $this->values in the database
|
||||
* can be used to update additional tables, call scripts etc.
|
||||
*/
|
||||
protected function postSave() : bool
|
||||
protected function postSave(): bool
|
||||
{
|
||||
# store list of allowed domains in the domain_admins table
|
||||
if (isset($this->values['domains'])) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
class AdminpasswordHandler extends PFAHandler
|
||||
@ -39,7 +40,7 @@ class AdminpasswordHandler extends PFAHandler
|
||||
);
|
||||
}
|
||||
|
||||
public function init(string $id) :bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
# hardcode to logged in admin
|
||||
if ($this->admin_username == '') {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
@ -141,7 +142,7 @@ class AliasHandler extends PFAHandler
|
||||
* AliasHandler needs some special handling in init() and therefore overloads the function.
|
||||
* It also calls parent::init()
|
||||
*/
|
||||
public function init(string $id) : bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
$bits = explode('@', $id);
|
||||
if (sizeof($bits) == 2) {
|
||||
@ -314,7 +315,7 @@ class AliasHandler extends PFAHandler
|
||||
$this->values['goto'] = join(',', $values['goto']);
|
||||
}
|
||||
|
||||
protected function postSave() : bool
|
||||
protected function postSave(): bool
|
||||
{
|
||||
# TODO: if alias belongs to a mailbox, update mailbox active status
|
||||
return true;
|
||||
@ -371,7 +372,7 @@ class AliasHandler extends PFAHandler
|
||||
return array($condition, $searchmode);
|
||||
}
|
||||
|
||||
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1) : bool
|
||||
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1): bool
|
||||
{
|
||||
list($condition, $searchmode) = $this->condition_ignore_mailboxes($condition, $searchmode);
|
||||
$this->set_is_mailbox_extrafrom($condition, $searchmode);
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
@ -53,7 +54,7 @@ class AliasdomainHandler extends PFAHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function init(string $id) : bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
$success = parent::init($id);
|
||||
if ($success) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
/**
|
||||
* class to handle 'delete' in Cli
|
||||
@ -6,7 +7,6 @@
|
||||
|
||||
class CliDelete extends Shell
|
||||
{
|
||||
|
||||
/**
|
||||
* Execution method always used for tasks
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
class CliHelp extends Shell
|
||||
@ -17,7 +18,7 @@ class CliHelp extends Shell
|
||||
|
||||
public function help()
|
||||
{
|
||||
$handler = new $this->handler_to_use;
|
||||
$handler = new $this->handler_to_use();
|
||||
# TODO: adjust help text according to $handler->taskNames
|
||||
|
||||
$module = preg_replace('/Handler$/', '', $this->handler_to_use);
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
/**
|
||||
* class to display the database scheme (for usage in upgrade.php) in Cli
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
/**
|
||||
* class to handle 'view' in Cli
|
||||
@ -6,7 +7,6 @@
|
||||
|
||||
class CliView extends Shell
|
||||
{
|
||||
|
||||
/**
|
||||
* Execution method always used for tasks
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
# This class is too static - if you inherit a class from it, it will share the static $instance and all its contents
|
||||
@ -48,7 +49,7 @@ final class Config
|
||||
* @param string $var
|
||||
* @return array
|
||||
*/
|
||||
public static function read_array(string $var) : array
|
||||
public static function read_array(string $var): array
|
||||
{
|
||||
$stuff = self::read($var);
|
||||
|
||||
@ -59,7 +60,7 @@ final class Config
|
||||
return $stuff;
|
||||
}
|
||||
|
||||
public static function has(string $var) : bool
|
||||
public static function has(string $var): bool
|
||||
{
|
||||
$x = self::getInstance()->getAll();
|
||||
return array_key_exists($var, $x);
|
||||
@ -68,7 +69,7 @@ final class Config
|
||||
* @param string $var
|
||||
* @return string
|
||||
*/
|
||||
public static function read_string(string $var) : string
|
||||
public static function read_string(string $var): string
|
||||
{
|
||||
$stuff = self::read($var);
|
||||
|
||||
@ -117,7 +118,7 @@ final class Config
|
||||
* @param string $value Value to use as sprintf parameter
|
||||
* @return string value of Config::$var, parsed by sprintf
|
||||
*/
|
||||
public static function read_f(string $var, string $value) : string
|
||||
public static function read_f(string $var, string $value): string
|
||||
{
|
||||
$text = self::read_string($var);
|
||||
|
||||
@ -141,7 +142,7 @@ final class Config
|
||||
* @param string $var Variable to obtain
|
||||
* @return bool value of Configure::$var (TRUE (on YES/yes) or FALSE (on NO/no/not set/unknown value)
|
||||
*/
|
||||
public static function bool(string $var) : bool
|
||||
public static function bool(string $var): bool
|
||||
{
|
||||
$value = self::read($var);
|
||||
|
||||
@ -173,7 +174,7 @@ final class Config
|
||||
* Used to read Config::$var, converted to bool, returned as integer (0 or 1)
|
||||
* @see bool()
|
||||
*/
|
||||
public static function intbool($var) : int
|
||||
public static function intbool($var): int
|
||||
{
|
||||
return Config::bool($var) ? 1 : 0;
|
||||
}
|
||||
@ -187,7 +188,7 @@ final class Config
|
||||
* @return string value of $PALANG[$var]
|
||||
* @access public
|
||||
*/
|
||||
public static function lang(string $var) : string
|
||||
public static function lang(string $var): string
|
||||
{
|
||||
$languages = self::read_array('__LANG');
|
||||
|
||||
@ -208,7 +209,7 @@ final class Config
|
||||
* @param string $value Value to use as sprintf parameter
|
||||
* @return string value of $PALANG[$var], parsed by sprintf
|
||||
*/
|
||||
public static function lang_f(string $var, $value) : string
|
||||
public static function lang_f(string $var, $value): string
|
||||
{
|
||||
$all = self::read_array('__LANG');
|
||||
|
||||
@ -227,7 +228,7 @@ final class Config
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAll() : array
|
||||
public function getAll(): array
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
@ -153,7 +154,7 @@ class DomainHandler extends PFAHandler
|
||||
}
|
||||
|
||||
|
||||
protected function preSave() : bool
|
||||
protected function preSave(): bool
|
||||
{
|
||||
# TODO: is this function superfluous? _can_edit should already cover this
|
||||
if ($this->is_superadmin) {
|
||||
@ -167,7 +168,7 @@ class DomainHandler extends PFAHandler
|
||||
* called by $this->store() after storing $this->values in the database
|
||||
* can be used to update additional tables, call scripts etc.
|
||||
*/
|
||||
protected function postSave() : bool
|
||||
protected function postSave(): bool
|
||||
{
|
||||
if ($this->new && $this->values['default_aliases']) {
|
||||
foreach (Config::read_array('default_aliases') as $address=>$goto) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
@ -66,7 +67,7 @@ class MailboxHandler extends PFAHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function init(string $id) : bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
if (!parent::init($id)) {
|
||||
return false;
|
||||
@ -232,7 +233,7 @@ class MailboxHandler extends PFAHandler
|
||||
}
|
||||
|
||||
|
||||
protected function preSave() : bool
|
||||
protected function preSave(): bool
|
||||
{
|
||||
if (isset($this->values['quota']) && $this->values['quota'] != -1 && is_numeric($this->values['quota'])) {
|
||||
$multiplier = Config::read_string('quota_multiplier');
|
||||
@ -310,7 +311,7 @@ class MailboxHandler extends PFAHandler
|
||||
return $ok && parent::set($values);
|
||||
}
|
||||
|
||||
protected function postSave() : bool
|
||||
protected function postSave(): bool
|
||||
{
|
||||
if ($this->new) {
|
||||
if (!$this->mailbox_post_script()) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
abstract class PFAHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* public variables
|
||||
*/
|
||||
@ -342,7 +342,7 @@ abstract class PFAHandler
|
||||
* initialize with $id and check if it is valid
|
||||
* @param string $id
|
||||
*/
|
||||
public function init(string $id) : bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
|
||||
// postfix treats address lookups (aliases, mailboxes) as if they were lowercase.
|
||||
@ -544,7 +544,7 @@ abstract class PFAHandler
|
||||
* @return bool - true if all values were stored in the database, otherwise false
|
||||
* error messages (if any) are stored in $this->errormsg
|
||||
*/
|
||||
public function save() : bool
|
||||
public function save(): bool
|
||||
{
|
||||
# backwards compability: save() was once (up to 3.2.x) named store(). If a child class still uses the old name, let it override save().
|
||||
if (method_exists($this, 'store')) {
|
||||
@ -619,7 +619,7 @@ abstract class PFAHandler
|
||||
* called by $this->save() before storing the values in the database
|
||||
* @return bool - if false, save() will abort
|
||||
*/
|
||||
protected function preSave() : bool
|
||||
protected function preSave(): bool
|
||||
{
|
||||
# backwards compability: preSave() was once (up to 3.2.x) named beforestore(). If a child class still uses the old name, let it override preSave().
|
||||
# Note: if a child class also has preSave(), it will override this function and obviously also the compability code.
|
||||
@ -635,7 +635,7 @@ abstract class PFAHandler
|
||||
* called by $this->save() after storing $this->values in the database
|
||||
* can be used to update additional tables, call scripts etc.
|
||||
*/
|
||||
protected function postSave() : bool
|
||||
protected function postSave(): bool
|
||||
{
|
||||
# backwards compability: postSave() was once (up to 3.2.x) named storemore(). If a child class still uses the old name, let it override postSave().
|
||||
# Note: if a child class also has postSave(), it will override this function and obviously also the compability code.
|
||||
@ -770,7 +770,7 @@ abstract class PFAHandler
|
||||
* @param int $offset - number of first row to return
|
||||
* @return array - rows (as associative array, with the ID as key)
|
||||
*/
|
||||
protected function read_from_db($condition, $searchmode = array(), $limit=-1, $offset=-1) : array
|
||||
protected function read_from_db($condition, $searchmode = array(), $limit=-1, $offset=-1): array
|
||||
{
|
||||
$queryparts = $this->build_select_query($condition, $searchmode);
|
||||
|
||||
@ -838,7 +838,7 @@ abstract class PFAHandler
|
||||
* @return bool - always true, no need to check ;-) (if $result is not an array, getList die()s)
|
||||
* The data is stored in $this->result (as array of rows, each row is an associative array of column => value)
|
||||
*/
|
||||
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1) : bool
|
||||
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1): bool
|
||||
{
|
||||
if (is_array($condition)) {
|
||||
$real_condition = array();
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
# $Id$
|
||||
|
||||
class VacationHandler extends PFAHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -19,7 +19,7 @@ class VacationHandler extends PFAHandler
|
||||
*/
|
||||
protected $domain_field = 'domain';
|
||||
|
||||
public function init(string $id) : bool
|
||||
public function init(string $id): bool
|
||||
{
|
||||
throw new \Exception('VacationHandler is not yet ready to be used with *Handler methods');
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . '/../common.php');
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
// File: index.php
|
||||
//
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
||||
# Note: run with upgrade.php?debug=1 to see all SQL error messages
|
||||
|
@ -69,7 +69,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$error = true;
|
||||
flash_error(Config::lang('pPassword_password_text_error'));
|
||||
} else {
|
||||
$handler = $context === 'admin' ? new AdminHandler : new MailboxHandler;
|
||||
$handler = $context === 'admin' ? new AdminHandler() : new MailboxHandler();
|
||||
if (!$handler->checkPasswordRecoveryCode($tUsername, $tCode)) {
|
||||
flash_error(Config::lang('pPassword_code_text_error'));
|
||||
} else {
|
||||
|
@ -69,7 +69,6 @@ echo $server->handle();
|
||||
|
||||
class UserProxy
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $old_password
|
||||
* @param string $new_password
|
||||
|
@ -208,7 +208,7 @@ class PostfixAdmin
|
||||
# TODO: add a way to Cli* to signal if the selected handler is supported (for example, not all *Handler support changing the password)
|
||||
|
||||
if (strtolower(get_parent_class($shell)) == 'shell') {
|
||||
$handler = new $shell->handler_to_use;
|
||||
$handler = new $shell->handler_to_use();
|
||||
if (in_array($task, $handler->taskNames)) {
|
||||
$this->shiftArgs();
|
||||
$shell->startup();
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
class Crypt
|
||||
{
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class AdminHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class ConfigTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
$c = Config::getInstance();
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class CreatePageBrowserTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function tearDown() : void
|
||||
public function tearDown(): void
|
||||
{
|
||||
$this->cleanup();
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ class DbBasicTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private $test_domain;
|
||||
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
$db = db_connect();
|
||||
$test_domain = 'test' . uniqid() . '.com';
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class MailboxHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function tearDown() : void
|
||||
public function tearDown(): void
|
||||
{
|
||||
db_query('DELETE FROM mailbox');
|
||||
db_query('DELETE FROM alias');
|
||||
@ -12,7 +12,7 @@ class MailboxHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
global $CONF;
|
||||
parent::setUp();
|
||||
|
@ -13,7 +13,7 @@ abstract class RemoteTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
protected $xmlrpc_client;
|
||||
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -9,12 +9,10 @@ require_once('RemoteTest.php');
|
||||
|
||||
class RemoteVacationTest extends RemoteTest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Adds the test recipient data to the database.
|
||||
*/
|
||||
public function setUp() : void
|
||||
public function setUp(): void
|
||||
{
|
||||
// Ensure config.inc.php is vaguely correct.
|
||||
global $CONF;
|
||||
|
Loading…
Reference in New Issue
Block a user