From 23ee48f3b263a4f6313b799e5f80049bef31338d Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 21 Feb 2019 18:06:36 +0530 Subject: [PATCH] Fix CS errors. --- composer.json | 2 +- phpcs.xml.dist | 12 ++--- src/Cache/Engine/DebugEngine.php | 6 +-- src/Command/BenchmarkCommand.php | 16 +++---- src/Controller/ComposerController.php | 6 +-- src/Controller/MailPreviewController.php | 17 ++++--- src/Controller/PanelsController.php | 3 +- src/Controller/RequestsController.php | 2 +- src/Controller/ToolbarController.php | 1 + src/Database/Log/DebugLog.php | 10 ++--- src/DebugInclude.php | 11 +++-- src/DebugMemory.php | 2 +- src/DebugPanel.php | 6 +-- src/DebugSql.php | 7 +-- src/DebugTimer.php | 10 ++--- src/Log/Engine/DebugKitLog.php | 2 +- src/Mailer/AbstractResult.php | 2 +- src/Mailer/MailPreview.php | 5 ++- src/Mailer/PreviewResult.php | 30 ++++++++----- src/Mailer/SentMailResult.php | 5 +-- src/Mailer/Transport/DebugKitTransport.php | 9 ++-- src/Middleware/DebugKitMiddleware.php | 5 ++- src/Model/Behavior/TimedBehavior.php | 2 +- src/Model/Entity/Panel.php | 3 +- src/Model/Entity/Request.php | 2 +- src/Model/Table/LazyTableTrait.php | 4 +- src/Model/Table/PanelsTable.php | 3 +- src/Model/Table/RequestsTable.php | 9 ++-- src/Panel/CachePanel.php | 6 +-- src/Panel/DeprecationsPanel.php | 3 +- src/Panel/EnvironmentPanel.php | 5 +-- src/Panel/HistoryPanel.php | 2 +- src/Panel/IncludePanel.php | 9 ++-- src/Panel/LogPanel.php | 4 +- src/Panel/MailPanel.php | 8 ++-- src/Panel/PackagesPanel.php | 1 + src/Panel/PanelRegistry.php | 1 + src/Panel/RequestPanel.php | 3 +- src/Panel/RoutesPanel.php | 3 +- src/Panel/SessionPanel.php | 3 +- src/Panel/SqlLogPanel.php | 2 +- src/Panel/TimerPanel.php | 6 +-- src/Panel/VariablesPanel.php | 32 ++++++++++--- src/Plugin.php | 1 + src/ToolbarService.php | 18 +++++--- src/View/AjaxView.php | 1 + src/View/Helper/CredentialsHelper.php | 7 +-- src/View/Helper/SimpleGraphHelper.php | 2 +- src/View/Helper/TidyHelper.php | 11 ++--- src/View/Helper/ToolbarHelper.php | 12 +++-- tests/Fixture/PanelsFixture.php | 10 ++--- tests/Fixture/RequestsFixture.php | 6 +-- .../TestCase/Cache/Engine/DebugEngineTest.php | 13 +++--- .../Controller/MailPreviewControllerTest.php | 16 +++---- .../Controller/PanelsControllerTest.php | 8 ++-- .../Controller/RequestsControllerTest.php | 4 +- .../Controller/ToolbarControllerTest.php | 4 +- tests/TestCase/Database/Log/DebugLogTest.php | 1 + tests/TestCase/DebugIncludeTest.php | 1 + tests/TestCase/DebugMemoryTest.php | 2 +- tests/TestCase/DebugPanelTest.php | 13 +----- tests/TestCase/DebugSqlTest.php | 1 + tests/TestCase/DebugTimerTest.php | 4 +- .../Transport/DebugKitTransportTest.php | 1 + .../Middleware/DebugKitMiddlewareTest.php | 17 ++++--- .../Model/Behavior/TimedBehaviorTest.php | 3 +- .../TestCase/Model/Table/RequestTableTest.php | 1 + tests/TestCase/Panel/CachePanelTest.php | 2 +- .../TestCase/Panel/DeprecationsPanelTest.php | 5 ++- tests/TestCase/Panel/EnvironmentPanelTest.php | 2 +- tests/TestCase/Panel/IncludePanelTest.php | 1 + tests/TestCase/Panel/LogPanelTest.php | 2 +- tests/TestCase/Panel/PackagesPanelTest.php | 1 + tests/TestCase/Panel/RoutesPanelTest.php | 3 +- tests/TestCase/Panel/SqlLogPanelTest.php | 4 +- tests/TestCase/Panel/VariablesPanelTest.php | 3 +- tests/TestCase/ToolbarServiceTest.php | 38 ++++++++-------- .../View/Helper/CredentialsHelperTest.php | 1 + .../View/Helper/SimpleGraphHelperTest.php | 9 ++-- .../View/Helper/ToolbarHelperTest.php | 45 ++++++++++--------- tests/bootstrap.php | 20 ++++----- tests/test_app/Application.php | 3 +- .../Controller/DebugKitTestController.php | 2 +- tests/test_app/Form/TestForm.php | 1 + tests/test_app/Panel/SimplePanel.php | 24 ++++++++++ tests/test_app/Panel/TestPanel.php | 2 +- .../Panel/PluginTestPanel.php | 1 + .../src/Mailer/Preview/TestMailerPreview.php | 2 +- .../src/Mailer/TestMailer.php | 2 +- .../Plugin/DebugkitTestPlugin/src/Plugin.php | 1 + 90 files changed, 333 insertions(+), 278 deletions(-) create mode 100644 tests/test_app/Panel/SimplePanel.php diff --git a/composer.json b/composer.json index 3318b3499..cadb787c6 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "jdorn/sql-formatter": "^1.2" }, "require-dev": { - "cakephp/cakephp-codesniffer": "^3.0", + "cakephp/cakephp-codesniffer": "dev-next", "phpunit/phpunit": "^7.0" }, "autoload": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 345da3602..32e0a739d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,12 +1,6 @@ - - - - - + + - - - 0 - + diff --git a/src/Cache/Engine/DebugEngine.php b/src/Cache/Engine/DebugEngine.php index 03fe9cd3c..94f51f51c 100644 --- a/src/Cache/Engine/DebugEngine.php +++ b/src/Cache/Engine/DebugEngine.php @@ -1,4 +1,5 @@ _engine = $registry->load('spies', $this->_config); unset($registry); @@ -290,7 +290,7 @@ public function clearGroup(string $group): bool public function __toString() { if (!empty($this->_engine)) { - list($ns, $class) = namespaceSplit(get_class($this->_engine)); + [$ns, $class] = namespaceSplit(get_class($this->_engine)); return str_replace('Engine', '', $class); } diff --git a/src/Command/BenchmarkCommand.php b/src/Command/BenchmarkCommand.php index 3008e2ab3..3de13345d 100644 --- a/src/Command/BenchmarkCommand.php +++ b/src/Command/BenchmarkCommand.php @@ -1,4 +1,5 @@ io->out(""); $this->io->out(Text::insert(__d('debug_kit', 'Requests/Second: :rps req/sec'), [ - 'rps' => round($requests / $duration, 3) + 'rps' => round($requests / $duration, 3), ])); $this->io->out(Text::insert(__d('debug_kit', 'Average request time: :average-time seconds'), [ - 'average-time' => round($duration / $requests, 3) + 'average-time' => round($duration / $requests, 3), ])); $this->io->out(Text::insert(__d('debug_kit', 'Standard deviation of average request time: :std-dev'), [ - 'std-dev' => round($this->_deviation($times, true), 3) + 'std-dev' => round($this->_deviation($times, true), 3), ])); $this->io->out(Text::insert(__d('debug_kit', 'Longest/shortest request: :longest sec/:shortest sec'), [ 'longest' => round(max($times), 3), - 'shortest' => round(min($times), 3) + 'shortest' => round(min($times), 3), ])); $this->io->out(""); @@ -164,11 +164,11 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption )) ->addArgument('url', [ 'help' => __d('debug_kit', 'The URL to request.'), - 'required' => true + 'required' => true, ]) ->addOption('n', [ 'default' => 10, - 'help' => __d('debug_kit', 'Number of iterations to perform.') + 'help' => __d('debug_kit', 'Number of iterations to perform.'), ]) ->addOption('t', [ 'default' => 100, @@ -176,7 +176,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption 'debug_kit', 'Maximum total time for all iterations, in seconds.' . 'If a single iteration takes more than the timeout, only one request will be made' - ) + ), ]) ->setEpilog(__d( 'debug_kit', diff --git a/src/Controller/ComposerController.php b/src/Controller/ComposerController.php index d81cc2bea..63dd791ec 100644 --- a/src/Controller/ComposerController.php +++ b/src/Controller/ComposerController.php @@ -1,4 +1,5 @@ append($pluginPaths) ->unfold(function ($pairs) { - list($paths, $plugin) = $pairs; + [$paths, $plugin] = $pairs; foreach ($paths as $path) { yield $plugin => $path; } @@ -202,7 +200,7 @@ protected function getMailPreviewClasses() $base = str_replace(".php", "", basename($file)); $class = App::className($plugin . $base, 'Mailer/Preview'); if ($class) { - yield ['plugin' => trim($plugin, '.'), 'class' => new $class]; + yield ['plugin' => trim($plugin, '.'), 'class' => new $class()]; } } }); @@ -269,11 +267,16 @@ protected function findPreview($previewName, $emailName, $plugin = null) if (!$realClass) { throw new NotFoundException("Mailer preview ${previewName} not found"); } - $mailPreview = new $realClass; + $mailPreview = new $realClass(); $email = $mailPreview->find($emailName); if (!$email) { - throw new NotFoundException(__d('debug_kit', "Mailer preview {0}::{1} not found", $previewName, $emailName)); + throw new NotFoundException(__d( + 'debug_kit', + "Mailer preview {0}::{1} not found", + $previewName, + $emailName + )); } return new PreviewResult($mailPreview->$email(), $email); diff --git a/src/Controller/PanelsController.php b/src/Controller/PanelsController.php index 968e852ea..fb1e4e824 100644 --- a/src/Controller/PanelsController.php +++ b/src/Controller/PanelsController.php @@ -1,4 +1,5 @@ set([ '_serialize' => ['panels'], - 'panels' => $panels + 'panels' => $panels, ]); } diff --git a/src/Controller/RequestsController.php b/src/Controller/RequestsController.php index 269d4b394..60ee4439e 100644 --- a/src/Controller/RequestsController.php +++ b/src/Controller/RequestsController.php @@ -1,4 +1,5 @@ _queries[] = [ 'query' => $query->query, 'took' => $query->took, - 'rows' => $query->numRows + 'rows' => $query->numRows, ]; } @@ -180,8 +180,7 @@ protected function isSchemaQuery(LoggedQuery $query) { $querystring = $query->query; - return ( - // Multiple engines + return // Multiple engines strpos($querystring, 'FROM information_schema') !== false || // Postgres strpos($querystring, 'FROM pg_catalog') !== false || @@ -194,7 +193,6 @@ protected function isSchemaQuery(LoggedQuery $query) strpos($querystring, 'PRAGMA') === 0 || // Sqlserver strpos($querystring, 'FROM INFORMATION_SCHEMA') !== false || - strpos($querystring, 'FROM sys.') !== false - ); + strpos($querystring, 'FROM sys.') !== false; } } diff --git a/src/DebugInclude.php b/src/DebugInclude.php index af3f1c293..d0371faa9 100644 --- a/src/DebugInclude.php +++ b/src/DebugInclude.php @@ -1,4 +1,5 @@ _composerPaths[$package['name']] = $vendorDir . str_replace('/', DIRECTORY_SEPARATOR, $package['name']) . DIRECTORY_SEPARATOR; + $this->_composerPaths[$package['name']] = $vendorDir + . str_replace('/', DIRECTORY_SEPARATOR, $package['name']) + . DIRECTORY_SEPARATOR; } } } diff --git a/src/DebugMemory.php b/src/DebugMemory.php index 36d4e5edf..a39790fb6 100644 --- a/src/DebugMemory.php +++ b/src/DebugMemory.php @@ -1,4 +1,5 @@ plugin) { return $this->plugin . '.' . Inflector::underscore($name); } diff --git a/src/DebugSql.php b/src/DebugSql.php index 3bd0b2686..2f275986e 100644 --- a/src/DebugSql.php +++ b/src/DebugSql.php @@ -1,4 +1,5 @@ $start, 'message' => $message, - 'named' => $named + 'named' => $named, ]; return true; @@ -136,7 +136,7 @@ public static function getAll($clear = false) 'start' => 0, 'end' => $_end - $start, 'time' => round($_end - $start, 6), - 'named' => null + 'named' => null, ]; foreach (self::$_timers as $name => $timer) { if (!isset($timer['end'])) { @@ -145,7 +145,7 @@ public static function getAll($clear = false) $times[$name] = array_merge($timer, [ 'start' => $timer['start'] - $start, 'end' => $timer['end'] - $start, - 'time' => self::elapsedTime($name) + 'time' => self::elapsedTime($name), ]); } if ($clear) { @@ -193,7 +193,7 @@ public static function requestTime() $start = self::requestStartTime(); $now = microtime(true); - return ($now - $start); + return $now - $start; } /** diff --git a/src/Log/Engine/DebugKitLog.php b/src/Log/Engine/DebugKitLog.php index fc96681b1..8fd4c134e 100644 --- a/src/Log/Engine/DebugKitLog.php +++ b/src/Log/Engine/DebugKitLog.php @@ -1,4 +1,5 @@ hasMethod($email)) { return false; } diff --git a/src/Mailer/PreviewResult.php b/src/Mailer/PreviewResult.php index 5866c3504..f85c1a08c 100644 --- a/src/Mailer/PreviewResult.php +++ b/src/Mailer/PreviewResult.php @@ -1,4 +1,5 @@ viewBuilder()->getTemplate()) { + $mailer->viewBuilder()->setTemplate($method); + } + $reflection = new ReflectionClass($mailer); $prop = $reflection->getProperty('_email'); $prop->setAccessible(true); $email = $prop->getValue($mailer); - if (!$email->viewBuilder()->getTemplate()) { - $email->viewBuilder()->setTemplate($method); - } + $reflection = new ReflectionClass($email); + $prop = $reflection->getProperty('renderer'); + $prop->setAccessible(true); + $renderer = $prop->getValue($email); + + $reflection = new ReflectionClass($renderer); + $prop = $reflection->getProperty('email'); + $prop->setAccessible(true); + $prop->setValue($renderer, $email); - $render = (new ReflectionClass($email)) - ->getMethod('_renderTemplates') - ->getClosure($email); + $method = $reflection->getMethod('renderTemplates'); + $closure = $method->getClosure($renderer); - $this->parts = $render(''); + $this->parts = $closure(''); $extra = ['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']; $this->headers = array_filter($email->getHeaders($extra)); diff --git a/src/Mailer/SentMailResult.php b/src/Mailer/SentMailResult.php index 60f3fc5f1..5f8e9a6d3 100644 --- a/src/Mailer/SentMailResult.php +++ b/src/Mailer/SentMailResult.php @@ -1,4 +1,5 @@ emailLog = $config['debugKitLog']; @@ -68,7 +69,7 @@ public function send(Email $email): array $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc']); $parts = [ 'text' => $email->message(Email::MESSAGE_TEXT), - 'html' => $email->message(Email::MESSAGE_HTML) + 'html' => $email->message(Email::MESSAGE_HTML), ]; $headers['Subject'] = $email->getOriginalSubject(); diff --git a/src/Middleware/DebugKitMiddleware.php b/src/Middleware/DebugKitMiddleware.php index 99f7f55c5..72c9c7749 100644 --- a/src/Middleware/DebugKitMiddleware.php +++ b/src/Middleware/DebugKitMiddleware.php @@ -1,4 +1,5 @@ service = $service; diff --git a/src/Model/Behavior/TimedBehavior.php b/src/Model/Behavior/TimedBehavior.php index ec4bfac09..cabefc6d4 100644 --- a/src/Model/Behavior/TimedBehavior.php +++ b/src/Model/Behavior/TimedBehavior.php @@ -1,4 +1,5 @@ addBehavior('Timestamp', [ 'events' => [ - 'Model.beforeSave' => ['requested_at' => 'new'] - ] + 'Model.beforeSave' => ['requested_at' => 'new'], + ], ]); $this->ensureTables(['DebugKit.Requests', 'DebugKit.Panels']); } @@ -67,7 +66,7 @@ public static function defaultConnectionName(): string * * @param \Cake\ORM\Query $query The query * @param array $options The options - * @return Query The query. + * @return \Cake\ORM\Query The query. */ public function findRecent(Query $query, array $options) { diff --git a/src/Panel/CachePanel.php b/src/Panel/CachePanel.php index cf951fdfc..54ba564ab 100644 --- a/src/Panel/CachePanel.php +++ b/src/Panel/CachePanel.php @@ -1,4 +1,5 @@ $metrics + 'metrics' => $metrics, ]; } } diff --git a/src/Panel/DeprecationsPanel.php b/src/Panel/DeprecationsPanel.php index 8edf3ee73..4bcca4fbe 100644 --- a/src/Panel/DeprecationsPanel.php +++ b/src/Panel/DeprecationsPanel.php @@ -1,4 +1,5 @@ ROOT, 'TESTS' => TESTS, 'TMP' => TMP, - 'WWW_ROOT' => WWW_ROOT + 'WWW_ROOT' => WWW_ROOT, ]; $hiddenCakeConstants = array_fill_keys( diff --git a/src/Panel/HistoryPanel.php b/src/Panel/HistoryPanel.php index f2ece233f..5f9a98f34 100644 --- a/src/Panel/HistoryPanel.php +++ b/src/Panel/HistoryPanel.php @@ -1,4 +1,5 @@ _debug->getPluginName($file); if ($pluginName) { - $return['plugins'][$pluginName][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'plugin', $pluginName); + $return['plugins'][$pluginName][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName( + $file, + 'plugin', + $pluginName + ); } elseif ($this->_debug->isAppFile($file)) { $return['app'][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'app'); } elseif ($this->_debug->isCakeFile($file)) { diff --git a/src/Panel/LogPanel.php b/src/Panel/LogPanel.php index a02631909..dfe4cb99f 100644 --- a/src/Panel/LogPanel.php +++ b/src/Panel/LogPanel.php @@ -1,4 +1,5 @@ Log::engine('debug_kit_log_panel') + 'logger' => Log::engine('debug_kit_log_panel'), ]; } diff --git a/src/Panel/MailPanel.php b/src/Panel/MailPanel.php index 60c286410..1a462305d 100644 --- a/src/Panel/MailPanel.php +++ b/src/Panel/MailPanel.php @@ -1,4 +1,5 @@ setAccessible(true); $configs = $property->getValue(); - $log = $this->emailLog = new ArrayObject; + $log = $this->emailLog = new ArrayObject(); foreach ($configs as $name => &$transport) { if (is_object($transport)) { @@ -73,7 +73,7 @@ public function initialize() public function data() { return [ - 'emails' => isset($this->emailLog) ? $this->emailLog->getArrayCopy() : [] + 'emails' => isset($this->emailLog) ? $this->emailLog->getArrayCopy() : [], ]; } diff --git a/src/Panel/PackagesPanel.php b/src/Panel/PackagesPanel.php index 5c2c888d9..7022a7331 100644 --- a/src/Panel/PackagesPanel.php +++ b/src/Panel/PackagesPanel.php @@ -1,4 +1,5 @@ 0, 'callable' => $before('Event: ' . $name)], - ['priority' => 999, 'callable' => $after('Event: ' . $name)] + ['priority' => 999, 'callable' => $after('Event: ' . $name)], ]; }; @@ -53,7 +53,7 @@ public function implementedEvents(): array DebugMemory::record(__d('debug_kit', 'Controller initialization')); }], ['priority' => 0, 'callable' => $before('Event: Controller.initialize')], - ['priority' => 999, 'callable' => $after('Event: Controller.initialize')] + ['priority' => 999, 'callable' => $after('Event: Controller.initialize')], ], 'Controller.startup' => [ ['priority' => 0, 'callable' => $before('Event: Controller.startup')], diff --git a/src/Panel/VariablesPanel.php b/src/Panel/VariablesPanel.php index a39b6356f..fae0418d2 100644 --- a/src/Panel/VariablesPanel.php +++ b/src/Panel/VariablesPanel.php @@ -1,4 +1,5 @@ __debugInfo(); } catch (\Exception $exception) { - return __d('debug_kit', 'Could not retrieve debug info - {0}. Error: {1} in {2}, line {3}', get_class($item), $exception->getMessage(), $exception->getFile(), $exception->getLine()); + return __d( + 'debug_kit', + 'Could not retrieve debug info - {0}. Error: {1} in {2}, line {3}', + get_class($item), + $exception->getMessage(), + $exception->getFile(), + $exception->getLine() + ); } return array_map($walker, $info); @@ -152,7 +159,7 @@ public function shutdown(Event $event) $this->_data = [ 'content' => $vars, - 'errors' => $errors + 'errors' => $errors, ]; } @@ -170,10 +177,23 @@ protected function trySerialize($item) return $item; } catch (\Exception $e) { if (is_object($item)) { - return __d('debug_kit', 'Unserializable object - {0}. Error: {1} in {2}, line {3}', get_class($item), $e->getMessage(), $e->getFile(), $e->getLine()); + return __d( + 'debug_kit', + 'Unserializable object - {0}. Error: {1} in {2}, line {3}', + get_class($item), + $e->getMessage(), + $e->getFile(), + $e->getLine() + ); } - return __d('debug_kit', 'Unserializable Error: {1} in {2}, line {3}', $e->getMessage(), $e->getFile(), $e->getLine()); + return __d( + 'debug_kit', + 'Unserializable Error: {1} in {2}, line {3}', + $e->getMessage(), + $e->getFile(), + $e->getLine() + ); } } diff --git a/src/Plugin.php b/src/Plugin.php index 3694eb656..c872df9f5 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -1,4 +1,5 @@ true, ], 'forceEnable' => false, - 'safeTld' => [] + 'safeTld' => [], ]; /** @@ -117,7 +116,12 @@ public function isEnabled() */ protected function isSuspiciouslyProduction() { - $host = explode('.', parse_url('http://' . env('HTTP_HOST'), PHP_URL_HOST)); + $url = parse_url('http://' . env('HTTP_HOST'), PHP_URL_HOST); + if ($url === false) { + return false; + } + + $host = explode('.', $url); $first = current($host); $isIP = is_numeric(implode('', $host)); @@ -178,7 +182,7 @@ public function panel($name) public function loadPanels() { foreach ($this->getConfig('panels') as $panel => $enabled) { - list($panel, $enabled) = (is_numeric($panel)) ? [$enabled, true] : [$panel, $enabled]; + [$panel, $enabled] = is_numeric($panel) ? [$enabled, true] : [$panel, $enabled]; if ($enabled) { $this->registry->load($panel); } @@ -220,7 +224,7 @@ public function saveData(ServerRequest $request, ResponseInterface $response) 'method' => $request->getMethod(), 'status_code' => $response->getStatusCode(), 'requested_at' => $request->getEnv('REQUEST_TIME'), - 'panels' => [] + 'panels' => [], ]; /* @var \DebugKit\Model\Table\RequestsTable $requests */ $requests = TableRegistry::get('DebugKit.Requests'); @@ -260,7 +264,7 @@ public function getToolbarUrl() $url = 'js/toolbar.js'; $filePaths = [ str_replace('/', DIRECTORY_SEPARATOR, WWW_ROOT . 'debug_kit/' . $url), - str_replace('/', DIRECTORY_SEPARATOR, CorePlugin::path('DebugKit') . 'webroot/' . $url) + str_replace('/', DIRECTORY_SEPARATOR, CorePlugin::path('DebugKit') . 'webroot/' . $url), ]; $url = '/debug_kit/' . $url; foreach ($filePaths as $filePath) { diff --git a/src/View/AjaxView.php b/src/View/AjaxView.php index 4b87e660f..068008e31 100644 --- a/src/View/AjaxView.php +++ b/src/View/AjaxView.php @@ -1,4 +1,5 @@ Html->tag('a', '******', [ 'class' => 'filtered-credentials', 'title' => h($credentials), - 'onclick' => "this.innerHTML = this.title" + 'onclick' => "this.innerHTML = this.title", ]); return h($protocol) . $link . '@' . h($tail); diff --git a/src/View/Helper/SimpleGraphHelper.php b/src/View/Helper/SimpleGraphHelper.php index 11d1ba182..42dc702ad 100644 --- a/src/View/Helper/SimpleGraphHelper.php +++ b/src/View/Helper/SimpleGraphHelper.php @@ -1,4 +1,5 @@ '; if (isset($markup[$line - 1])) { $string .= h($markup[$line - 1]); } + // phpcs:ignore $string .= '' . h(@$markup[$line]) . ''; if (isset($markup[$line + 1])) { $string .= h($markup[$line + 1]); @@ -125,7 +126,7 @@ public function report($html = null) * normalized string so that the error messages can be linked to the line that caused them. * * @param string $in '' - * @param string &$out '' + * @param string $out '' * @return string */ public function tidyErrors($in = '', &$out = '') @@ -163,7 +164,7 @@ public function tidyErrors($in = '', &$out = '') * exec method * * @param mixed $cmd '' - * @param mixed &$out null + * @param mixed $out null * @return bool True if successful */ protected function _exec($cmd, &$out = null) diff --git a/src/View/Helper/ToolbarHelper.php b/src/View/Helper/ToolbarHelper.php index 3a4d39339..8f2dea209 100644 --- a/src/View/Helper/ToolbarHelper.php +++ b/src/View/Helper/ToolbarHelper.php @@ -1,4 +1,5 @@ [ 'type' => 'foreign', 'columns' => ['request_id'], - 'references' => ['requests', 'id'] - ] - ] + 'references' => ['requests', 'id'], + ], + ], ]; /** @@ -67,8 +67,8 @@ class PanelsFixture extends TestFixture 'panel' => 'DebugKit.Request', 'title' => 'Request', 'element' => 'DebugKit.request_panel', - 'content' => 'a:5:{s:6:"params";a:5:{s:6:"plugin";N;s:10:"controller";s:5:"Tasks";s:6:"action";s:3:"add";s:4:"_ext";N;s:4:"pass";a:0:{}}s:5:"query";a:0:{}s:4:"data";a:0:{}s:6:"cookie";a:2:{s:14:"toolbarDisplay";s:4:"show";s:7:"CAKEPHP";s:26:"9pk8sa2ot6pclki9f4iakio560";}s:3:"get";a:0:{}}' - ] + 'content' => 'a:5:{s:6:"params";a:5:{s:6:"plugin";N;s:10:"controller";s:5:"Tasks";s:6:"action";s:3:"add";s:4:"_ext";N;s:4:"pass";a:0:{}}s:5:"query";a:0:{}s:4:"data";a:0:{}s:6:"cookie";a:2:{s:14:"toolbarDisplay";s:4:"show";s:7:"CAKEPHP";s:26:"9pk8sa2ot6pclki9f4iakio560";}s:3:"get";a:0:{}}', + ], ]; /** diff --git a/tests/Fixture/RequestsFixture.php b/tests/Fixture/RequestsFixture.php index 2388f4f73..87e8c8dd8 100644 --- a/tests/Fixture/RequestsFixture.php +++ b/tests/Fixture/RequestsFixture.php @@ -44,7 +44,7 @@ class RequestsFixture extends TestFixture 'requested_at' => ['type' => 'datetime', 'null' => false], '_constraints' => [ 'primary' => ['type' => 'primary', 'columns' => ['id']], - ] + ], ]; /** @@ -58,8 +58,8 @@ class RequestsFixture extends TestFixture 'url' => '/tasks/add', 'content_type' => 'text/html', 'status_code' => 200, - 'requested_at' => '2014-08-21 7:41:12' - ] + 'requested_at' => '2014-08-21 7:41:12', + ], ]; /** diff --git a/tests/TestCase/Cache/Engine/DebugEngineTest.php b/tests/TestCase/Cache/Engine/DebugEngineTest.php index 08f15143a..9b57ae5b1 100644 --- a/tests/TestCase/Cache/Engine/DebugEngineTest.php +++ b/tests/TestCase/Cache/Engine/DebugEngineTest.php @@ -1,4 +1,5 @@ 'File', - 'path' => TMP + 'path' => TMP, ]); $this->assertTrue($engine->init()); $this->assertInstanceOf('Cake\Cache\Engine\FileEngine', $engine->engine()); @@ -74,7 +73,7 @@ public function testInitErrorOnInvalidConfig() { $engine = new DebugEngine([ 'className' => 'Derpy', - 'path' => TMP + 'path' => TMP, ]); $engine->init(); } @@ -149,7 +148,7 @@ public function testGroupsProxies() $engine = new DebugEngine([ 'className' => 'File', 'path' => TMP, - 'groups' => ['test', 'test2'] + 'groups' => ['test', 'test2'], ]); $engine->init(); $result = $engine->groups(); @@ -165,7 +164,7 @@ public function testConfigProxies() { $engine = new DebugEngine([ 'className' => 'File', - 'path' => TMP + 'path' => TMP, ]); $engine->init(); @@ -185,7 +184,7 @@ public function testToString() $engine = new DebugEngine([ 'className' => 'File', 'path' => TMP, - 'groups' => ['test', 'test2'] + 'groups' => ['test', 'test2'], ]); $this->assertEquals('File', (string)$engine); } diff --git a/tests/TestCase/Controller/MailPreviewControllerTest.php b/tests/TestCase/Controller/MailPreviewControllerTest.php index c79022d1f..eb90405c3 100644 --- a/tests/TestCase/Controller/MailPreviewControllerTest.php +++ b/tests/TestCase/Controller/MailPreviewControllerTest.php @@ -1,4 +1,5 @@ [ [ 'headers' => ['To' => 'test@example.com'], - 'message' => ['html' => '

Hi

', 'text' => 'Hi'] - ] - ] + 'message' => ['html' => '

Hi

', 'text' => 'Hi'], + ], + ], ]; $panel->content = serialize($data); $panels->save($panel); @@ -150,9 +150,9 @@ public function testSentValidDataRenderPart() 'emails' => [ [ 'headers' => ['To' => 'test@example.com'], - 'message' => ['html' => '

Hi

', 'text' => 'Hi'] - ] - ] + 'message' => ['html' => '

Hi

', 'text' => 'Hi'], + ], + ], ]; $panel->content = serialize($data); $panels->save($panel); diff --git a/tests/TestCase/Controller/PanelsControllerTest.php b/tests/TestCase/Controller/PanelsControllerTest.php index 6d6b794c9..c2c233767 100644 --- a/tests/TestCase/Controller/PanelsControllerTest.php +++ b/tests/TestCase/Controller/PanelsControllerTest.php @@ -1,4 +1,5 @@ configRequest([ 'headers' => [ 'accept' => 'application/json, text/javascript, */*; q=0.01', - ] + ], ]); $this->get('/debug-kit/panels/index/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'); diff --git a/tests/TestCase/Controller/RequestsControllerTest.php b/tests/TestCase/Controller/RequestsControllerTest.php index a7b53c9e4..2d9eef978 100644 --- a/tests/TestCase/Controller/RequestsControllerTest.php +++ b/tests/TestCase/Controller/RequestsControllerTest.php @@ -1,4 +1,5 @@ assertTrue(DebugTimer::stop('test2')); $elapsed = DebugTimer::elapsedTime('test2'); - $expected = stripos(PHP_OS, 'win') === false ? 0.999: 0.95; // Windows timer's precision is bad + $expected = stripos(PHP_OS, 'win') === false ? 0.999 : 0.95; // Windows timer's precision is bad $this->assertTrue($elapsed >= $expected); DebugTimer::start('test3'); diff --git a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php index 20e79827a..6a92d8d76 100644 --- a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php +++ b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php @@ -1,4 +1,5 @@ '/articles', - 'environment' => ['REQUEST_METHOD' => 'GET'] + 'environment' => ['REQUEST_METHOD' => 'GET'], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $layer = new DebugKitMiddleware(); @@ -128,7 +127,7 @@ public function testInvokeNoModifyBinaryResponse() { $request = new ServerRequest([ 'url' => '/articles', - 'environment' => ['REQUEST_METHOD' => 'GET'] + 'environment' => ['REQUEST_METHOD' => 'GET'], ]); $response = new Response([ 'statusCode' => 200, @@ -164,12 +163,12 @@ public function testInvokeNoModifyNonHtmlResponse() { $request = new ServerRequest([ 'url' => '/articles', - 'environment' => ['REQUEST_METHOD' => 'GET'] + 'environment' => ['REQUEST_METHOD' => 'GET'], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/plain', - 'body' => 'OK' + 'body' => 'OK', ]); $layer = new DebugKitMiddleware(); @@ -202,7 +201,7 @@ public function testInvokeNoModifyRequestAction() $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => '

things

' + 'body' => '

things

', ]); $layer = new DebugKitMiddleware(); diff --git a/tests/TestCase/Model/Behavior/TimedBehaviorTest.php b/tests/TestCase/Model/Behavior/TimedBehaviorTest.php index 586c8d6fe..bddd9f759 100644 --- a/tests/TestCase/Model/Behavior/TimedBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/TimedBehaviorTest.php @@ -1,4 +1,5 @@ assertContains('Something going away', $error['message']); $this->assertEquals('DebugKit/tests/TestCase/Panel/DeprecationsPanelTest.php', $error['niceFile']); - $this->assertEquals(45, $error['line']); + $this->assertEquals(46, $error['line']); $error = $data['plugins']['DebugKit'][2]; $this->assertContains('Raw error', $error['message']); $this->assertEquals('DebugKit/tests/TestCase/Panel/DeprecationsPanelTest.php', $error['niceFile']); - $this->assertEquals(47, $error['line']); + $this->assertEquals(48, $error['line']); } public function testSummary() diff --git a/tests/TestCase/Panel/EnvironmentPanelTest.php b/tests/TestCase/Panel/EnvironmentPanelTest.php index d14f74c3d..63aca7539 100644 --- a/tests/TestCase/Panel/EnvironmentPanelTest.php +++ b/tests/TestCase/Panel/EnvironmentPanelTest.php @@ -1,4 +1,5 @@ setMethods(['__debugInfo']) ->getMock(); $unserializableDebugInfo->expects($this->once())->method('__debugInfo')->willReturn([ - 'unserializable' => $unserializable + 'unserializable' => $unserializable, ]); $resource = fopen('data:text/plain;base64,', 'r'); diff --git a/tests/TestCase/ToolbarServiceTest.php b/tests/TestCase/ToolbarServiceTest.php index f3899fac5..ca721014d 100644 --- a/tests/TestCase/ToolbarServiceTest.php +++ b/tests/TestCase/ToolbarServiceTest.php @@ -1,4 +1,5 @@ events, ['panels' => [ 'DebugKit.SqlLog' => false, 'DebugKit.Cache' => true, - 'DebugKit.Session' + 'DebugKit.Session', ]]); $bar->loadPanels(); @@ -131,12 +131,12 @@ public function testSaveDataIgnoreRequestAction() { $request = new Request([ 'url' => '/articles', - 'params' => ['plugin' => null, 'requested' => 1] + 'params' => ['plugin' => null, 'requested' => 1], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $bar = new ToolbarService($this->events, []); @@ -152,12 +152,12 @@ public function testSaveDataIgnoreDebugKit() { $request = new Request([ 'url' => '/debug_kit/panel/abc123', - 'params' => [] + 'params' => [], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $bar = new ToolbarService($this->events, []); @@ -173,12 +173,12 @@ public function testSaveDataIgnoreDebugKitDashedUrl() { $request = new Request([ 'url' => '/debug-kit/panel/abc123', - 'params' => [] + 'params' => [], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $bar = new ToolbarService($this->events, []); @@ -194,12 +194,12 @@ public function testSaveData() { $request = new Request([ 'url' => '/articles', - 'environment' => ['REQUEST_METHOD' => 'GET'] + 'environment' => ['REQUEST_METHOD' => 'GET'], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $bar = new ToolbarService($this->events, []); @@ -235,12 +235,12 @@ public function testInjectScriptsLastBodyTag() { $request = new Request([ 'url' => '/articles', - 'environment' => ['REQUEST_METHOD' => 'GET'] + 'environment' => ['REQUEST_METHOD' => 'GET'], ]); $response = new Response([ 'statusCode' => 200, 'type' => 'text/html', - 'body' => 'test

some text

' + 'body' => 'test

some text

', ]); $bar = new ToolbarService($this->events, []); @@ -254,7 +254,7 @@ public function testInjectScriptsLastBodyTag() '' . ''; - $this->assertTextEquals($expected, $response->getBody()); + $this->assertTextEquals($expected, (string)$response->getBody()); $this->assertTrue($response->hasHeader('X-DEBUGKIT-ID'), 'Should have a tracking id'); } @@ -267,7 +267,7 @@ public function testInjectScriptsFileBodies() { $request = new Request([ 'url' => '/articles', - 'params' => ['plugin' => null] + 'params' => ['plugin' => null], ]); $response = new Response([ 'statusCode' => 200, @@ -293,7 +293,7 @@ public function testInjectScriptsStreamBodies() { $request = new Request([ 'url' => '/articles', - 'params' => ['plugin' => null] + 'params' => ['plugin' => null], ]); $response = new Response([ 'statusCode' => 200, @@ -325,7 +325,7 @@ public function testInjectScriptsNoModifyResponse() $response = new Response([ 'statusCode' => 200, 'type' => 'application/json', - 'body' => '{"some":"json"}' + 'body' => '{"some":"json"}', ]); $bar = new ToolbarService($this->events, []); @@ -333,7 +333,7 @@ public function testInjectScriptsNoModifyResponse() $row = $bar->saveData($request, $response); $response = $bar->injectScripts($row, $response); - $this->assertTextEquals('{"some":"json"}', $response->getBody()); + $this->assertTextEquals('{"some":"json"}', (string)$response->getBody()); $this->assertTrue($response->hasHeader('X-DEBUGKIT-ID'), 'Should have a tracking id'); } @@ -435,7 +435,7 @@ public function testIsEnabledForceEnableCallable() $bar = new ToolbarService($this->events, [ 'forceEnable' => function () { return true; - } + }, ]); $this->assertTrue($bar->isEnabled(), 'debug is off, panel is forced on'); } diff --git a/tests/TestCase/View/Helper/CredentialsHelperTest.php b/tests/TestCase/View/Helper/CredentialsHelperTest.php index b0d3b4058..072d53846 100644 --- a/tests/TestCase/View/Helper/CredentialsHelperTest.php +++ b/tests/TestCase/View/Helper/CredentialsHelperTest.php @@ -1,4 +1,5 @@ [ 'class' => 'graph-bar-value', 'style' => 'margin-left: 0px; width: 35px', - 'title' => 'Starting 0ms into the request, taking 10ms' + 'title' => 'Starting 0ms into the request, taking 10ms', ]], ' ', '/div', - '/div' + '/div', ]; $this->assertHtml($expected, $output); } @@ -103,11 +104,11 @@ public function testBarOffset() ['div' => [ 'class' => 'graph-bar-value', 'style' => 'margin-left: 35px; width: 35px', - 'title' => 'Starting 10ms into the request, taking 10ms' + 'title' => 'Starting 10ms into the request, taking 10ms', ]], ' ', '/div', - '/div' + '/div', ]; $this->assertHtml($expected, $output); } diff --git a/tests/TestCase/View/Helper/ToolbarHelperTest.php b/tests/TestCase/View/Helper/ToolbarHelperTest.php index 0a4d66de1..1ff722230 100644 --- a/tests/TestCase/View/Helper/ToolbarHelperTest.php +++ b/tests/TestCase/View/Helper/ToolbarHelperTest.php @@ -1,4 +1,5 @@ ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -84,7 +85,7 @@ public function testMakeNeatArrayBasic() $expected = [ 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -93,7 +94,7 @@ public function testMakeNeatArrayBasic() $expected = [ 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -102,7 +103,7 @@ public function testMakeNeatArrayBasic() $expected = [ 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); } @@ -134,7 +135,7 @@ public function testMakeNeatArrayCyclicObjects() '/li', '/ul', '/li', - '/ul' + '/ul', ]; $this->assertHtml($expected, $result); } @@ -167,7 +168,7 @@ public function testMakeNeatArrayDuplicateObjects() '/li', '/ul', '/li', - '/ul' + '/ul', ]; $this->assertHtml($expected, $result); } @@ -184,7 +185,7 @@ public function testMakeNeatArray() $expected = [ 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -193,7 +194,7 @@ public function testMakeNeatArray() $expected = [ 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -203,7 +204,7 @@ public function testMakeNeatArray() 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); @@ -211,8 +212,8 @@ public function testMakeNeatArray() 'key' => 'value', 'foo' => [ 'this' => 'deep', - 'another' => 'value' - ] + 'another' => 'value', + ], ]; $result = $this->Toolbar->makeNeatArray($in); $expected = [ @@ -225,7 +226,7 @@ public function testMakeNeatArray() 'assertHtml($expected, $result); @@ -233,12 +234,12 @@ public function testMakeNeatArray() 'key' => 'value', 'foo' => [ 'this' => 'deep', - 'another' => 'value' + 'another' => 'value', ], 'lotr' => [ 'gandalf' => 'wizard', - 'bilbo' => 'hobbit' - ] + 'bilbo' => 'hobbit', + ], ]; $result = $this->Toolbar->makeNeatArray($in, 1); $expected = [ @@ -258,7 +259,7 @@ public function testMakeNeatArray() 'assertHtml($expected, $result); @@ -280,7 +281,7 @@ public function testMakeNeatArray() 'assertHtml($expected, $result); @@ -290,7 +291,7 @@ public function testMakeNeatArray() 'ul' => ['class' => 'neat-array depth-0'], 'assertHtml($expected, $result); } @@ -317,7 +318,7 @@ public function testMakeNeatArrayObjects() 'assertHtml($expected, $result); } @@ -332,12 +333,12 @@ public function testMakeNeatArraySorted() $in = [ 'lotr' => [ 'gandalf' => 'wizard', - 'bilbo' => 'hobbit' + 'bilbo' => 'hobbit', ], 'key' => 'value', 'foo' => [ 'this' => 'deep', - 'another' => 'value' + 'another' => 'value', ], ]; $this->Toolbar->setSort(true); @@ -359,7 +360,7 @@ public function testMakeNeatArraySorted() 'assertHtml($expected, $result); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fb5af7086..f8823989f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,5 @@ register(); $loader->addNamespace('TestApp', APP); @@ -61,29 +61,29 @@ 'cssBaseUrl' => 'css/', 'paths' => [ 'plugins' => [APP . 'Plugin' . DS], - 'templates' => [APP . 'templates' . DS] - ] + 'templates' => [APP . 'templates' . DS], + ], ]); Configure::write('Session', [ - 'defaults' => 'php' + 'defaults' => 'php', ]); Cache::setConfig([ '_cake_core_' => [ 'engine' => 'File', 'prefix' => 'cake_core_', - 'serialize' => true + 'serialize' => true, ], '_cake_model_' => [ 'engine' => 'File', 'prefix' => 'cake_model_', - 'serialize' => true + 'serialize' => true, ], 'default' => [ 'engine' => 'File', 'prefix' => 'default_', - 'serialize' => true - ] + 'serialize' => true, + ], ]); // Ensure default test connection is defined @@ -110,7 +110,7 @@ 'engine' => 'Cake\Log\Engine\FileLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error', - ] + ], ]); Plugin::getCollection()->add(new \DebugKit\Plugin()); diff --git a/tests/test_app/Application.php b/tests/test_app/Application.php index dc7acf935..e7ad7442c 100644 --- a/tests/test_app/Application.php +++ b/tests/test_app/Application.php @@ -1,4 +1,5 @@