Minor code style fixes, remove unused `use` definitions, set YAML indentation to 2

parent fd813acc
......@@ -7,3 +7,6 @@ charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.{yml, yaml}]
indent_size = 2
filter:
paths: [src/*]
paths: [src/*]
checks:
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
tools:
external_code_coverage:
timeout: 120
external_code_coverage:
timeout: 120
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="true"
timeoutForLargeTests="60"
timeoutForMediumTests="10"
timeoutForSmallTests="1"
verbose="false"
>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="true"
timeoutForLargeTests="60"
timeoutForMediumTests="10"
timeoutForSmallTests="1"
verbose="false"
>
<php>
<ini name="error_reporting" value="-1" />
<ini name="error_reporting" value="-1"/>
<const name="PHPUNIT_TESTSUITE" value="true"/>
<const name="PHPUNIT_DB_HOST" value="127.0.0.1"/>
<const name="PHPUNIT_DB_NAME" value="telegrambot"/>
......
......@@ -47,10 +47,10 @@ class DebugCommand extends AdminCommand
*/
public function execute()
{
$pdo = DB::getPdo();
$pdo = DB::getPdo();
$message = $this->getMessage();
$chat = $message->getChat();
$text = strtolower($message->getText(true));
$chat = $message->getChat();
$text = strtolower($message->getText(true));
$data = ['chat_id' => $chat->getId()];
......@@ -80,7 +80,7 @@ class DebugCommand extends AdminCommand
$debug_info[] = sprintf('*Maximum PHP script execution time:* `%d seconds`', ini_get('max_execution_time'));
$mysql_version = $pdo ? $pdo->query('SELECT VERSION() AS version')->fetchColumn() : null;
$debug_info[] = sprintf('*MySQL version:* `%s`', $mysql_version ?: 'disabled');
$debug_info[] = sprintf('*MySQL version:* `%s`', $mysql_version ?: 'disabled');
$debug_info[] = sprintf('*Operating System:* `%s`', php_uname());
......@@ -88,7 +88,7 @@ class DebugCommand extends AdminCommand
$debug_info[] = sprintf('*Web Server:* `%s`', $_SERVER['SERVER_SOFTWARE']);
}
if (function_exists('curl_init')) {
$curlversion = curl_version();
$curlversion = curl_version();
$debug_info[] = sprintf('*curl version:* `%1$s; %2$s`', $curlversion['version'], $curlversion['ssl_version']);
}
......@@ -105,8 +105,8 @@ class DebugCommand extends AdminCommand
}
$webhook_info_result_str = json_encode($webhook_info_result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
$debug_info[] = $webhook_info_title;
$debug_info[] = sprintf(
$debug_info[] = $webhook_info_title;
$debug_info[] = sprintf(
'```' . PHP_EOL . '%s```',
$webhook_info_result_str
);
......@@ -116,7 +116,7 @@ class DebugCommand extends AdminCommand
}
$data['parse_mode'] = 'Markdown';
$data['text'] = implode(PHP_EOL, $debug_info);
$data['text'] = implode(PHP_EOL, $debug_info);
return Request::sendMessage($data);
}
......
......@@ -11,7 +11,6 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Generic command
......
......@@ -10,9 +10,9 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Generic message command
......
......@@ -11,8 +11,6 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle;
use Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent;
use Longman\TelegramBot\Request;
/**
......
......@@ -11,7 +11,6 @@
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Start command
......
......@@ -179,7 +179,7 @@ class Keyboard extends Entity
protected function validate()
{
$keyboard_type = $this->getKeyboardType();
$keyboard = $this->getProperty($keyboard_type);
$keyboard = $this->getProperty($keyboard_type);
if ($keyboard !== null) {
if (!is_array($keyboard)) {
......
......@@ -442,7 +442,7 @@ class Telegram
*/
public function processUpdate(Update $update)
{
$this->update = $update;
$this->update = $update;
$this->last_update_id = $update->getUpdateId();
//Load admin commands
......@@ -877,7 +877,7 @@ class Telegram
/**
* Enable requests limiter
*
* @param array $options
* @param array $options
*
* @return \Longman\TelegramBot\Telegram
* @throws TelegramException
......@@ -902,7 +902,7 @@ class Telegram
throw new TelegramException('No command(s) provided!');
}
$this->run_commands = true;
$this->run_commands = true;
$result = Request::getMe();
......
......@@ -53,7 +53,7 @@ class ConversationTest extends TestCase
public function testConversationThatExistsPropertiesSetCorrectly()
{
$info = TestHelpers::startFakeConversation();
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$this->assertAttributeEquals($info['user_id'], 'user_id', $conversation);
$this->assertAttributeEquals($info['chat_id'], 'chat_id', $conversation);
......@@ -85,7 +85,7 @@ class ConversationTest extends TestCase
public function testNewConversationThatWillExistWithCommand()
{
$info = TestHelpers::startFakeConversation();
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$this->assertTrue($conversation->exists());
$this->assertEquals('command', $conversation->getCommand());
......@@ -93,7 +93,7 @@ class ConversationTest extends TestCase
public function testStopConversation()
{
$info = TestHelpers::startFakeConversation();
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$this->assertTrue($conversation->exists());
$conversation->stop();
......@@ -104,7 +104,7 @@ class ConversationTest extends TestCase
public function testCancelConversation()
{
$info = TestHelpers::startFakeConversation();
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$this->assertTrue($conversation->exists());
$conversation->cancel();
......@@ -115,8 +115,8 @@ class ConversationTest extends TestCase
public function testUpdateConversationNotes()
{
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$info = TestHelpers::startFakeConversation();
$conversation = new Conversation($info['user_id'], $info['chat_id'], 'command');
$conversation->notes = 'newnote';
$conversation->update();
......
......@@ -306,7 +306,7 @@ class ServerResponseTest extends TestCase
//... they are not finished...
}
public function getStickerSet()
{
TestHelpers::setStaticProperty(Request::class, 'current_action', 'getStickerSet');
......@@ -357,19 +357,19 @@ class ServerResponseTest extends TestCase
}
}';
}
public function testGetStickerSet()
{
$result = $this->getStickerSet();
$server = new ServerResponse(json_decode($result, true), 'testbot');
$server_result = $server->getResult();
self::assertInstanceOf('\Longman\TelegramBot\Entities\StickerSet', $server_result);
self::assertEquals('stickerset_name', $server_result->getName());
self::assertEquals('Some name', $server_result->getTitle());
self::assertFalse($server_result->getContainsMasks());
$stickers = $server_result->getStickers();
self::assertCount(4, $stickers);
self::assertInstanceOf('\Longman\TelegramBot\Entities\Sticker', $stickers[0]);
......
......@@ -223,7 +223,7 @@ class TestHelpers
/**
* Empty all tables for the passed database
*
* @param array $credentials
* @param array $credentials
*/
public static function emptyDb(array $credentials)
{
......
<?php
require __DIR__ . '/../vendor/autoload.php';
$filename='logfile.log';
$API_KEY = 'random';
$filename = 'logfile.log';
$API_KEY = 'random';
$BOT_NAME = 'bot_name';
define('PHPUNIT_TESTSUITE', 'some value');
$CREDENTIALS = array('host'=>'localhost', 'user'=>'', 'password'=>'', 'database'=>'');
$CREDENTIALS = ['host' => 'localhost', 'user' => '', 'password' => '', 'database' => ''];
$update = null;
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment