From 20bb3c07a071c65f7c284521e9975f23c5b9b8e0 Mon Sep 17 00:00:00 2001 From: Camilo Sperberg Date: Wed, 27 Dec 2017 00:20:13 +0100 Subject: [PATCH 1/2] Lower required packages to a PHP7.0 installable set --- composer.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.lock b/composer.lock index e723150..74aeb4f 100644 --- a/composer.lock +++ b/composer.lock @@ -288,32 +288,32 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -338,7 +338,7 @@ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2015-06-14T21:17:01+00:00" }, { "name": "monolog/monolog", From 40e823d96158a21d6ecb95b97c83f82c8234ee12 Mon Sep 17 00:00:00 2001 From: Camilo Sperberg Date: Tue, 2 Jan 2018 22:56:57 +0100 Subject: [PATCH 2/2] Introduce external dummy logger --- composer.json | 3 +- composer.lock | 189 +++++++++++++++++- src/Abstracts/TelegramTypes.php | 4 +- src/InternalFunctionality/DummyLogger.php | 68 ------- src/TgLog.php | 12 +- .../InternalFunctionality/DummyLoggerTest.php | 86 -------- 6 files changed, 197 insertions(+), 165 deletions(-) delete mode 100644 src/InternalFunctionality/DummyLogger.php delete mode 100644 tests/InternalFunctionality/DummyLoggerTest.php diff --git a/composer.json b/composer.json index 486eb28..24cbf87 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,9 @@ ], "require": { "php": ">=7.0.0", + "roave/security-advisories": "dev-master", "guzzlehttp/guzzle": "~6.0", - "psr/log": "~1.0" + "unreal4u/dummy-logger": "~1.0" }, "require-dev": { "monolog/monolog": "~1.17", diff --git a/composer.lock b/composer.lock index 74aeb4f..c2b1d46 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "51fc76d6f147c710a866a611c2ff4eb2", + "content-hash": "c936fe27dbf5683143ca9da6d4591f60", "packages": [ { "name": "guzzlehttp/guzzle", @@ -283,6 +283,189 @@ "psr-3" ], "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "roave/security-advisories", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Roave/SecurityAdvisories.git", + "reference": "0703d860f83775029738dc4a519301e8e3d81853" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/0703d860f83775029738dc4a519301e8e3d81853", + "reference": "0703d860f83775029738dc4a519301e8e3d81853", + "shasum": "" + }, + "conflict": { + "adodb/adodb-php": "<5.20.6", + "amphp/artax": "<1.0.6|>=2,<2.0.6", + "aws/aws-sdk-php": ">=3,<3.2.1", + "bugsnag/bugsnag-laravel": ">=2,<2.0.2", + "cakephp/cakephp": ">=1.3,<1.3.18|>=2,<2.4.99|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3,<3.0.15|>=3.1,<3.1.4", + "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", + "cartalyst/sentry": "<=2.1.6", + "codeigniter/framework": "<=3.0.6", + "composer/composer": "<=1.0.0-alpha11", + "contao-components/mediaelement": ">=2.14.2,<2.21.1", + "contao/core": ">=2,<3.5.31", + "contao/core-bundle": ">=4,<4.4.8", + "contao/listing-bundle": ">=4,<4.4.8", + "doctrine/annotations": ">=1,<1.2.7", + "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", + "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", + "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2", + "doctrine/doctrine-bundle": "<1.5.2", + "doctrine/doctrine-module": "<=0.7.1", + "doctrine/mongodb-odm": ">=1,<1.0.2", + "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", + "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1", + "dompdf/dompdf": ">=0.6,<0.6.2", + "drupal/core": ">=8,<8.3.7", + "drupal/drupal": ">=8,<8.3.7", + "ezsystems/ezpublish-legacy": ">=5.3,<5.3.12.2|>=5.4,<5.4.10.1|>=2017.8,<2017.8.1.1", + "firebase/php-jwt": "<2", + "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", + "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", + "gree/jose": "<=2.2", + "gregwar/rst": "<1.0.3", + "guzzlehttp/guzzle": ">=6,<6.2.1|>=4.0.0-rc2,<4.2.4|>=5,<5.3.1", + "illuminate/auth": ">=4,<4.0.99|>=4.1,<4.1.26", + "illuminate/database": ">=4,<4.0.99|>=4.1,<4.1.29", + "joomla/session": "<1.3.1", + "laravel/framework": ">=4,<4.0.99|>=4.1,<4.1.29", + "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", + "magento/magento1ce": ">=1.5.0.1,<1.9.3.2", + "magento/magento1ee": ">=1.9,<1.14.3.2", + "magento/magento2ce": ">=2,<2.2", + "monolog/monolog": ">=1.8,<1.12", + "namshi/jose": "<2.2", + "onelogin/php-saml": "<2.10.4", + "oro/crm": ">=1.7,<1.7.4", + "oro/platform": ">=1.7,<1.7.4", + "phpmailer/phpmailer": ">=5,<5.2.24", + "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", + "phpxmlrpc/extras": "<6.0.1", + "pusher/pusher-php-server": "<2.2.1", + "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", + "shopware/shopware": "<5.2.25", + "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", + "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", + "silverstripe/framework": ">=3,<3.3", + "silverstripe/userforms": "<3", + "simplesamlphp/saml2": "<1.8.1|>=1.9,<1.9.1|>=1.10,<1.10.3|>=2,<2.3.3", + "simplesamlphp/simplesamlphp": "<1.14.16", + "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", + "socalnick/scn-social-auth": "<1.15.2", + "squizlabs/php_codesniffer": ">=1,<2.8.1", + "swiftmailer/swiftmailer": ">=4,<5.4.5", + "symfony/dependency-injection": ">=2,<2.0.17", + "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2", + "symfony/http-foundation": ">=2,<2.3.27|>=2.4,<2.5.11|>=2.6,<2.6.6", + "symfony/http-kernel": ">=2,<2.3.29|>=2.4,<2.5.12|>=2.6,<2.6.8", + "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/routing": ">=2,<2.0.19", + "symfony/security": ">=2,<2.0.25|>=2.1,<2.1.13|>=2.2,<2.2.9|>=2.3,<2.3.37|>=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8.23,<2.8.25|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5", + "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<2.8.6|>=2.8.23,<2.8.25|>=3,<3.0.6|>=3.2.10,<3.2.12|>=3.3.3,<3.3.5", + "symfony/security-csrf": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/serializer": ">=2,<2.0.11", + "symfony/symfony": ">=2,<2.3.41|>=2.4,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/translation": ">=2,<2.0.17", + "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", + "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", + "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "thelia/backoffice-default-template": ">=2.1,<2.1.2", + "thelia/thelia": ">=2.1.0-beta1,<2.1.3|>=2.1,<2.1.2", + "twig/twig": "<1.20", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.22|>=8,<8.7.5", + "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", + "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", + "willdurand/js-translation-bundle": "<2.1.1", + "yiisoft/yii": ">=1.1.14,<1.1.15", + "yiisoft/yii2": "<2.0.5", + "yiisoft/yii2-bootstrap": "<2.0.4", + "yiisoft/yii2-dev": "<2.0.4", + "yiisoft/yii2-gii": "<2.0.4", + "yiisoft/yii2-jui": "<2.0.4", + "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", + "zendframework/zend-diactoros": ">=1,<1.0.4", + "zendframework/zend-form": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-http": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.3,<2.3.8|>=2.4,<2.4.1", + "zendframework/zend-json": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zend-ldap": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.8|>=2.3,<2.3.3", + "zendframework/zend-mail": ">=2,<2.4.11|>=2.5,<2.7.2", + "zendframework/zend-navigation": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-session": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.9|>=2.3,<2.3.4", + "zendframework/zend-validator": ">=2.3,<2.3.6", + "zendframework/zend-view": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zendframework": ">=2,<2.4.11|>=2.5,<2.5.1", + "zendframework/zendframework1": "<1.12.20", + "zendframework/zendopenid": ">=2,<2.0.2", + "zendframework/zendxml": ">=1,<1.0.1", + "zetacomponents/mail": "<1.8.2", + "zf-commons/zfc-user": "<1.2.2", + "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", + "zfr/zfr-oauth2-server-module": "<0.1.2" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "role": "maintainer" + } + ], + "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", + "time": "2017-12-24T19:52:27+00:00" + }, + { + "name": "unreal4u/dummy-logger", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/unreal4u/dummyLogger.git", + "reference": "48e049c6e1519a67eee1173e88e8c4c5e969c267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/unreal4u/dummyLogger/zipball/48e049c6e1519a67eee1173e88e8c4c5e969c267", + "reference": "48e049c6e1519a67eee1173e88e8c4c5e969c267", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/log": "~1.0", + "roave/security-advisories": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "unreal4u\\Dummy\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Camilo Sperberg", + "email": "me+ghdummylogger@unreal4u.com" + } + ], + "description": "Dummy logger that implements PSR-3 so that my own classes can work with a common base", + "time": "2018-01-02T21:34:48+00:00" } ], "packages-dev": [ @@ -1902,7 +2085,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "roave/security-advisories": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Abstracts/TelegramTypes.php b/src/Abstracts/TelegramTypes.php index 8656d6f..86bf04a 100644 --- a/src/Abstracts/TelegramTypes.php +++ b/src/Abstracts/TelegramTypes.php @@ -5,7 +5,7 @@ namespace unreal4u\TelegramAPI\Abstracts; use Psr\Log\LoggerInterface; -use unreal4u\TelegramAPI\InternalFunctionality\DummyLogger; +use unreal4u\Dummy\Logger; use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultArray; abstract class TelegramTypes @@ -15,7 +15,7 @@ abstract class TelegramTypes public function __construct(array $data = null, LoggerInterface $logger = null) { if ($logger === null) { - $logger = new DummyLogger(); + $logger = new Logger(); } $this->logger = $logger; diff --git a/src/InternalFunctionality/DummyLogger.php b/src/InternalFunctionality/DummyLogger.php deleted file mode 100644 index 77293d9..0000000 --- a/src/InternalFunctionality/DummyLogger.php +++ /dev/null @@ -1,68 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - public function alert($message, array $context = array()): bool - { - return $this->log(LogLevel::ALERT, $message, $context); - } - - public function critical($message, array $context = array()): bool - { - return $this->log(LogLevel::CRITICAL, $message, $context); - } - - public function error($message, array $context = array()): bool - { - return $this->log(LogLevel::ERROR, $message, $context); - } - - public function warning($message, array $context = array()): bool - { - return $this->log(LogLevel::WARNING, $message, $context); - } - - public function notice($message, array $context = array()): bool - { - return $this->log(LogLevel::NOTICE, $message, $context); - } - - public function info($message, array $context = array()): bool - { - return $this->log(LogLevel::INFO, $message, $context); - } - - public function debug($message, array $context = array()): bool - { - return $this->log(LogLevel::DEBUG, $message, $context); - } - - /** - * @SuppressWarnings("unused") - * @param mixed $level - * @param string $message - * @param array $context - * @return bool - */ - public function log($level, $message, array $context = array()): bool - { - return false; - } -} diff --git a/src/TgLog.php b/src/TgLog.php index 21128bf..6841f66 100644 --- a/src/TgLog.php +++ b/src/TgLog.php @@ -6,8 +6,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; +use unreal4u\Dummy\Logger; use unreal4u\TelegramAPI\Abstracts\TelegramTypes; -use unreal4u\TelegramAPI\InternalFunctionality\DummyLogger; use unreal4u\TelegramAPI\InternalFunctionality\TelegramDocument; use unreal4u\TelegramAPI\Abstracts\TelegramMethods; use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; @@ -71,7 +71,7 @@ public function __construct(string $botToken, LoggerInterface $logger = null, Cl // Initialize new dummy logger (PSR-3 compatible) if not injected if ($logger === null) { - $logger = new DummyLogger(); + $logger = new Logger(); } $this->logger = $logger; @@ -93,7 +93,7 @@ public function __construct(string $botToken, LoggerInterface $logger = null, Cl */ public function performApiRequest(TelegramMethods $method): TelegramTypes { - $this->logger->debug('Request for API call, resetting internal values', [get_class($method)]); + $this->logger->debug('Request for API call, resetting internal values', [\get_class($method)]); $this->resetObjectValues(); $rawData = $this->sendRequestToTelegram($method, $this->constructFormData($method)); @@ -121,7 +121,7 @@ public function downloadFile(File $file): TelegramDocument * Builds up the Telegram API url * @return TgLog */ - final private function constructApiUrl(): TgLog + private function constructApiUrl(): TgLog { $this->apiUrl = 'https://api.telegram.org/bot' . $this->botToken . '/'; $this->logger->debug('Built up the API URL'); @@ -213,7 +213,7 @@ private function checkSpecialConditions(TelegramMethods $method): array $return = [false]; foreach ($method as $key => $value) { - if (is_object($value) && $value instanceof InputFile) { + if (\is_object($value) && $value instanceof InputFile) { $this->logger->debug('About to send a file, so changing request to use multi-part instead'); // If we are about to send a file, we must use the multipart/form-data way $this->formType = 'multipart/form-data'; @@ -240,7 +240,7 @@ private function checkSpecialConditions(TelegramMethods $method): array */ protected function composeApiMethodUrl(TelegramMethods $call): string { - $completeClassName = get_class($call); + $completeClassName = \get_class($call); $this->methodName = substr($completeClassName, strrpos($completeClassName, '\\') + 1); $this->logger->info('About to perform API request', ['method' => $this->methodName]); diff --git a/tests/InternalFunctionality/DummyLoggerTest.php b/tests/InternalFunctionality/DummyLoggerTest.php deleted file mode 100644 index 314fb41..0000000 --- a/tests/InternalFunctionality/DummyLoggerTest.php +++ /dev/null @@ -1,86 +0,0 @@ -dummyLogger = new DummyLogger(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->dummyLogger = null; - parent::tearDown(); - } - - public function testEmergency() - { - $result = $this->dummyLogger->emergency('Hello'); - $this->assertFalse($result); - } - - public function testAlert() - { - $result = $this->dummyLogger->alert('Hello'); - $this->assertFalse($result); - } - - public function testCritical() - { - $result = $this->dummyLogger->critical('Hello'); - $this->assertFalse($result); - } - - public function testError() - { - $result = $this->dummyLogger->error('Hello'); - $this->assertFalse($result); - } - - public function testWarning() - { - $result = $this->dummyLogger->warning('Hello'); - $this->assertFalse($result); - } - - public function testNotice() - { - $result = $this->dummyLogger->notice('Hello'); - $this->assertFalse($result); - } - - public function testInfo() - { - $result = $this->dummyLogger->info('Hello'); - $this->assertFalse($result); - } - - public function testDebug() - { - $result = $this->dummyLogger->debug('Hello'); - $this->assertFalse($result); - } - - public function testLog() - { - $result = $this->dummyLogger->log(100, 'Hello'); - $this->assertFalse($result); - } -}