Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
CS Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Jun 3, 2015
1 parent 759af89 commit da790a7
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 87 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ return Symfony\CS\Config\Config::create()
'-concat_without_spaces',
'-phpdoc_indent',
'-phpdoc_params',
'-psr0',
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
Expand Down
5 changes: 2 additions & 3 deletions bin/testconsole.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

use Sulu\Component\DocumentManager\Tests\Bootstrap;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Application;

require_once(__DIR__ . '/../vendor/autoload.php');
require_once __DIR__ . '/../vendor/autoload.php';

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper(Bootstrap::createDbalConnection())
'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper(Bootstrap::createDbalConnection()),
));

$cli = new Application('Sulu Document Manager Test CLI', '0.1');
Expand Down
2 changes: 1 addition & 1 deletion lib/Collection/ReferrerCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function initialize()
// initialized, but if we don't do this, we won't know how many items are in the
// collection, as one node could have many referring properties.
foreach ($references as $reference) {
/** @var PropertyInterface $reference */
/* @var PropertyInterface $reference */
$referrerNode = $reference->getParent();
$this->documents[$referrerNode->getIdentifier()] = $referrerNode;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/DocumentInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getParent($document)
$parentNode = $this->getNode($document)->getParent();

if (!$parentNode) {
return null;
return;
}

return $this->proxyFactory->createProxyForNode($document, $parentNode);
Expand Down
1 change: 1 addition & 0 deletions lib/Event/CreateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct($alias)

/**
* @return object
*
* @throws \RuntimeException
*/
public function getDocument()
Expand Down
3 changes: 2 additions & 1 deletion lib/Event/FindEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getDebugMessage()
'i:%s d:%s l:%s',
$this->identifier,
$this->document ? spl_object_hash($this->document) : '<no document>',
$this->locale ? : '<no locale>'
$this->locale ?: '<no locale>'
);
}

Expand All @@ -78,6 +78,7 @@ public function getLocale()

/**
* @return object
*
* @throws DocumentManagerException
*/
public function getDocument()
Expand Down
1 change: 1 addition & 0 deletions lib/Event/QueryCreateBuilderEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function setQueryBuilder(QueryBuilder $queryBuilder)

/**
* @return mixed
*
* @throws DocumentManagerException
*/
public function getQueryBuilder()
Expand Down
2 changes: 1 addition & 1 deletion lib/NodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use PHPCR\NodeInterface;
use PHPCR\RepositoryException;
use PHPCR\SessionInterface;
use PHPCR\Util\NodeHelper;
use PHPCR\Util\UUIDHelper;
use Sulu\Component\DocumentManager\Exception\DocumentNotFoundException;
use PHPCR\Util\NodeHelper;

/**
* The node manager is responsible for talking to the PHPCR
Expand Down
16 changes: 13 additions & 3 deletions lib/PathBuilder.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<?php

/*
* This file is part of the Sulu CMS.
*
* (c) MASSIVE ART WebServices GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sulu\Component\DocumentManager;

/**
* The path builder provides a way to create paths from templates
* The path builder provides a way to create paths from templates.
*/
class PathBuilder
{
Expand Down Expand Up @@ -40,9 +49,10 @@ public function __construct(PathSegmentRegistry $registry)
* @see Sulu\Component\DocumentManager\PathSegmentRegistry
*
* @param array $segments
*
* @return string
*/
public function build($segments)
public function build(array $segments)
{
$results = array();
foreach ($segments as $segment) {
Expand All @@ -64,7 +74,7 @@ public function build($segments)
private function buildSegment($segment)
{
if (empty($segment) || $segment == '/') {
return null;
return;
}

if (substr($segment, 0, 1) == '%') {
Expand Down
1 change: 1 addition & 0 deletions lib/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function __construct(
* @param string $hydrationMode
*
* @return mixed|\PHPCR\Query\QueryResultInterface
*
* @throws DocumentManagerException
*/
public function execute(array $parameters = array(), $hydrationMode = self::HYDRATE_DOCUMENT)
Expand Down
6 changes: 3 additions & 3 deletions lib/Strategy/MixinStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public function createNodeForDocument($document, NodeInterface $parentNode, $nam
public function resolveMetadataForNode(NodeInterface $node)
{
if (false === $node->hasProperty('jcr:mixinTypes')) {
return null;
return;
}

$mixinTypes = (array)$node->getPropertyValue('jcr:mixinTypes');
$mixinTypes = (array) $node->getPropertyValue('jcr:mixinTypes');

foreach ($mixinTypes as $mixinType) {
if (true == $this->metadataFactory->hasMetadataForPhpcrType($mixinType)) {
return $this->metadataFactory->getMetadataForPhpcrType($mixinType);
}
}

return null;
return;
}
}
2 changes: 1 addition & 1 deletion lib/Subscriber/Behavior/Audit/BlameSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private function getUserId(array $options)
$token = $this->tokenStorage->getToken();

if (null === $token || $token instanceof AnonymousToken) {
return null;
return;
}

$user = $token->getUser();
Expand Down
3 changes: 1 addition & 2 deletions lib/Subscriber/Behavior/Path/AutoNameSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Sulu\Component\DocumentManager\NameResolver;
use Sulu\Component\DocumentManager\NodeManager;
use Symfony\Cmf\Bundle\CoreBundle\Slugifier\SlugifierInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
Expand Down Expand Up @@ -164,7 +163,7 @@ public function handlePersist(PersistEvent $event)
*/
private function rename(NodeInterface $node, $name)
{
$names = (array)$node->getParent()->getNodeNames();
$names = (array) $node->getParent()->getNodeNames();
$pos = array_search($node->getName(), $names);
$next = isset($names[$pos + 1]) ? $names[$pos + 1] : null;

Expand Down
2 changes: 0 additions & 2 deletions lib/Subscriber/Phpcr/RemoveSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Sulu\Component\DocumentManager\Subscriber\Phpcr;

use PHPCR\NodeInterface;
use PHPCR\PropertyInterface;
use Sulu\Component\DocumentManager\DocumentRegistry;
use Sulu\Component\DocumentManager\Event\RemoveEvent;
use Sulu\Component\DocumentManager\Events;
Expand Down
2 changes: 1 addition & 1 deletion lib/Subscriber/Phpcr/ReorderSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function handleReorder(ReorderEvent $event)
private function resolveSiblingName($siblingId, NodeInterface $parentNode, NodeInterface $node)
{
if (null === $siblingId) {
return null;
return;
}

$siblingPath = $siblingId;
Expand Down
2 changes: 0 additions & 2 deletions symfony-di/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,3 @@
</services>

</container>


7 changes: 2 additions & 5 deletions tests/Bench/BaseBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@

namespace Sulu\Component\DocumentManager\Tests\Bench;

use Sulu\Component\DocumentManager\Tests\Bootstrap;
use Sulu\Component\DocumentManager\Subscriber\Behavior;
use Symfony\Component\EventDispatcher\EventDispatcher;
use PhpBench\Benchmark;
use Sulu\Component\DocumentManager\Tests\Bootstrap;

abstract class BaseBench implements Benchmark
{
const BASE_NAME = 'test';
const BASE_PATH = '/test';

private $session;
private $container;

protected function initPhpcr()
Expand Down Expand Up @@ -50,6 +47,7 @@ protected function getContainer()
protected function getSession()
{
$session = $this->getContainer()->get('doctrine_phpcr.default_session');

return $session;
}

Expand All @@ -58,4 +56,3 @@ protected function getDocumentManager()
return $this->getContainer()->get('sulu_document_manager.document_manager');
}
}

11 changes: 5 additions & 6 deletions tests/Bench/BenchmarkBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Sulu\Component\DocumentManager\Tests\Bench;

use PhpBench\BenchCase;
use PhpBench\Benchmark\Iteration;

class BenchmarkBench extends BaseBench
Expand All @@ -37,7 +36,7 @@ public function benchCreatePersist(Iteration $iteration)
$document = $manager->create('full');
foreach ($locales as $locale) {
$manager->persist($document, $locale, array(
'path' => self::BASE_PATH . '/node-' . $i
'path' => self::BASE_PATH . '/node-' . $i,
));
}
}
Expand All @@ -61,8 +60,8 @@ public function benchCreatePersistPhpcr(Iteration $iteration)
$node = $baseNode->addNode('node-' . $i);
foreach ($iteration->getParameter('locales') as $locale) {
$node->addMixin('mix:test');
$node->setProperty('lsys:' . $locale .'-created', new \DateTime());
$node->setProperty('lsys:' . $locale .'-changed', new \DateTime());
$node->setProperty('lsys:' . $locale . '-created', new \DateTime());
$node->setProperty('lsys:' . $locale . '-changed', new \DateTime());
}
}

Expand All @@ -76,10 +75,10 @@ public function provideNodeTotals()
'nb_nodes' => 1,
),
array(
'nb_nodes' => 10,
'nb_nodes' => 10,
),
array(
'nb_nodes' => 100,
'nb_nodes' => 100,
),
);
}
Expand Down
7 changes: 3 additions & 4 deletions tests/Bench/PathBuilderBench.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Sulu\Component\DocumentManager\Tests\Bench;
namespace Sulu\Component\DocumentManager\tests\Bench;

use PhpBench\Benchmark;
use Sulu\Component\DocumentManager\PathBuilder;
use Sulu\Component\DocumentManager\PathSegmentRegistry;
use PhpBench\Benchmark;

class PathBuilderBench implements Benchmark
{
Expand Down Expand Up @@ -33,12 +33,11 @@ public function provideElements()
{
return array(
array(
'elements' => array('one', 'two', 'three')
'elements' => array('one', 'two', 'three'),
),
array(
'elements' => array('%one', '%two%', 'three'),
),
);
}

}
25 changes: 10 additions & 15 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Component\DocumentManager\Tests;
namespace Sulu\Component\DocumentManager\tests;

use Jackalope\RepositoryFactoryDoctrineDBAL;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use PHPCR\SessionInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Sulu\Component\DocumentManager\EventDispatcher\DebugEventDispatcher;
use Symfony\Component\Stopwatch\Stopwatch;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

class Bootstrap
{
Expand All @@ -35,21 +32,19 @@ public static function createContainer()

$container = new ContainerBuilder();
$container->set('doctrine_phpcr.default_session', self::createSession());
$stopwatch = new Stopwatch();
$logger = new Logger('test');
$logger->pushHandler(new StreamHandler($logDir .'/test.log'));
$logger->pushHandler(new StreamHandler($logDir . '/test.log'));

//$dispatcher = new DebugEventDispatcher($container, $stopwatch, $logger);
$dispatcher = new ContainerAwareEventDispatcher($container);
$container->set('sulu_document_manager.event_dispatcher', $dispatcher);

$config = array(
'sulu_document_manager.default_locale' => 'en',
'sulu_document_manager.mapping'=> array(
'sulu_document_manager.mapping' => array(
'full' => array(
'alias' => 'full',
'phpcr_type' => 'mix:test',
'class' => 'Sulu\Component\DocumentManager\Tests\Functional\Model\FullDocument'
'class' => 'Sulu\Component\DocumentManager\Tests\Functional\Model\FullDocument',
),
),
'sulu_document_manager.namespace_mapping' => array(
Expand Down Expand Up @@ -77,13 +72,13 @@ public static function createContainer()
}

/**
* Create a new PHPCR session
* Create a new PHPCR session.
*
* @return SessionInterface
*/
public static function createSession()
{
$transportName = getenv('SULU_DM_TRANSPORT') ? : 'jackalope-doctrine-dbal';
$transportName = getenv('SULU_DM_TRANSPORT') ?: 'jackalope-doctrine-dbal';

switch ($transportName) {
case 'jackalope-doctrine-dbal':
Expand All @@ -104,7 +99,7 @@ public static function createDbalConnection()
'host' => 'localhost',
'user' => 'admin',
'password' => 'admin',
'path' => __DIR__ . '/../data/test.sqlite'
'path' => __DIR__ . '/../data/test.sqlite',
));

return $connection;
Expand Down
Loading

0 comments on commit da790a7

Please sign in to comment.