diff --git a/.travis.yml b/.travis.yml index b004e07..3cd7176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,16 @@ language: php sudo: false env: - - NETTE=2.1 - - NETTE=2.2 - - NETTE=2.3 - NETTE=2.4 - 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 +32,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 ac7c6ee..fdfa9e7 100644 --- a/composer.json +++ b/composer.json @@ -16,33 +16,16 @@ "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" + "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 3152fbe..27bf7ee 100644 --- a/src/Tracy/Panel.php +++ b/src/Tracy/Panel.php @@ -8,43 +8,22 @@ 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. * * @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; - - /** @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 * @@ -54,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); + Tracy\Debugger::getBar()->addPanel($this); } @@ -136,7 +115,7 @@ protected function prepareTrace(array $trace) */ protected function dump($object) { - return call_user_func(array($this->debuggerClass, 'dump'), $object, TRUE); + return Tracy\Debugger::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 0895b7e..0000000 --- a/tests/composer-nette-2.1.json +++ /dev/null @@ -1,33 +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.3.0", - "skautis/skautis": "~2.0@dev", - "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 82c32ee..0000000 --- a/tests/composer-nette-2.2.json +++ /dev/null @@ -1,37 +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.3.0", - "skautis/skautis": "~2.0@dev", - "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 1c9e181..0000000 --- a/tests/composer-nette-2.3.json +++ /dev/null @@ -1,37 +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.3.0", - "skautis/skautis": "~2.0@dev", - "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 -} diff --git a/tests/composer-nette-2.4.json b/tests/composer-nette-2.4.json index 32ffd4f..e1c52e4 100644 --- a/tests/composer-nette-2.4.json +++ b/tests/composer-nette-2.4.json @@ -16,8 +16,9 @@ "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.*", "nette/http": "2.4.*" },