Skip to content

Commit

Permalink
fixed CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 16, 2019
1 parent af4fef2 commit ae468fe
Show file tree
Hide file tree
Showing 28 changed files with 395 additions and 395 deletions.
10 changes: 5 additions & 5 deletions Encoder/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@
*/
class ChainDecoder implements ContextAwareDecoderInterface
{
protected $decoders = array();
protected $decoderByFormat = array();
protected $decoders = [];
protected $decoderByFormat = [];

public function __construct(array $decoders = array())
public function __construct(array $decoders = [])
{
$this->decoders = $decoders;
}

/**
* {@inheritdoc}
*/
final public function decode($data, $format, array $context = array())
final public function decode($data, $format, array $context = [])
{
return $this->getDecoder($format, $context)->decode($data, $format, $context);
}

/**
* {@inheritdoc}
*/
public function supportsDecoding($format, array $context = array())
public function supportsDecoding($format, array $context = [])
{
try {
$this->getDecoder($format, $context);
Expand Down
12 changes: 6 additions & 6 deletions Encoder/ChainEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@
*/
class ChainEncoder implements ContextAwareEncoderInterface
{
protected $encoders = array();
protected $encoderByFormat = array();
protected $encoders = [];
protected $encoderByFormat = [];

public function __construct(array $encoders = array())
public function __construct(array $encoders = [])
{
$this->encoders = $encoders;
}

/**
* {@inheritdoc}
*/
final public function encode($data, $format, array $context = array())
final public function encode($data, $format, array $context = [])
{
return $this->getEncoder($format, $context)->encode($data, $format, $context);
}

/**
* {@inheritdoc}
*/
public function supportsEncoding($format, array $context = array())
public function supportsEncoding($format, array $context = [])
{
try {
$this->getEncoder($format, $context);
Expand All @@ -62,7 +62,7 @@ public function supportsEncoding($format, array $context = array())
*
* @return bool
*/
public function needsNormalization($format, array $context = array())
public function needsNormalization($format, array $context = [])
{
$encoder = $this->getEncoder($format, $context);

Expand Down
30 changes: 15 additions & 15 deletions Encoder/CsvEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
private $escapeChar;
private $keySeparator;
private $escapeFormulas;
private $formulasStartCharacters = array('=', '-', '+', '@');
private $formulasStartCharacters = ['=', '-', '+', '@'];

public function __construct(string $delimiter = ',', string $enclosure = '"', string $escapeChar = '\\', string $keySeparator = '.', bool $escapeFormulas = false)
{
Expand All @@ -49,20 +49,20 @@ public function __construct(string $delimiter = ',', string $enclosure = '"', st
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array())
public function encode($data, $format, array $context = [])
{
$handle = fopen('php://temp,', 'w+');

if (!\is_array($data)) {
$data = array(array($data));
$data = [[$data]];
} elseif (empty($data)) {
$data = array(array());
$data = [[]];
} else {
// Sequential arrays of arrays are considered as collections
$i = 0;
foreach ($data as $key => $value) {
if ($i !== $key || !\is_array($value)) {
$data = array($data);
$data = [$data];
break;
}

Expand All @@ -73,7 +73,7 @@ public function encode($data, $format, array $context = array())
list($delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas) = $this->getCsvOptions($context);

foreach ($data as &$value) {
$flattened = array();
$flattened = [];
$this->flatten($value, $flattened, $keySeparator, '', $escapeFormulas);
$value = $flattened;
}
Expand Down Expand Up @@ -106,16 +106,16 @@ public function supportsEncoding($format)
/**
* {@inheritdoc}
*/
public function decode($data, $format, array $context = array())
public function decode($data, $format, array $context = [])
{
$handle = fopen('php://temp', 'r+');
fwrite($handle, $data);
rewind($handle);

$headers = null;
$nbHeaders = 0;
$headerCount = array();
$result = array();
$headerCount = [];
$result = [];

list($delimiter, $enclosure, $escapeChar, $keySeparator) = $this->getCsvOptions($context);

Expand All @@ -134,7 +134,7 @@ public function decode($data, $format, array $context = array())
continue;
}

$item = array();
$item = [];
for ($i = 0; ($i < $nbCols) && ($i < $nbHeaders); ++$i) {
$depth = $headerCount[$i];
$arr = &$item;
Expand All @@ -147,7 +147,7 @@ public function decode($data, $format, array $context = array())
}

if (!isset($arr[$headers[$i][$j]])) {
$arr[$headers[$i][$j]] = array();
$arr[$headers[$i][$j]] = [];
}

$arr = &$arr[$headers[$i][$j]];
Expand Down Expand Up @@ -202,23 +202,23 @@ private function getCsvOptions(array $context)
$enclosure = isset($context[self::ENCLOSURE_KEY]) ? $context[self::ENCLOSURE_KEY] : $this->enclosure;
$escapeChar = isset($context[self::ESCAPE_CHAR_KEY]) ? $context[self::ESCAPE_CHAR_KEY] : $this->escapeChar;
$keySeparator = isset($context[self::KEY_SEPARATOR_KEY]) ? $context[self::KEY_SEPARATOR_KEY] : $this->keySeparator;
$headers = isset($context[self::HEADERS_KEY]) ? $context[self::HEADERS_KEY] : array();
$headers = isset($context[self::HEADERS_KEY]) ? $context[self::HEADERS_KEY] : [];
$escapeFormulas = isset($context[self::ESCAPE_FORMULAS_KEY]) ? $context[self::ESCAPE_FORMULAS_KEY] : $this->escapeFormulas;

if (!\is_array($headers)) {
throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, \gettype($headers)));
}

return array($delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas);
return [$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas];
}

/**
* @return string[]
*/
private function extractHeaders(array $data)
{
$headers = array();
$flippedHeaders = array();
$headers = [];
$flippedHeaders = [];

foreach ($data as $row) {
$previousHeader = null;
Expand Down
32 changes: 16 additions & 16 deletions Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
* @param int|null $loadOptions A bit field of LIBXML_* constants
* @param int[] $ignoredNodeTypes an array of ignored XML node types, each one of the DOM Predefined XML_* Constants
*/
public function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $ignoredNodeTypes = array(XML_PI_NODE, XML_COMMENT_NODE))
public function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $ignoredNodeTypes = [XML_PI_NODE, XML_COMMENT_NODE])
{
$this->rootNodeName = $rootNodeName;
$this->loadOptions = null !== $loadOptions ? $loadOptions : LIBXML_NONET | LIBXML_NOBLANKS;
Expand All @@ -55,7 +55,7 @@ public function __construct(string $rootNodeName = 'response', int $loadOptions
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array())
public function encode($data, $format, array $context = [])
{
if ($data instanceof \DOMDocument) {
return $data->saveXML();
Expand All @@ -81,7 +81,7 @@ public function encode($data, $format, array $context = array())
/**
* {@inheritdoc}
*/
public function decode($data, $format, array $context = array())
public function decode($data, $format, array $context = [])
{
if ('' === trim($data)) {
throw new NotEncodableValueException('Invalid XML data, it can not be empty.');
Expand Down Expand Up @@ -117,7 +117,7 @@ public function decode($data, $format, array $context = array())

if ($rootNode->hasChildNodes()) {
$xpath = new \DOMXPath($dom);
$data = array();
$data = [];
foreach ($xpath->query('namespace::*', $dom->documentElement) as $nsNode) {
$data['@'.$nsNode->nodeName] = $nsNode->nodeValue;
}
Expand All @@ -135,7 +135,7 @@ public function decode($data, $format, array $context = array())
return $rootNode->nodeValue;
}

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

foreach ($rootNode->attributes as $attrKey => $attr) {
$data['@'.$attrKey] = $attr->nodeValue;
Expand Down Expand Up @@ -241,7 +241,7 @@ final protected function isElementNameValid(string $name): bool
*
* @return array|string
*/
private function parseXml(\DOMNode $node, array $context = array())
private function parseXml(\DOMNode $node, array $context = [])
{
$data = $this->parseXmlAttributes($node, $context);

Expand Down Expand Up @@ -273,13 +273,13 @@ private function parseXml(\DOMNode $node, array $context = array())
/**
* Parse the input DOMNode attributes into an array.
*/
private function parseXmlAttributes(\DOMNode $node, array $context = array()): array
private function parseXmlAttributes(\DOMNode $node, array $context = []): array
{
if (!$node->hasAttributes()) {
return array();
return [];
}

$data = array();
$data = [];
$typeCastAttributes = $this->resolveXmlTypeCastAttributes($context);

foreach ($node->attributes as $attr) {
Expand All @@ -306,17 +306,17 @@ private function parseXmlAttributes(\DOMNode $node, array $context = array()): a
*
* @return array|string
*/
private function parseXmlValue(\DOMNode $node, array $context = array())
private function parseXmlValue(\DOMNode $node, array $context = [])
{
if (!$node->hasChildNodes()) {
return $node->nodeValue;
}

if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, array(XML_TEXT_NODE, XML_CDATA_SECTION_NODE))) {
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [XML_TEXT_NODE, XML_CDATA_SECTION_NODE])) {
return $node->firstChild->nodeValue;
}

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

foreach ($node->childNodes as $subnode) {
if (\in_array($subnode->nodeType, $this->ignoredNodeTypes, true)) {
Expand Down Expand Up @@ -471,7 +471,7 @@ private function selectNodeType(\DOMNode $node, $val): bool
/**
* Get real XML root node name, taking serializer options into account.
*/
private function resolveXmlRootName(array $context = array()): string
private function resolveXmlRootName(array $context = []): string
{
return isset($context['xml_root_node_name'])
? $context['xml_root_node_name']
Expand All @@ -481,7 +481,7 @@ private function resolveXmlRootName(array $context = array()): string
/**
* Get XML option for type casting attributes Defaults to true.
*/
private function resolveXmlTypeCastAttributes(array $context = array()): bool
private function resolveXmlTypeCastAttributes(array $context = []): bool
{
return isset($context['xml_type_cast_attributes'])
? (bool) $context['xml_type_cast_attributes']
Expand All @@ -496,7 +496,7 @@ private function createDomDocument(array $context): \DOMDocument
$document = new \DOMDocument();

// Set an attribute on the DOM document specifying, as part of the XML declaration,
$xmlOptions = array(
$xmlOptions = [
// nicely formats output with indentation and extra space
'xml_format_output' => 'formatOutput',
// the version number of the document
Expand All @@ -505,7 +505,7 @@ private function createDomDocument(array $context): \DOMDocument
'xml_encoding' => 'encoding',
// whether the document is standalone
'xml_standalone' => 'xmlStandalone',
);
];
foreach ($xmlOptions as $xmlOption => $documentProperty) {
if (isset($context[$xmlOption])) {
$document->$documentProperty = $context[$xmlOption];
Expand Down
2 changes: 1 addition & 1 deletion Mapping/ClassDiscriminatorFromClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ClassDiscriminatorFromClassMetadata implements ClassDiscriminatorResolverI
* @var ClassMetadataFactoryInterface
*/
private $classMetadataFactory;
private $mappingForMappedObjectCache = array();
private $mappingForMappedObjectCache = [];

public function __construct(ClassMetadataFactoryInterface $classMetadataFactory)
{
Expand Down
2 changes: 1 addition & 1 deletion Mapping/ClassDiscriminatorMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ClassDiscriminatorMapping
private $typeProperty;
private $typesMapping;

public function __construct(string $typeProperty, array $typesMapping = array())
public function __construct(string $typeProperty, array $typesMapping = [])
{
$this->typeProperty = $typeProperty;
$this->typesMapping = $typesMapping;
Expand Down
6 changes: 3 additions & 3 deletions Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ClassMetadata implements ClassMetadataInterface
* class' serialized representation. Do not access it. Use
* {@link getAttributesMetadata()} instead.
*/
public $attributesMetadata = array();
public $attributesMetadata = [];

/**
* @var \ReflectionClass
Expand Down Expand Up @@ -133,10 +133,10 @@ public function setClassDiscriminatorMapping(ClassDiscriminatorMapping $mapping
*/
public function __sleep()
{
return array(
return [
'name',
'attributesMetadata',
'classDiscriminatorMapping',
);
];
}
}
2 changes: 1 addition & 1 deletion Mapping/Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata)
}

if (isset($xml->{'discriminator-map'})) {
$mapping = array();
$mapping = [];
foreach ($xml->{'discriminator-map'}->mapping as $element) {
$elementAttributes = $element->attributes();
$mapping[(string) $elementAttributes->type] = (string) $elementAttributes->class;
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
// Don't run set for a parameter passed to the constructor
$params[] = $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $context, $format);
unset($data[$key]);
} elseif (array_key_exists($key, $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? array())) {
} elseif (array_key_exists($key, $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? [])) {
$params[] = $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
} elseif ($constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
Expand Down

0 comments on commit ae468fe

Please sign in to comment.