From e9da26132fea04f458bf5da23f7c2b0984d0b050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Sun, 18 Feb 2018 13:09:38 +0100 Subject: [PATCH 1/5] Nette\SmartObject instead of Nette\Object --- src/Tracy/Panel.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tracy/Panel.php b/src/Tracy/Panel.php index 3152fbe..a76871b 100644 --- a/src/Tracy/Panel.php +++ b/src/Tracy/Panel.php @@ -20,8 +20,9 @@ class_alias('Nette\Diagnostics\IBarPanel', 'Tracy\IBarPanel'); * * @author Hána František */ -class Panel extends Nette\Object implements Tracy\IBarPanel +class Panel implements Tracy\IBarPanel { + use Nette\SmartObject; /** @var string */ private $htmlPrefix; From 141786e85b09fedf574b9e8ce744c31fd7399035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Mon, 26 Mar 2018 20:07:23 +0200 Subject: [PATCH 2/5] Add nette/utils ^2.4 as direct dependency --- composer.json | 3 ++- tests/composer-nette-2.1.json | 1 + tests/composer-nette-2.2.json | 1 + tests/composer-nette-2.3.json | 1 + tests/composer-nette-2.4.json | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ac7c6ee..7a4945d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "php": ">=5.3.0", "skautis/skautis": "~2.0@dev", "nette/di": "~2.1@dev", - "nette/http": "~2.1@dev" + "nette/http": "~2.1@dev", + "nette/utils": "^2.4" }, "require-dev": { "nette/tester": "~1.3", diff --git a/tests/composer-nette-2.1.json b/tests/composer-nette-2.1.json index 0895b7e..ea19852 100644 --- a/tests/composer-nette-2.1.json +++ b/tests/composer-nette-2.1.json @@ -18,6 +18,7 @@ "require": { "php": ">=5.3.0", "skautis/skautis": "~2.0@dev", + "nette/utils": "2.4.*", "nette/nette": "2.1.*" }, "require-dev": { diff --git a/tests/composer-nette-2.2.json b/tests/composer-nette-2.2.json index 82c32ee..f03f826 100644 --- a/tests/composer-nette-2.2.json +++ b/tests/composer-nette-2.2.json @@ -18,6 +18,7 @@ "require": { "php": ">=5.3.0", "skautis/skautis": "~2.0@dev", + "nette/utils": "2.4.*", "nette/di": "2.2.*", "nette/http": "2.2.*" }, diff --git a/tests/composer-nette-2.3.json b/tests/composer-nette-2.3.json index 1c9e181..ef57659 100644 --- a/tests/composer-nette-2.3.json +++ b/tests/composer-nette-2.3.json @@ -18,6 +18,7 @@ "require": { "php": ">=5.3.0", "skautis/skautis": "~2.0@dev", + "nette/utils": "2.4.*", "nette/di": "2.3.*", "nette/http": "2.3.*" }, diff --git a/tests/composer-nette-2.4.json b/tests/composer-nette-2.4.json index 32ffd4f..8841f4a 100644 --- a/tests/composer-nette-2.4.json +++ b/tests/composer-nette-2.4.json @@ -18,6 +18,7 @@ "require": { "php": ">=5.3.0", "skautis/skautis": "~2.0@dev", + "nette/utils": "2.4.*", "nette/di": "2.4.*", "nette/http": "2.4.*" }, From 7bdbc5eda5504d88ff236178412329701c45dec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Tue, 27 Mar 2018 09:35:00 +0200 Subject: [PATCH 3/5] Drop support for PHP below 5.6 --- .travis.yml | 9 +-------- composer.json | 2 +- tests/composer-nette-2.1.json | 2 +- tests/composer-nette-2.2.json | 2 +- tests/composer-nette-2.3.json | 2 +- tests/composer-nette-2.4.json | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index b004e07..ace2587 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,19 +11,12 @@ env: - NETTE=master php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - hhvm matrix: - exclude: - - php: 5.4 - env: NETTE=2.4 - - php: 5.5 - env: NETTE=2.4 allow_failures: - php: hhvm @@ -42,4 +35,4 @@ after_failure: cache: directories: - - $HOME/.composer/cache \ No newline at end of file + - $HOME/.composer/cache diff --git a/composer.json b/composer.json index 7a4945d..3d0a28a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "source": "https://github.com/skaut/SkautisNette" }, "require": { - "php": ">=5.3.0", + "php": ">=5.6", "skautis/skautis": "~2.0@dev", "nette/di": "~2.1@dev", "nette/http": "~2.1@dev", diff --git a/tests/composer-nette-2.1.json b/tests/composer-nette-2.1.json index ea19852..a82df7f 100644 --- a/tests/composer-nette-2.1.json +++ b/tests/composer-nette-2.1.json @@ -16,7 +16,7 @@ "source": "https://github.com/skaut/SkautisNette" }, "require": { - "php": ">=5.3.0", + "php": ">=5.6", "skautis/skautis": "~2.0@dev", "nette/utils": "2.4.*", "nette/nette": "2.1.*" diff --git a/tests/composer-nette-2.2.json b/tests/composer-nette-2.2.json index f03f826..39cc324 100644 --- a/tests/composer-nette-2.2.json +++ b/tests/composer-nette-2.2.json @@ -16,7 +16,7 @@ "source": "https://github.com/skaut/SkautisNette" }, "require": { - "php": ">=5.3.0", + "php": ">=5.6", "skautis/skautis": "~2.0@dev", "nette/utils": "2.4.*", "nette/di": "2.2.*", diff --git a/tests/composer-nette-2.3.json b/tests/composer-nette-2.3.json index ef57659..c0995e7 100644 --- a/tests/composer-nette-2.3.json +++ b/tests/composer-nette-2.3.json @@ -16,7 +16,7 @@ "source": "https://github.com/skaut/SkautisNette" }, "require": { - "php": ">=5.3.0", + "php": ">=5.6", "skautis/skautis": "~2.0@dev", "nette/utils": "2.4.*", "nette/di": "2.3.*", diff --git a/tests/composer-nette-2.4.json b/tests/composer-nette-2.4.json index 8841f4a..e1c52e4 100644 --- a/tests/composer-nette-2.4.json +++ b/tests/composer-nette-2.4.json @@ -16,7 +16,7 @@ "source": "https://github.com/skaut/SkautisNette" }, "require": { - "php": ">=5.3.0", + "php": ">=5.6", "skautis/skautis": "~2.0@dev", "nette/utils": "2.4.*", "nette/di": "2.4.*", From 83e814b3540ae8452b657c3d548b87e0bac45b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Tue, 27 Mar 2018 10:02:57 +0200 Subject: [PATCH 4/5] Use Nette 2.4 as minimal version --- .travis.yml | 3 - composer.json | 28 ++------- src/SkautisExtension.php | 62 ++++--------------- src/Tracy/Panel.php | 28 +-------- .../SkautisNette/SkautisExtension.debug.phpt | 6 +- .../SkautisExtension.production.phpt | 4 +- tests/composer-nette-2.1.json | 34 ---------- tests/composer-nette-2.2.json | 38 ------------ tests/composer-nette-2.3.json | 38 ------------ 9 files changed, 27 insertions(+), 214 deletions(-) delete mode 100644 tests/composer-nette-2.1.json delete mode 100644 tests/composer-nette-2.2.json delete mode 100644 tests/composer-nette-2.3.json diff --git a/.travis.yml b/.travis.yml index ace2587..3cd7176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,6 @@ language: php sudo: false env: - - NETTE=2.1 - - NETTE=2.2 - - NETTE=2.3 - NETTE=2.4 - NETTE=master diff --git a/composer.json b/composer.json index 3d0a28a..fdfa9e7 100644 --- a/composer.json +++ b/composer.json @@ -18,32 +18,14 @@ "require": { "php": ">=5.6", "skautis/skautis": "~2.0@dev", - "nette/di": "~2.1@dev", - "nette/http": "~2.1@dev", - "nette/utils": "^2.4" + "nette/di": "^2.4@dev", + "nette/http": "^2.4@dev", + "nette/utils": "^2.4@dev" }, "require-dev": { "nette/tester": "~1.3", - "nette/nette": "~2.1@dev", - "nette/application": "~2.1@dev", - "nette/bootstrap": "~2.1@dev", - "nette/caching": "~2.1@dev", - "nette/component-model": "~2.1@dev", - "nette/database": "~2.1@dev", - "nette/deprecated": "~2.1@dev", - "nette/finder": "~2.1@dev", - "nette/forms": "~2.1@dev", - "nette/mail": "~2.1@dev", - "nette/neon": "~2.1@dev", - "nette/php-generator": "~2.1@dev", - "nette/reflection": "~2.1@dev", - "nette/robot-loader": "~2.1@dev", - "nette/safe-stream": "~2.1@dev", - "nette/security": "~2.1@dev", - "nette/tokenizer": "~2.1@dev", - "nette/utils": "~2.1@dev", - "latte/latte": "~2.1@dev", - "tracy/tracy": "~2.1@dev" + "nette/nette": "^2.4@dev", + "nette/utils": "^2.4@dev" }, "suggest": { "tracy/tracy": "to enable skautis panel for Tracy debug bar.", diff --git a/src/SkautisExtension.php b/src/SkautisExtension.php index 3651a9a..042c2e5 100644 --- a/src/SkautisExtension.php +++ b/src/SkautisExtension.php @@ -4,6 +4,8 @@ use Nette; use Nette\DI\Config; +use Skautis; +use Tracy\Debugger; /** @@ -16,13 +18,13 @@ class SkautisExtension extends Nette\DI\CompilerExtension { /** @var array */ - public $defaults = array( + public $defaults = [ 'applicationId' => NULL, 'testMode' => FALSE, 'profiler' => NULL, 'cache' => TRUE, 'compression' => TRUE, - ); + ]; public function loadConfiguration() @@ -32,66 +34,28 @@ public function loadConfiguration() $config['profiler'] = isset($config['profiler']) ? $config['profiler'] : !empty($container->parameters['debugMode']); $container->addDefinition($this->prefix('config')) - ->setClass('Skautis\Config', array($config['applicationId'], $config['testMode'], $config['cache'], $config['compression'])); + ->setClass(Skautis\Config::class, array($config['applicationId'], $config['testMode'], $config['cache'], $config['compression'])); $container->addDefinition($this->prefix('webServiceFactory')) - ->setClass('Skautis\Wsdl\WebServiceFactory'); + ->setClass(Skautis\Wsdl\WebServiceFactory::class); $manager = $container->addDefinition($this->prefix('wsdlManager')) - ->setClass('Skautis\Wsdl\WsdlManager'); + ->setClass(Skautis\Wsdl\WsdlManager::class); $container->addDefinition($this->prefix('session')) - ->setClass('Skautis\Nette\SessionAdapter'); + ->setClass(SessionAdapter::class); $container->addDefinition($this->prefix('user')) - ->setClass('Skautis\User'); + ->setClass(Skautis\User::class); $container->addDefinition($this->prefix('skautis')) - ->setClass('Skautis\Skautis'); + ->setClass(Skautis\Skautis::class); - if ($config['profiler'] && (class_exists('Tracy\Debugger') || class_exists('Nette\Diagnostics\Debugger'))) { + if ($config['profiler'] && class_exists(Debugger::class)) { $panel = $container->addDefinition($this->prefix('panel')) - ->setClass('Skautis\Nette\Tracy\Panel'); - $manager->addSetup(array($panel, 'register'), array($manager)); + ->setClass(Skautis\Nette\Tracy\Panel::class); + $manager->addSetup([$panel, 'register'], array($manager)); } } - - /** - * BC with nette/di <2.3 - * @param string $name - * @param array $args - * @return mixed - */ - public function __call($name, $args) - { - if ($name === 'validateConfig') { - return call_user_func_array(array($this, '_validateConfig'), $args); - } - return parent::__call($name, $args); - } - - - /** - * Checks whether $config contains only $expected items and returns combined array. - * BC with nette/di <2.3 - * @param array $expected configuration keys - * @param array|NULL $config to validate - * @param string|NULL $name configuration section name - * @return array - * @throws Nette\InvalidStateException - */ - private function _validateConfig(array $expected, array $config = NULL, $name = NULL) - { - if (func_num_args() === 1) { - $config = $this->config; - } - if ($extra = array_diff_key((array) $config, $expected)) { - $name = $name ?: $this->name; - $extra = implode(", $name.", array_keys($extra)); - throw new Nette\InvalidStateException("Unknown configuration option $name.$extra."); - } - return Config\Helpers::merge($config, $expected); - } - } diff --git a/src/Tracy/Panel.php b/src/Tracy/Panel.php index a76871b..7d63034 100644 --- a/src/Tracy/Panel.php +++ b/src/Tracy/Panel.php @@ -8,13 +8,6 @@ use Skautis\Wsdl\WsdlManager; use Tracy; - -if (!interface_exists('Tracy\IBarPanel') && interface_exists('Nette\Diagnostics\IBarPanel')) { - // BC with Nette 2.1 - class_alias('Nette\Diagnostics\IBarPanel', 'Tracy\IBarPanel'); -} - - /** * Skautis panel for Tracy. * @@ -25,27 +18,12 @@ class Panel implements Tracy\IBarPanel use Nette\SmartObject; /** @var string */ - private $htmlPrefix; - - /** @var string */ - private $debuggerClass; + private $htmlPrefix = 'tracy'; /** @var array */ private $queries = array(); - public function __construct() - { - if (!class_exists('Tracy\Debugger') && class_exists('Nette\Diagnostics\Debugger')) { - $this->htmlPrefix = 'nette'; - $this->debuggerClass = 'Nette\Diagnostics\Debugger'; - } else { - $this->htmlPrefix = 'tracy'; - $this->debuggerClass = 'Tracy\Debugger'; - } - } - - /** * Registers event listener on WebService objects via WsdlManager * @@ -55,7 +33,7 @@ public function register(WsdlManager $wsdlManager) { $wsdlManager->addWebServiceListener(WebService::EVENT_SUCCESS, array($this, 'logEvent')); $wsdlManager->addWebServiceListener(WebService::EVENT_FAILURE, array($this, 'logEvent')); - call_user_func(array($this->debuggerClass, 'getBar'))->addPanel($this); + call_user_func([Tracy\Debugger::class, 'getBar'])->addPanel($this); } @@ -137,7 +115,7 @@ protected function prepareTrace(array $trace) */ protected function dump($object) { - return call_user_func(array($this->debuggerClass, 'dump'), $object, TRUE); + return call_user_func([Tracy\Debugger::class, 'dump'], $object, TRUE); } diff --git a/tests/SkautisNette/SkautisExtension.debug.phpt b/tests/SkautisNette/SkautisExtension.debug.phpt index 0c0ddc3..9af72ed 100644 --- a/tests/SkautisNette/SkautisExtension.debug.phpt +++ b/tests/SkautisNette/SkautisExtension.debug.phpt @@ -1,6 +1,8 @@ addConfig(__DIR__ . '/files/config.neon'); $container = $configurator->createContainer(); Assert::false($container->isCreated('skautis.panel')); -Assert::type('Skautis\Skautis', $container->getService('skautis.skautis')); +Assert::type(Skautis::class, $container->getService('skautis.skautis')); Assert::true($container->isCreated('skautis.panel')); -Assert::type('Skautis\Nette\Tracy\Panel', $container->getService('skautis.panel')); +Assert::type(Panel::class, $container->getService('skautis.panel')); diff --git a/tests/SkautisNette/SkautisExtension.production.phpt b/tests/SkautisNette/SkautisExtension.production.phpt index 6fc0727..4a609fd 100644 --- a/tests/SkautisNette/SkautisExtension.production.phpt +++ b/tests/SkautisNette/SkautisExtension.production.phpt @@ -1,7 +1,7 @@ setDebugMode(FALSE); $configurator->addConfig(__DIR__ . '/files/config.neon'); $container = $configurator->createContainer(); -Assert::type('Skautis\Skautis', $container->getService('skautis.skautis')); +Assert::type(Skautis::class, $container->getService('skautis.skautis')); Assert::false($container->hasService('skautis.panel')); diff --git a/tests/composer-nette-2.1.json b/tests/composer-nette-2.1.json deleted file mode 100644 index a82df7f..0000000 --- a/tests/composer-nette-2.1.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "skautis/nette", - "type": "library", - "description": "Nette extension for Skautis library", - "keywords": ["skautis", "api", "nette"], - "homepage": "https://github.com/skaut/SkautisNette", - "license": ["BSD-3-Clause"], - "authors": [ - { - "name": "František Hána", - "homepage": "http://sinacek.cz" - } - ], - "support": { - "wiki": "http://is.skaut.cz/napoveda/", - "source": "https://github.com/skaut/SkautisNette" - }, - "require": { - "php": ">=5.6", - "skautis/skautis": "~2.0@dev", - "nette/utils": "2.4.*", - "nette/nette": "2.1.*" - }, - "require-dev": { - "nette/tester": "~1.3" - }, - "autoload": { - "psr-4": { - "Skautis\\Nette\\": "src/" - } - }, - "minimum-stability": "stable", - "prefer-stable": true -} diff --git a/tests/composer-nette-2.2.json b/tests/composer-nette-2.2.json deleted file mode 100644 index 39cc324..0000000 --- a/tests/composer-nette-2.2.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "skautis/nette", - "type": "library", - "description": "Nette extension for Skautis library", - "keywords": ["skautis", "api", "nette"], - "homepage": "https://github.com/skaut/SkautisNette", - "license": ["BSD-3-Clause"], - "authors": [ - { - "name": "František Hána", - "homepage": "http://sinacek.cz" - } - ], - "support": { - "wiki": "http://is.skaut.cz/napoveda/", - "source": "https://github.com/skaut/SkautisNette" - }, - "require": { - "php": ">=5.6", - "skautis/skautis": "~2.0@dev", - "nette/utils": "2.4.*", - "nette/di": "2.2.*", - "nette/http": "2.2.*" - }, - "require-dev": { - "nette/tester": "~1.3", - "nette/nette": "2.2.*", - "nette/bootstrap": "2.2.*", - "tracy/tracy": "2.2.*" - }, - "autoload": { - "psr-4": { - "Skautis\\Nette\\": "src/" - } - }, - "minimum-stability": "stable", - "prefer-stable": true -} diff --git a/tests/composer-nette-2.3.json b/tests/composer-nette-2.3.json deleted file mode 100644 index c0995e7..0000000 --- a/tests/composer-nette-2.3.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "skautis/nette", - "type": "library", - "description": "Nette extension for Skautis library", - "keywords": ["skautis", "api", "nette"], - "homepage": "https://github.com/skaut/SkautisNette", - "license": ["BSD-3-Clause"], - "authors": [ - { - "name": "František Hána", - "homepage": "http://sinacek.cz" - } - ], - "support": { - "wiki": "http://is.skaut.cz/napoveda/", - "source": "https://github.com/skaut/SkautisNette" - }, - "require": { - "php": ">=5.6", - "skautis/skautis": "~2.0@dev", - "nette/utils": "2.4.*", - "nette/di": "2.3.*", - "nette/http": "2.3.*" - }, - "require-dev": { - "nette/tester": "~1.3", - "nette/nette": "2.3.*", - "nette/bootstrap": "2.3.*", - "tracy/tracy": "2.3.*" - }, - "autoload": { - "psr-4": { - "Skautis\\Nette\\": "src/" - } - }, - "minimum-stability": "stable", - "prefer-stable": true -} From f052f9719c51040c64f0bd355db33aa81b9753dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Wed, 4 Apr 2018 10:48:17 +0200 Subject: [PATCH 5/5] Use direct method call instead of call_user_func --- src/Tracy/Panel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tracy/Panel.php b/src/Tracy/Panel.php index 7d63034..27bf7ee 100644 --- a/src/Tracy/Panel.php +++ b/src/Tracy/Panel.php @@ -33,7 +33,7 @@ public function register(WsdlManager $wsdlManager) { $wsdlManager->addWebServiceListener(WebService::EVENT_SUCCESS, array($this, 'logEvent')); $wsdlManager->addWebServiceListener(WebService::EVENT_FAILURE, array($this, 'logEvent')); - call_user_func([Tracy\Debugger::class, 'getBar'])->addPanel($this); + Tracy\Debugger::getBar()->addPanel($this); } @@ -115,7 +115,7 @@ protected function prepareTrace(array $trace) */ protected function dump($object) { - return call_user_func([Tracy\Debugger::class, 'dump'], $object, TRUE); + return Tracy\Debugger::dump($object, TRUE); }