Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit ef12621

Browse files
authored
Merge pull request #44 from symfony-cmf/analysis-qM0ZOO
Apply fixes from StyleCI
2 parents 9a5746b + 8c94df7 commit ef12621

File tree

17 files changed

+106
-113
lines changed

17 files changed

+106
-113
lines changed

src/Controller/ResourceController.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Controller;
1313

14+
use JMS\Serializer\SerializationContext;
15+
use JMS\Serializer\SerializerInterface;
1416
use Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\Handler\ResourceHandler;
15-
use Symfony\Cmf\Component\Resource\Puli\Api\ResourceRepository;
1617
use Symfony\Cmf\Component\Resource\Puli\Api\ResourceNotFoundException;
1718
use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface;
1819
use Symfony\Component\HttpFoundation\Request;
1920
use Symfony\Component\HttpFoundation\Response;
2021
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
21-
use Symfony\Component\Routing\Exception\RouteNotFoundException;
2222
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
2323
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
24-
use JMS\Serializer\SerializerInterface;
25-
use JMS\Serializer\SerializationContext;
2624

2725
class ResourceController
2826
{
@@ -120,7 +118,6 @@ public function patchResourceAction($repositoryName, $path, Request $request)
120118
$fullPath = method_exists($repository, 'resolvePath') ? $repository->resolvePath($path) : $path;
121119
$this->guardAccess('write', $repositoryName, $fullPath);
122120

123-
124121
$requestContent = json_decode($request->getContent(), true);
125122
if (!$requestContent) {
126123
return $this->badRequestResponse('Only JSON request bodies are supported.');

src/DependencyInjection/CmfResourceRestExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\DependencyInjection;
1313

14-
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
use Symfony\Component\Config\Definition\Processor;
1515
use Symfony\Component\Config\FileLocator;
16-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18-
use Symfony\Component\Config\Definition\Processor;
19-
use Symfony\Component\Config\Loader\LoaderInterface;
18+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2019

2120
class CmfResourceRestExtension extends Extension
2221
{
@@ -54,7 +53,6 @@ public function getXsdValidationBasePath()
5453
return __DIR__.'/../Resources/config/schema';
5554
}
5655

57-
5856
private function configurePayloadAliasRegistry(ContainerBuilder $container, $aliasMap)
5957
{
6058
$registry = $container->getDefinition('cmf_resource_rest.registry.payload_alias');

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\DependencyInjection;
1313

14-
use Symfony\Component\Config\Definition\ConfigurationInterface;
1514
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15+
use Symfony\Component\Config\Definition\ConfigurationInterface;
1616

1717
class Configuration implements ConfigurationInterface
1818
{

src/Registry/PayloadAliasRegistry.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Registry;
1313

1414
use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource;
15-
use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface;
1615
use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource;
16+
use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface;
1717

1818
/**
1919
* Registry for resource payload aliases.
@@ -25,7 +25,7 @@ class PayloadAliasRegistry
2525
/**
2626
* @var array
2727
*/
28-
private $aliasesByRepository = array();
28+
private $aliasesByRepository = [];
2929

3030
/**
3131
* @var RepositoryRegistryInterface
@@ -36,13 +36,13 @@ class PayloadAliasRegistry
3636
* @param RepositoryRegistryInterface $repositoryRegistry
3737
* @param array $aliases
3838
*/
39-
public function __construct(RepositoryRegistryInterface $repositoryRegistry, array $aliases = array())
39+
public function __construct(RepositoryRegistryInterface $repositoryRegistry, array $aliases = [])
4040
{
4141
$this->repositoryRegistry = $repositoryRegistry;
4242

4343
foreach ($aliases as $alias => $config) {
4444
if (!isset($this->aliasesByRepository[$config['repository']])) {
45-
$this->aliasesByRepository[$config['repository']] = array();
45+
$this->aliasesByRepository[$config['repository']] = [];
4646
}
4747

4848
$this->aliasesByRepository[$config['repository']][$config['type']] = $alias;

src/Serializer/Jms/EventSubscriber/PhpcrNodeSubscriber.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\EventSubscriber;
1313

14-
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
15-
use PHPCR\NodeInterface;
1614
use JMS\Serializer\EventDispatcher\Events;
15+
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
1716
use JMS\Serializer\EventDispatcher\PreSerializeEvent;
17+
use PHPCR\NodeInterface;
1818

1919
/**
2020
* Force the type of PHPCR node instances to PHPCR\NodeInterface.
@@ -25,12 +25,12 @@ class PhpcrNodeSubscriber implements EventSubscriberInterface
2525
{
2626
public static function getSubscribedEvents()
2727
{
28-
return array(
29-
array(
28+
return [
29+
[
3030
'event' => Events::PRE_SERIALIZE,
3131
'method' => 'onPreSerialize',
32-
),
33-
);
32+
],
33+
];
3434
}
3535

3636
/**

src/Serializer/Jms/EventSubscriber/ResourceSubscriber.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\EventSubscriber;
1313

14-
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
1514
use JMS\Serializer\EventDispatcher\Events;
15+
use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
1616
use JMS\Serializer\EventDispatcher\PreSerializeEvent;
1717
use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource;
1818

@@ -25,12 +25,12 @@ class ResourceSubscriber implements EventSubscriberInterface
2525
{
2626
public static function getSubscribedEvents()
2727
{
28-
return array(
29-
array(
28+
return [
29+
[
3030
'event' => Events::PRE_SERIALIZE,
3131
'method' => 'onPreSerialize',
32-
),
33-
);
32+
],
33+
];
3434
}
3535

3636
/**

src/Serializer/Jms/Handler/PhpcrNodeHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\Handler;
1313

14-
use JMS\Serializer\Handler\SubscribingHandlerInterface;
14+
use JMS\Serializer\Context;
1515
use JMS\Serializer\GraphNavigator;
16+
use JMS\Serializer\Handler\SubscribingHandlerInterface;
1617
use JMS\Serializer\JsonSerializationVisitor;
17-
use JMS\Serializer\Context;
1818
use PHPCR\NodeInterface;
1919

2020
/**
@@ -26,14 +26,14 @@ class PhpcrNodeHandler implements SubscribingHandlerInterface
2626
{
2727
public static function getSubscribingMethods()
2828
{
29-
return array(
30-
array(
29+
return [
30+
[
3131
'event' => GraphNavigator::DIRECTION_SERIALIZATION,
3232
'format' => 'json',
3333
'type' => 'PHPCR\NodeInterface',
3434
'method' => 'serializePhpcrNode',
35-
),
36-
);
35+
],
36+
];
3737
}
3838

3939
/**
@@ -48,7 +48,7 @@ public function serializePhpcrNode(
4848
array $type,
4949
Context $context
5050
) {
51-
$res = array();
51+
$res = [];
5252

5353
foreach ($node->getProperties() as $name => $property) {
5454
$res[$name] = $property->getValue();

src/Serializer/Jms/Handler/ResourceHandler.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Serializer\Jms\Handler;
1313

14-
use JMS\Serializer\Handler\SubscribingHandlerInterface;
14+
use JMS\Serializer\Context;
1515
use JMS\Serializer\GraphNavigator;
16+
use JMS\Serializer\Handler\SubscribingHandlerInterface;
1617
use JMS\Serializer\JsonSerializationVisitor;
17-
use JMS\Serializer\Context;
1818
use PHPCR\NodeInterface;
1919
use PHPCR\Util\PathHelper;
20+
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
2021
use Symfony\Cmf\Component\Resource\Description\DescriptionFactory;
2122
use Symfony\Cmf\Component\Resource\Puli\Api\PuliResource;
22-
use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface;
2323
use Symfony\Cmf\Component\Resource\Repository\Resource\CmfResource;
24-
use Symfony\Cmf\Bundle\ResourceRestBundle\Registry\PayloadAliasRegistry;
24+
use Symfony\Cmf\Component\Resource\RepositoryRegistryInterface;
2525

2626
/**
2727
* Handle PHPCR resource serialization.
@@ -52,14 +52,14 @@ public function __construct(
5252

5353
public static function getSubscribingMethods()
5454
{
55-
return array(
56-
array(
55+
return [
56+
[
5757
'event' => GraphNavigator::DIRECTION_SERIALIZATION,
5858
'format' => 'json',
5959
'type' => 'Puli\Repository\Api\Resource\PuliResource',
6060
'method' => 'serializeResource',
61-
),
62-
);
61+
],
62+
];
6363
}
6464

6565
/**
@@ -85,7 +85,7 @@ public function setMaxDepth($maxDepth)
8585

8686
private function doSerializeResource(PuliResource $resource, $depth = 0)
8787
{
88-
$data = array();
88+
$data = [];
8989
$repositoryAlias = $this->registry->getRepositoryName($resource->getRepository());
9090

9191
$data['repository_alias'] = $repositoryAlias;
@@ -105,9 +105,9 @@ private function doSerializeResource(PuliResource $resource, $depth = 0)
105105
$data['label'] = $data['node_name'] = PathHelper::getNodeName($data['path']);
106106
$data['repository_path'] = $resource->getRepositoryPath();
107107

108-
$children = array();
108+
$children = [];
109109
foreach ($resource->listChildren() as $name => $childResource) {
110-
$children[$name] = array();
110+
$children[$name] = [];
111111

112112
if ($depth < $this->maxDepth) {
113113
$children[$name] = $this->doSerializeResource($childResource, $depth + 1);

tests/Features/Context/ResourceContext.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111

1212
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Features\Context;
1313

14-
use Behat\Gherkin\Node\PyStringNode;
14+
use Behat\Behat\Context\Context;
1515
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
16+
use Behat\Gherkin\Node\PyStringNode;
1617
use Behat\Gherkin\Node\TableNode;
1718
use PHPCR\Util\NodeHelper;
1819
use PHPCR\Util\PathHelper;
19-
use Behat\Symfony2Extension\Context\KernelAwareContext;
20-
use Behat\Behat\Context\Context;
21-
use Symfony\Component\HttpKernel\KernelInterface;
2220
use Symfony\Component\Filesystem\Filesystem;
2321
use Symfony\Component\Finder\Finder;
22+
use Symfony\Component\HttpKernel\KernelInterface;
2423
use Webmozart\Assert\Assert;
2524

2625
class ResourceContext implements Context

tests/Resources/TestBundle/Security/ResourceVoter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Symfony\Cmf\Bundle\ResourceRestBundle\Tests\Resources\TestBundle\Security;
44

5+
use Symfony\Cmf\Bundle\ResourceRestBundle\Controller\ResourceController;
56
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
67
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
7-
use Symfony\Cmf\Bundle\ResourceRestBundle\Controller\ResourceController;
88

99
class ResourceVoter extends Voter
1010
{
@@ -18,7 +18,7 @@ protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
1818
if ('security' !== $subject['repository_name']) {
1919
return true;
2020
}
21-
21+
2222
if ('/tests/cmf/articles/public' !== substr($subject['path'], 0, 27)) {
2323
return false;
2424
}

0 commit comments

Comments
 (0)