Skip to content

Commit

Permalink
Merge branch '2.x' into 3.0
Browse files Browse the repository at this point in the history
* 2.x:
  make StyleCI happy
  • Loading branch information
xabbuh committed Aug 27, 2020
2 parents 2c8bcf8 + 6667096 commit dcd7d83
Show file tree
Hide file tree
Showing 48 changed files with 212 additions and 226 deletions.
4 changes: 2 additions & 2 deletions Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class Context
{
private $attributes = array();
private $attributes = [];
private $version;
private $groups;
private $isMaxDepthEnabled;
Expand All @@ -29,7 +29,7 @@ final class Context
/**
* @var ExclusionStrategyInterface[]
*/
private $exclusionStrategies = array();
private $exclusionStrategies = [];

public function setAttribute(string $key, $value): self
{
Expand Down
4 changes: 2 additions & 2 deletions Controller/Annotations/AbstractParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class AbstractParam implements ParamInterface
public $nullable = false;

/** @var array */
public $incompatibles = array();
public $incompatibles = [];

/** {@inheritdoc} */
public function getName()
Expand Down Expand Up @@ -70,7 +70,7 @@ public function getIncompatibilities()
/** {@inheritdoc} */
public function getConstraints()
{
$constraints = array();
$constraints = [];
if (!$this->nullable) {
$constraints[] = new Constraints\NotNull();
}
Expand Down
14 changes: 7 additions & 7 deletions Controller/Annotations/AbstractScalarParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public function getConstraints()
if ($this->requirements instanceof Constraint) {
$constraints[] = $this->requirements;
} elseif (is_scalar($this->requirements)) {
$constraints[] = new Regex(array(
$constraints[] = new Regex([
'pattern' => '#^(?:'.$this->requirements.')$#xsu',
'message' => sprintf(
'Parameter \'%s\' value, does not match requirements \'%s\'',
$this->getName(),
$this->requirements
),
));
]);
} elseif (is_array($this->requirements) && isset($this->requirements['rule']) && $this->requirements['error_message']) {
$constraints[] = new Regex(array(
$constraints[] = new Regex([
'pattern' => '#^(?:'.$this->requirements['rule'].')$#xsu',
'message' => $this->requirements['error_message'],
));
]);
} elseif (is_array($this->requirements)) {
foreach ($this->requirements as $index => $requirement) {
if ($requirement instanceof Constraint) {
Expand All @@ -75,9 +75,9 @@ public function getConstraints()
// If the user wants to map the value, apply all constraints to every
// value of the map
if ($this->map) {
$constraints = array(
new All(array('constraints' => $constraints)),
);
$constraints = [
new All(['constraints' => $constraints]),
];
if (false === $this->nullable) {
$constraints[] = new NotNull();
}
Expand Down
8 changes: 4 additions & 4 deletions Controller/Annotations/FileParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getConstraints()
$constraints[] = $this->requirements;
}

$options = is_array($this->requirements) ? $this->requirements : array();
$options = is_array($this->requirements) ? $this->requirements : [];
if ($this->image) {
$constraints[] = new Image($options);
} else {
Expand All @@ -58,9 +58,9 @@ public function getConstraints()

// If the user wants to map the value
if ($this->map) {
$constraints = array(
new All(array('constraints' => $constraints)),
);
$constraints = [
new All(['constraints' => $constraints]),
];
}

return $constraints;
Expand Down
3 changes: 1 addition & 2 deletions Controller/Annotations/ParamInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public function isStrict();
/**
* Get param value in function of the current request.
*
* @param Request $request
* @param mixed $default value
* @param mixed $default value
*
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/FormatListenerRulesPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function process(ContainerBuilder $container): void
'path' => "^/$path/",
'priorities' => ['html', 'json'],
'fallback_format' => 'html',
'attributes' => array(),
'attributes' => [],
'prefer_extension' => true,
];

Expand Down Expand Up @@ -75,7 +75,7 @@ private function addRule(array $rule, ContainerBuilder $container): void
->addMethodCall('add', [$matcher, $rule]);
}

private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?array $methods = null, array $attributes = array()): Reference
private function createRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, ?array $methods = null, array $attributes = []): Reference
{
$arguments = [$path, $host, $methods, null, $attributes];
$serialized = serialize($arguments);
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->arrayNode('ips')
->beforeNormalization()->ifString()->then(function ($v) {
return array($v);
return [$v];
})->end()
->prototype('scalar')->end()
->end()
Expand Down Expand Up @@ -178,7 +178,7 @@ private function addViewSection(ArrayNodeDefinition $rootNode): void
->prototype('array')
->beforeNormalization()
->ifString()
->then(function ($v) { return array($v); })
->then(function ($v) { return [$v]; })
->end()
->prototype('scalar')->end()
->end()
Expand Down Expand Up @@ -376,7 +376,7 @@ private function addExceptionSection(ArrayNodeDefinition $rootNode): void
->always()
->then(function ($v) {
if (!$v['enabled']) {
return $v;
return $v;
}

if ($v['exception_listener']) {
Expand Down
14 changes: 7 additions & 7 deletions DependencyInjection/FOSRestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ private function loadBodyListener(array $config, XmlFileLoader $loader, Containe
}

$service->replaceArgument(1, $config['body_listener']['throw_exception_on_unsupported_content_type']);
$service->addMethodCall('setDefaultFormat', array($config['body_listener']['default_format']));
$service->addMethodCall('setDefaultFormat', [$config['body_listener']['default_format']]);

$container->getDefinition('fos_rest.decoder_provider')->replaceArgument(1, $config['body_listener']['decoders']);

$decoderServicesMap = array();
$decoderServicesMap = [];

foreach ($config['body_listener']['decoders'] as $id) {
$decoderServicesMap[$id] = new Reference($id);
Expand Down Expand Up @@ -344,7 +344,7 @@ private function loadSerializer(array $config, ContainerBuilder $container): voi
{
$bodyConverter = $container->hasDefinition('fos_rest.converter.request_body') ? $container->getDefinition('fos_rest.converter.request_body') : null;
$viewHandler = $container->getDefinition('fos_rest.view_handler.default');
$options = array();
$options = [];

if (!empty($config['serializer']['version'])) {
if ($bodyConverter) {
Expand Down Expand Up @@ -379,22 +379,22 @@ private function loadZoneMatcherListener(array $config, XmlFileLoader $loader, C
$zone['ips']
);

$zoneMatcherListener->addMethodCall('addRequestMatcher', array($matcher));
$zoneMatcherListener->addMethodCall('addRequestMatcher', [$matcher]);
}
}
}

private function createZoneRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, array $methods = array(), array $ips = null): Reference
private function createZoneRequestMatcher(ContainerBuilder $container, ?string $path = null, ?string $host = null, array $methods = [], array $ips = null): Reference
{
if ($methods) {
$methods = array_map('strtoupper', (array) $methods);
}

$serialized = serialize(array($path, $host, $methods, $ips));
$serialized = serialize([$path, $host, $methods, $ips]);
$id = 'fos_rest.zone_request_matcher.'.md5($serialized).sha1($serialized);

// only add arguments that are necessary
$arguments = array($path, $host, $methods, $ips);
$arguments = [$path, $host, $methods, $ips];
while (count($arguments) > 0 && !end($arguments)) {
array_pop($arguments);
}
Expand Down
6 changes: 3 additions & 3 deletions EventListener/ViewResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public function onKernelView(ViewEvent $event): void
public static function getSubscribedEvents(): array
{
// Must be executed before SensioFrameworkExtraBundle's listener
return array(
KernelEvents::VIEW => array('onKernelView', 30),
);
return [
KernelEvents::VIEW => ['onKernelView', 30],
];
}
}
2 changes: 1 addition & 1 deletion EventListener/ZoneMatcherListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class ZoneMatcherListener
{
private $requestMatchers = array();
private $requestMatchers = [];

public function addRequestMatcher(RequestMatcherInterface $requestMatcher)
{
Expand Down
2 changes: 1 addition & 1 deletion Form/Extension/DisableCSRFExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ public function configureOptions(OptionsResolver $resolver): void

public static function getExtendedTypes(): iterable
{
return array(FormType::class);
return [FormType::class];
}
}
4 changes: 2 additions & 2 deletions Negotiation/FormatNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class FormatNegotiator extends BaseNegotiator
private $requestStack;
private $mimeTypes;

public function __construct(RequestStack $requestStack, array $mimeTypes = array())
public function __construct(RequestStack $requestStack, array $mimeTypes = [])
{
$this->requestStack = $requestStack;
$this->mimeTypes = $mimeTypes;
Expand Down Expand Up @@ -118,7 +118,7 @@ private function normalizePriorities(Request $request, array $priorities): array
{
$priorities = $this->sanitize($priorities);

$mimeTypes = array();
$mimeTypes = [];
foreach ($priorities as $priority) {
if (strpos($priority, '/')) {
$mimeTypes[] = $priority;
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/CamelKeysNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function normalize(array $data)

private function normalizeArray(array &$data)
{
$normalizedData = array();
$normalizedData = [];

foreach ($data as $key => $val) {
$normalizedKey = $this->normalizeString($key);
Expand Down
4 changes: 2 additions & 2 deletions Request/ParamFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ private function cleanParamWithRequirements(ParamInterface $param, $paramValue,
$violation = new ConstraintViolation(
$e->getMessage(),
$e->getMessage(),
array(),
[],
$paramValue,
'',
null,
null,
$e->getCode()
);
$errors = new ConstraintViolationList(array($violation));
$errors = new ConstraintViolationList([$violation]);
}

if (0 < count($errors)) {
Expand Down
2 changes: 1 addition & 1 deletion Request/ParamReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getParamsFromClass(\ReflectionClass $class): array
*/
private function getParamsFromAnnotationArray(array $annotations): array
{
$params = array();
$params = [];
foreach ($annotations as $annotation) {
if ($annotation instanceof ParamInterface) {
$params[$annotation->getName()] = $annotation;
Expand Down
6 changes: 3 additions & 3 deletions Request/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
final class ParameterBag
{
private $paramReader;
private $params = array();
private $params = [];

public function __construct(ParamReaderInterface $paramReader)
{
Expand Down Expand Up @@ -54,10 +54,10 @@ public function addParam(Request $request, ParamInterface $param): void
public function setController(Request $request, callable $controller): void
{
$requestId = spl_object_hash($request);
$this->params[$requestId] = array(
$this->params[$requestId] = [
'controller' => $controller,
'params' => null,
);
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Serializer/SymfonySerializerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function deserialize(string $data, string $type, string $format, Context

private function convertContext(Context $context): array
{
$newContext = array();
$newContext = [];
foreach ($context->getAttributes() as $key => $value) {
$newContext[$key] = $value;
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/Context/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testAttributes()

public function testGroupAddition()
{
$this->context->addGroups(array('quz', 'foo'));
$this->context->addGroups(['quz', 'foo']);
$this->context->addGroup('foo');
$this->context->addGroup('bar');

Expand All @@ -60,12 +60,12 @@ public function testGroupAddition()

public function testSetGroups()
{
$this->context->setGroups(array('quz', 'foo'));
$this->context->setGroups(['quz', 'foo']);

$this->assertEquals(array('quz', 'foo'), $this->context->getGroups());
$this->assertEquals(['quz', 'foo'], $this->context->getGroups());

$this->context->setGroups(array('foo'));
$this->assertEquals(array('foo'), $this->context->getGroups());
$this->context->setGroups(['foo']);
$this->assertEquals(['foo'], $this->context->getGroups());
}

public function testAlreadyExistentGroupAddition()
Expand All @@ -74,7 +74,7 @@ public function testAlreadyExistentGroupAddition()
$this->context->addGroup('foo');
$this->context->addGroup('bar');

$this->assertEquals(array('foo', 'bar'), $this->context->getGroups());
$this->assertEquals(['foo', 'bar'], $this->context->getGroups());
}

public function testVersion()
Expand Down
10 changes: 5 additions & 5 deletions Tests/Controller/Annotations/AbstractParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testDefaultValues()
$this->assertNull($this->param->description);
$this->assertFalse($this->param->strict);
$this->assertFalse($this->param->nullable);
$this->assertEquals(array(), $this->param->incompatibles);
$this->assertEquals([], $this->param->incompatibles);
}

public function testNameGetter()
Expand All @@ -67,8 +67,8 @@ public function testDescriptionGetter()

public function testIncompatiblesGetter()
{
$this->param->incompatibles = array('c', 'd');
$this->assertEquals(array('c', 'd'), $this->param->getIncompatibilities());
$this->param->incompatibles = ['c', 'd'];
$this->assertEquals(['c', 'd'], $this->param->getIncompatibilities());
}

public function testStrictGetter()
Expand All @@ -79,9 +79,9 @@ public function testStrictGetter()

public function testNotNullConstraint()
{
$this->assertEquals(array(new NotNull()), $this->param->getConstraints(''));
$this->assertEquals([new NotNull()], $this->param->getConstraints(''));

$this->param->nullable = true;
$this->assertEquals(array(), $this->param->getConstraints());
$this->assertEquals([], $this->param->getConstraints());
}
}
Loading

0 comments on commit dcd7d83

Please sign in to comment.