From 802e34924774d202e1b29e8e399928625933be86 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Tue, 28 Aug 2018 05:33:53 +0000 Subject: [PATCH] Apply fixes from StyleCI --- spec/PHPCR/Shell/Query/UpdateParserSpec.php | 2 -- src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php | 2 ++ .../Shell/Console/Command/Phpcr/NodePropertySetCommand.php | 1 + .../Shell/Console/Command/Phpcr/QueryUpdateCommand.php | 1 - src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php | 1 + src/PHPCR/Shell/Phpcr/PhpcrSession.php | 1 + src/PHPCR/Shell/Query/Validator.php | 1 - src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php | 1 - src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php | 1 - src/PHPCR/Shell/Test/ContextBase.php | 6 ++++++ 10 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/PHPCR/Shell/Query/UpdateParserSpec.php b/spec/PHPCR/Shell/Query/UpdateParserSpec.php index bdfb9eaa..85df910f 100644 --- a/spec/PHPCR/Shell/Query/UpdateParserSpec.php +++ b/spec/PHPCR/Shell/Query/UpdateParserSpec.php @@ -93,7 +93,6 @@ public function it_should_parse_functions( $qomf->selector('a', 'dtl:article')->willReturn($source); $qomf->createQuery($source, null)->willReturn($query); - $sql = <<<'EOT' UPDATE [dtl:article] AS a SET a.tags = array_replace(a.tags, 'asd', 'dsa') EOT; @@ -110,7 +109,6 @@ public function it_should_parse_apply( $qomf->selector('a', 'dtl:article')->willReturn($source); $qomf->createQuery($source, null)->willReturn($query); - $sql = <<<'EOT' UPDATE [dtl:article] AS a APPLY nodetype_add('nt:barbar') EOT; diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index 18dff05d..b6f8da76 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -176,6 +176,7 @@ private function renderChildren($currentNode, $table, $spacers, $filter = null) } $primaryItemValue = ''; + try { $primaryItem = $child->getPrimaryItem(); @@ -243,6 +244,7 @@ private function renderProperties($currentNode, $table, $spacers, $filter = null $i = 0; foreach ($properties as $name => $property) { $this->nbProperties++; + try { $i++; if (isset($propertyNames[$name])) { diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php index 812cc4cd..1cdae185 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertySetCommand.php @@ -69,6 +69,7 @@ public function execute(InputInterface $input, OutputInterface $output) // convert path to UUID if (false === UUIDHelper::isUuid($value)) { $path = $value; + try { $targetNode = $session->getNode($path); $value = $targetNode->getIdentifier(); diff --git a/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php index 8a93ca12..8a12b088 100644 --- a/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php @@ -80,7 +80,6 @@ public function execute(InputInterface $input, OutputInterface $output) $updates = $res->offsetGet(1); $applies = $res->offsetGet(3); - $start = microtime(true); $result = $query->execute(); $rows = 0; diff --git a/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php b/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php index bef67137..62326cce 100644 --- a/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Shell/PathChangeCommand.php @@ -30,6 +30,7 @@ public function execute(InputInterface $input, OutputInterface $output) { $session = $this->get('phpcr.session'); $path = $input->getArgument('path'); + try { $session->chdir($path); $output->writeln(''.$session->getCwd().''); diff --git a/src/PHPCR/Shell/Phpcr/PhpcrSession.php b/src/PHPCR/Shell/Phpcr/PhpcrSession.php index 52262836..736ab22d 100644 --- a/src/PHPCR/Shell/Phpcr/PhpcrSession.php +++ b/src/PHPCR/Shell/Phpcr/PhpcrSession.php @@ -70,6 +70,7 @@ public function autocomplete($text) { // return autocompletions for current path $cwd = $this->getCwd(); + try { $node = $this->getNode($cwd); $list = (array) $node->getNodeNames(); diff --git a/src/PHPCR/Shell/Query/Validator.php b/src/PHPCR/Shell/Query/Validator.php index 6dd2d1dc..1bce9672 100644 --- a/src/PHPCR/Shell/Query/Validator.php +++ b/src/PHPCR/Shell/Query/Validator.php @@ -10,7 +10,6 @@ * */ - namespace \PHPCR\Shell\Query; class Validator diff --git a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php index 8225b176..04579780 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileLoaderSubscriber.php @@ -16,7 +16,6 @@ use PHPCR\Shell\Config\ProfileLoader; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ProfileInitEvent; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php b/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php index 24810d6e..a2654002 100644 --- a/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php +++ b/src/PHPCR/Shell/Subscriber/ProfileWriterSubscriber.php @@ -15,7 +15,6 @@ use PHPCR\Shell\Config\ProfileLoader; use PHPCR\Shell\Event\PhpcrShellEvents; use PHPCR\Shell\Event\ProfileInitEvent; -use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/src/PHPCR/Shell/Test/ContextBase.php b/src/PHPCR/Shell/Test/ContextBase.php index c9d71708..dc172f28 100644 --- a/src/PHPCR/Shell/Test/ContextBase.php +++ b/src/PHPCR/Shell/Test/ContextBase.php @@ -390,6 +390,7 @@ public function thereShouldNotExistANamespacePrefix($arg1) public function thereShouldExistANodeAt($arg1) { $session = $this->getSession(); + try { $session->getNode($arg1); } catch (PathNotFoundException $e) { @@ -472,6 +473,7 @@ public function thereShouldNotExistANodeAt($arg1) try { $session->getNode($arg1); + throw new \Exception('Node at path '.$arg1.' exists.'); } catch (PathNotFoundException $e) { // good.. not does not exist @@ -505,6 +507,7 @@ public function thereShouldNotExistAPropertyAt($arg1) try { $session->getProperty($arg1); + throw new \Exception('Property exists at "'.$arg1.'"'); } catch (PathNotFoundException $e) { // good @@ -577,6 +580,7 @@ public function thereExistsAWorkspace($arg1) { $session = $this->getSession(); $workspace = $session->getWorkspace(); + try { $workspace->createWorkspace($arg1); } catch (\Exception $e) { @@ -591,6 +595,7 @@ public function thereShouldNotExistAWorkspaceCalled($arg1) { try { $this->thereShouldExistAWorkspaceCalled($arg1); + throw new \Exception(sprintf('Workspace "%s" exists.', $arg1)); } catch (\Exception $e) { } @@ -642,6 +647,7 @@ public function thereShouldNotExistANodeTypeNamed($arg1) $session = $this->getSession(); $workspace = $session->getWorkspace(); $nodeTypeManager = $workspace->getNodeTypeManager(); + try { $nodeTypeManager->getNodeType($arg1); } catch (\Exception $e) {