From c8b8e924b8b7bdf5dc0efd6ef9f02ca31d52822e Mon Sep 17 00:00:00 2001 From: David Neustadt Date: Thu, 19 Apr 2018 20:14:17 +0200 Subject: [PATCH] cs fixes --- .php_cs.dist | 1 + Controllers/Backend/ViewSnapshots.php | 23 ++++++++++------------- Controllers/Frontend/Snapshots.php | 8 ++++---- FroshViewSnapshots.php | 7 +++---- README.MD | 1 - Subscriber/Dispatch.php | 19 ++++++++----------- Subscriber/TemplateRegistration.php | 7 +++---- composer.json | 2 +- tests/Unit/bootstrap.php | 11 ++++++----- tests/Unit/config.php | 24 ++++++++++++------------ 10 files changed, 48 insertions(+), 55 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index f371d09..15c80f1 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create() 'array_syntax' => ['syntax' => 'short'], 'declare_strict_types' => false, 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + 'increment_style' => ['style' => 'post'], ] ) ->setFinder($finder); \ No newline at end of file diff --git a/Controllers/Backend/ViewSnapshots.php b/Controllers/Backend/ViewSnapshots.php index cd7c1ed..684a746 100644 --- a/Controllers/Backend/ViewSnapshots.php +++ b/Controllers/Backend/ViewSnapshots.php @@ -5,10 +5,9 @@ */ class Shopware_Controllers_Backend_ViewSnapshots extends Shopware_Controllers_Backend_ExtJs { - - public function indexAction() + public function indexAction() { - $this->View()->loadTemplate("backend/view_snapshots/app.js"); + $this->View()->loadTemplate('backend/view_snapshots/app.js'); } /** @@ -16,8 +15,8 @@ public function indexAction() */ public function listAction() { - $limit = (int)$this->Request()->getParam('limit', 20); - $offset = (int)$this->Request()->getParam('start', 0); + $limit = (int) $this->Request()->getParam('limit', 20); + $offset = (int) $this->Request()->getParam('start', 0); $qb = $this->getModelManager()->getDBALQueryBuilder(); @@ -41,21 +40,19 @@ public function listAction() foreach ($data as &$row) { $row['url'] = $this->get('router')->assemble( [ - 'module' => 'frontend', - 'controller' => 'snapshots', - 'action' => 'load', - 'session' => $row['sessionID'], - 'step' => $row['step'], + 'module' => 'frontend', + 'controller' => 'snapshots', + 'action' => 'load', + 'session' => $row['sessionID'], + 'step' => $row['step'], ] ); } - $total = (int)$this->container->get('dbal_connection')->fetchColumn('SELECT FOUND_ROWS()'); + $total = (int) $this->container->get('dbal_connection')->fetchColumn('SELECT FOUND_ROWS()'); $this->View()->assign( ['success' => true, 'data' => $data, 'total' => $total] ); } - } - diff --git a/Controllers/Frontend/Snapshots.php b/Controllers/Frontend/Snapshots.php index 0f34841..436cb95 100644 --- a/Controllers/Frontend/Snapshots.php +++ b/Controllers/Frontend/Snapshots.php @@ -13,7 +13,7 @@ public function indexAction() public function loadAction() { $sessionID = $this->Request()->getParam('session'); - $step = (int)$this->Request()->getParam('step', 1); + $step = (int) $this->Request()->getParam('step', 1); if (empty($sessionID)) { throw new \Exception( @@ -37,12 +37,12 @@ public function loadAction() ); } - $nextStep = (int)$this->get('dbal_connection')->fetchColumn( + $nextStep = (int) $this->get('dbal_connection')->fetchColumn( 'SELECT MIN(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` > :step LIMIT 1', $sqlParams ); - $prevStep = (int)$this->get('dbal_connection')->fetchColumn( + $prevStep = (int) $this->get('dbal_connection')->fetchColumn( 'SELECT MAX(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` < :step LIMIT 1', $sqlParams ); @@ -90,4 +90,4 @@ public function stopRecordingAction() $this->Response()->setBody(json_encode(['success' => true])); } -} \ No newline at end of file +} diff --git a/FroshViewSnapshots.php b/FroshViewSnapshots.php index 081e54a..87833b5 100644 --- a/FroshViewSnapshots.php +++ b/FroshViewSnapshots.php @@ -3,15 +3,14 @@ namespace FroshViewSnapshots; use Shopware\Components\Plugin; -use Shopware\Components\Plugin\Context\UninstallContext; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Shopware\Components\Plugin\Context\ActivateContext; use Shopware\Components\Plugin\Context\InstallContext; +use Shopware\Components\Plugin\Context\UninstallContext; use Shopware\Components\Plugin\Context\UpdateContext; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Class FroshViewSnapshots - * @package FroshViewSnapshots */ class FroshViewSnapshots extends Plugin { @@ -60,4 +59,4 @@ public function uninstall(UninstallContext $context) $this->container->get('dbal_connection')->query($sql); } -} \ No newline at end of file +} diff --git a/README.MD b/README.MD index 3cae571..a187e03 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,5 @@ # View Snapshots -[![Scrutinizer](https://scrutinizer-ci.com/g/FriendsOfShopware/FroshViewSnapshots/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FriendsOfShopware/FroshViewSnapshots/?branch=master) [![Travis CI](https://travis-ci.org/FriendsOfShopware/FroshViewSnapshots.svg?branch=master)](https://travis-ci.org/FriendsOfShopware/FroshViewSnapshots) View Snapshots is a plugin for shopware that allows you to record/log requests diff --git a/Subscriber/Dispatch.php b/Subscriber/Dispatch.php index 3e06a37..278b8f2 100644 --- a/Subscriber/Dispatch.php +++ b/Subscriber/Dispatch.php @@ -7,7 +7,6 @@ /** * Class Dispatch - * @package FroshViewSnapshots\Subscriber */ class Dispatch implements SubscriberInterface { @@ -23,14 +22,14 @@ class Dispatch implements SubscriberInterface /** * Dispatch constructor. + * * @param \Enlight_Components_Session_Namespace $session - * @param Connection $connection + * @param Connection $connection */ public function __construct( \Enlight_Components_Session_Namespace $session, Connection $connection - ) - { + ) { $this->session = $session; $this->connection = $connection; } @@ -63,7 +62,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs $view->assign( [ - 'snapshotSessionID' => $snapshotSessionID ? : $sessionID, + 'snapshotSessionID' => $snapshotSessionID ?: $sessionID, 'isSessionRecorded' => $isSessionRecorded, ] ); @@ -72,8 +71,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs $snapshotSessionID || !$isSessionRecorded || $request->isXmlHttpRequest() - ) - { + ) { return; } @@ -86,8 +84,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs try { // workaround for PDOException when trying to serialize PDO instances serialize($value); - } - catch (\Throwable $e) { + } catch (\Throwable $e) { // as we only need a snapshot for the view, remove the PDO instance $value = null; } @@ -100,7 +97,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs $params['__action'] = $request->getActionName(); $params = json_encode($params); - $step = (int)$this->connection->fetchColumn( + $step = (int) $this->connection->fetchColumn( 'SELECT MAX(`step`) FROM `view_snapshots` WHERE `sessionID` = :sessionID', ['sessionID' => $sessionID] ); @@ -117,4 +114,4 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs ] ); } -} \ No newline at end of file +} diff --git a/Subscriber/TemplateRegistration.php b/Subscriber/TemplateRegistration.php index 7416048..c9bc4eb 100644 --- a/Subscriber/TemplateRegistration.php +++ b/Subscriber/TemplateRegistration.php @@ -6,7 +6,6 @@ /** * Class TemplateRegistration - * @package FroshViewSnapshots\Subscriber */ class TemplateRegistration implements SubscriberInterface { @@ -22,14 +21,14 @@ class TemplateRegistration implements SubscriberInterface /** * TemplateRegistration constructor. + * * @param $pluginDirectory * @param \Enlight_Template_Manager $templateManager */ public function __construct( $pluginDirectory, \Enlight_Template_Manager $templateManager - ) - { + ) { $this->pluginDirectory = $pluginDirectory; $this->templateManager = $templateManager; } @@ -48,4 +47,4 @@ public function onPreDispatch() { $this->templateManager->addTemplateDir($this->pluginDirectory . '/Resources/views'); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index f73b219..54119a1 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "frosh/frosh-view-snapshots", + "name": "frosh/view-snapshots", "keywords": ["views", "snapshot", "recording", "frontend", "template", "restore", "shopware", "shopware-plugin"], "description": "Shopware plugin that allows you to record/log views and restore them", "license": "MIT", diff --git a/tests/Unit/bootstrap.php b/tests/Unit/bootstrap.php index 5b8cf8a..57ab354 100644 --- a/tests/Unit/bootstrap.php +++ b/tests/Unit/bootstrap.php @@ -27,10 +27,6 @@ class TestKernel extends \Shopware\Kernel { - protected function getConfigPath() - { - return __DIR__ . '/config.php'; - } /** * Static method to start boot kernel without leaving local scope in test helper. */ @@ -47,5 +43,10 @@ public static function start() $shop->registerResources(); $_SERVER['HTTP_HOST'] = $shop->getHost(); } + + protected function getConfigPath() + { + return __DIR__ . '/config.php'; + } } -TestKernel::start(); \ No newline at end of file +TestKernel::start(); diff --git a/tests/Unit/config.php b/tests/Unit/config.php index 46663fe..0bb2af4 100644 --- a/tests/Unit/config.php +++ b/tests/Unit/config.php @@ -1,34 +1,34 @@ loadConfig($this->AppPath() . 'Configs/Default.php'), [ 'front' => [ - 'throwExceptions' => true, + 'throwExceptions' => true, 'disableOutputBuffering' => false, - 'showException' => true, + 'showException' => true, ], 'errorHandler' => [ 'throwOnRecoverableError' => true, ], 'session' => [ 'unitTestEnabled' => true, - 'name' => 'SHOPWARESID', + 'name' => 'SHOPWARESID', 'cookie_lifetime' => 0, - 'use_trans_sid' => false, - 'gc_probability' => 1, - 'gc_divisor' => 100, - 'save_handler' => 'db', + 'use_trans_sid' => false, + 'gc_probability' => 1, + 'gc_divisor' => 100, + 'save_handler' => 'db', ], 'mail' => [ 'type' => 'file', 'path' => $this->getCacheDir(), ], 'phpSettings' => [ - 'error_reporting' => E_ALL, - 'display_errors' => 1, - 'date.timezone' => 'Europe/Berlin', + 'error_reporting' => E_ALL, + 'display_errors' => 1, + 'date.timezone' => 'Europe/Berlin', 'max_execution_time' => 0, ], 'csrfProtection' => [ 'frontend' => false, - 'backend' => false, + 'backend' => false, ], -]); \ No newline at end of file +]);