Run php-cs-fixer on the code base
This commit is contained in:
@@ -93,7 +93,8 @@ class Csv
|
||||
{
|
||||
if (! empty($value)) {
|
||||
$value = trim(strtolower($value));
|
||||
return $value === '1' || $value{0} === 't' ? 1 : 0;
|
||||
return $value === '1' || $value{0}
|
||||
=== 't' ? 1 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -187,8 +188,7 @@ class Csv
|
||||
foreach ($this->columns as $sql_name => $csv_name) {
|
||||
if (isset($row[$index])) {
|
||||
$line[$sql_name] = $row[$index];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$line[$sql_name] = '';
|
||||
}
|
||||
|
||||
|
||||
@@ -214,8 +214,7 @@ class DateParser extends Base
|
||||
foreach ($fields as $field) {
|
||||
if (! empty($values[$field])) {
|
||||
$values[$field] = date($format, $values[$field]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$values[$field] = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,7 @@ class HttpClient extends Base
|
||||
|
||||
if (is_resource($stream)) {
|
||||
$response = stream_get_contents($stream);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->container['logger']->error('HttpClient: request failed');
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ class Lexer
|
||||
$this->offset = 0;
|
||||
|
||||
while (isset($input[$this->offset])) {
|
||||
|
||||
$result = $this->match(substr($input, $this->offset));
|
||||
|
||||
if ($result === false) {
|
||||
@@ -84,7 +83,6 @@ class Lexer
|
||||
{
|
||||
foreach ($this->tokenMap as $pattern => $name) {
|
||||
if (preg_match($pattern, $string, $matches)) {
|
||||
|
||||
$this->offset += strlen($matches[1]);
|
||||
|
||||
return array(
|
||||
@@ -113,7 +111,6 @@ class Lexer
|
||||
);
|
||||
|
||||
while (false !== ($token = current($tokens))) {
|
||||
|
||||
switch ($token['token']) {
|
||||
case 'T_ASSIGNEE':
|
||||
case 'T_COLOR':
|
||||
|
||||
@@ -87,7 +87,7 @@ class Client extends Base
|
||||
{
|
||||
$container = $this->container;
|
||||
|
||||
$this->transports[$transport] = function() use ($class, $container) {
|
||||
$this->transports[$transport] = function () use ($class, $container) {
|
||||
return new $class($container);
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ class Mail extends Base implements ClientInterface
|
||||
public function sendEmail($email, $name, $subject, $html, $author)
|
||||
{
|
||||
try {
|
||||
|
||||
$message = Swift_Message::newInstance()
|
||||
->setSubject($subject)
|
||||
->setFrom(array(MAIL_FROM => $author))
|
||||
@@ -38,8 +37,7 @@ class Mail extends Base implements ClientInterface
|
||||
->setTo(array($email => $name));
|
||||
|
||||
Swift_Mailer::newInstance($this->getTransport())->send($message);
|
||||
}
|
||||
catch (Swift_TransportException $e) {
|
||||
} catch (Swift_TransportException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ class Markdown extends Parsedown
|
||||
{
|
||||
// Replace task #123 by a link to the task
|
||||
if (! empty($this->link) && preg_match('!#(\d+)!i', $Excerpt['text'], $matches)) {
|
||||
|
||||
$url = $this->helper->href(
|
||||
$this->link['controller'],
|
||||
$this->link['action'],
|
||||
|
||||
@@ -86,7 +86,6 @@ class OAuth2 extends Base
|
||||
public function getAccessToken($code)
|
||||
{
|
||||
if (empty($this->accessToken) && ! empty($code)) {
|
||||
|
||||
$params = array(
|
||||
'code' => $code,
|
||||
'client_id' => $this->clientId,
|
||||
|
||||
@@ -355,8 +355,7 @@ class Paginator
|
||||
$this->action,
|
||||
$this->getUrlParams($this->page - 1, $this->order, $this->direction)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$html .= '← '.t('Previous');
|
||||
}
|
||||
|
||||
@@ -382,8 +381,7 @@ class Paginator
|
||||
$this->action,
|
||||
$this->getUrlParams($this->page + 1, $this->order, $this->direction)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$html .= t('Next').' →';
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class Base extends \Kanboard\Core\Base
|
||||
{
|
||||
$container = $this->container;
|
||||
|
||||
$this->container['dispatcher']->addListener($event, function() use ($container, $callback) {
|
||||
$this->container['dispatcher']->addListener($event, function () use ($container, $callback) {
|
||||
call_user_func($callback, $container);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ class Loader extends \Kanboard\Core\Base
|
||||
$current_version = $this->getSchemaVersion($plugin);
|
||||
|
||||
try {
|
||||
|
||||
$this->db->startTransaction();
|
||||
$this->db->getDriver()->disableForeignKeys();
|
||||
|
||||
@@ -109,8 +108,7 @@ class Loader extends \Kanboard\Core\Base
|
||||
$this->db->getDriver()->enableForeignKeys();
|
||||
$this->db->closeTransaction();
|
||||
$this->setSchemaVersion($plugin, $i - 1);
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
} catch (PDOException $e) {
|
||||
$this->db->cancelTransaction();
|
||||
$this->db->getDriver()->enableForeignKeys();
|
||||
die('Unable to migrate schema for the plugin: '.$plugin.' => '.$e->getMessage());
|
||||
|
||||
@@ -218,11 +218,8 @@ class Request
|
||||
);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
|
||||
if (isset($_SERVER[$key])) {
|
||||
|
||||
foreach (explode(',', $_SERVER[$key]) as $ip_address) {
|
||||
|
||||
$ip_address = trim($ip_address);
|
||||
|
||||
if ($only_public) {
|
||||
@@ -231,9 +228,7 @@ class Request
|
||||
if (filter_var($ip_address, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
|
||||
return $ip_address;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
return $ip_address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ class Response
|
||||
{
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
|
||||
header('X-Ajax-Redirect: '.$url);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
header('Location: '.$url);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,17 +127,13 @@ class Router extends Base
|
||||
$count = count($parts);
|
||||
|
||||
foreach ($this->paths as $route) {
|
||||
|
||||
if ($count === $route['count']) {
|
||||
|
||||
$params = array();
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
||||
if ($route['pattern'][$i]{0} === ':') {
|
||||
$params[substr($route['pattern'][$i], 1)] = $parts[$i];
|
||||
}
|
||||
else if ($route['pattern'][$i] !== $parts[$i]) {
|
||||
} elseif ($route['pattern'][$i] !== $parts[$i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +164,6 @@ class Router extends Base
|
||||
}
|
||||
|
||||
foreach ($this->urls[$controller][$action] as $pattern) {
|
||||
|
||||
if (array_diff_key($params, $pattern['params']) === array()) {
|
||||
$url = $pattern['path'];
|
||||
$i = 0;
|
||||
@@ -213,8 +208,7 @@ class Router extends Base
|
||||
$this->controller = $this->sanitize($_GET['controller'], 'app');
|
||||
$this->action = $this->sanitize($_GET['action'], 'index');
|
||||
$plugin = ! empty($_GET['plugin']) ? $this->sanitize($_GET['plugin'], '') : '';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
list($this->controller, $this->action) = $this->findRoute($this->getPath($uri, $query_string)); // TODO: add plugin for routes
|
||||
$plugin = '';
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Kanboard\Core;
|
||||
*/
|
||||
class Security
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Generate a random token with different methods: openssl or /dev/urandom or fallback to uniqid()
|
||||
*
|
||||
* @static
|
||||
@@ -21,8 +21,7 @@ class Security
|
||||
{
|
||||
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||
return bin2hex(\openssl_random_pseudo_bytes(30));
|
||||
}
|
||||
else if (ini_get('open_basedir') === '' && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||
} elseif (ini_get('open_basedir') === '' && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||
return hash('sha256', file_get_contents('/dev/urandom', false, null, 0, 30));
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,7 @@ class Template extends Helper
|
||||
if (strpos($template_name, ':') !== false) {
|
||||
list($plugin, $template) = explode(':', $template_name);
|
||||
$path = __DIR__.'/../../plugins/'.ucfirst($plugin).'/Template/'.$template.'.php';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$path = __DIR__.'/../Template/'.$template_name.'.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ class Tool
|
||||
return '';
|
||||
}
|
||||
|
||||
list($local_part,) = explode('@', $email);
|
||||
list(,$identifier) = explode('+', $local_part);
|
||||
list($local_part, ) = explode('@', $email);
|
||||
list(, $identifier) = explode('+', $local_part);
|
||||
|
||||
return $identifier;
|
||||
}
|
||||
@@ -83,14 +83,11 @@ class Tool
|
||||
$dst_width = $resize_width;
|
||||
$dst_height = floor($src_height * ($resize_width / $src_width));
|
||||
$dst_image = imagecreatetruecolor($dst_width, $dst_height);
|
||||
}
|
||||
elseif ($resize_width == 0 && $resize_height > 0) {
|
||||
} elseif ($resize_width == 0 && $resize_height > 0) {
|
||||
$dst_width = floor($src_width * ($resize_height / $src_height));
|
||||
$dst_height = $resize_height;
|
||||
$dst_image = imagecreatetruecolor($dst_width, $dst_height);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
$src_ratio = $src_width / $src_height;
|
||||
$resize_ratio = $resize_width / $resize_height;
|
||||
|
||||
@@ -99,8 +96,7 @@ class Tool
|
||||
$dst_height = floor($src_height * ($resize_width / $src_width));
|
||||
|
||||
$dst_y = ($dst_height - $resize_height) / 2 * (-1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dst_width = floor($src_width * ($resize_height / $src_height));
|
||||
$dst_height = $resize_height;
|
||||
|
||||
|
||||
@@ -184,8 +184,7 @@ class Translator
|
||||
{
|
||||
if (isset(self::$locales[$identifier])) {
|
||||
return self::$locales[$identifier];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user