diff --git a/composer.json b/composer.json index 4286e23..fdfa9e7 100644 --- a/composer.json +++ b/composer.json @@ -25,25 +25,7 @@ "require-dev": { "nette/tester": "~1.3", "nette/nette": "^2.4@dev", - "nette/application": "^2.4@dev", - "nette/bootstrap": "^2.4@dev", - "nette/caching": "^2.4@dev", - "nette/component-model": "^2.4@dev", - "nette/database": "^2.4@dev", - "nette/deprecated": "^2.4@dev", - "nette/finder": "^2.4@dev", - "nette/forms": "^2.4@dev", - "nette/mail": "^2.4@dev", - "nette/neon": "^2.4@dev", - "nette/php-generator": "^2.4@dev", - "nette/reflection": "^2.4@dev", - "nette/robot-loader": "^2.4@dev", - "nette/safe-stream": "^2.4@dev", - "nette/security": "^2.4@dev", - "nette/tokenizer": "^2.4@dev", - "nette/utils": "^2.4@dev", - "latte/latte": "^2.4@dev", - "tracy/tracy": "^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..756b6c3 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,46 +34,31 @@ 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 @@ -81,7 +68,7 @@ public function __call($name, $args) * @return array * @throws Nette\InvalidStateException */ - private function _validateConfig(array $expected, array $config = NULL, $name = NULL) + private function validateConfig(array $expected, array $config = NULL, $name = NULL) { if (func_num_args() === 1) { $config = $this->config; 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'));