Skip to content

Commit

Permalink
Fix CS using php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Apr 30, 2019
1 parent d46a200 commit 2240dda
Show file tree
Hide file tree
Showing 43 changed files with 901 additions and 899 deletions.
24 changes: 12 additions & 12 deletions bundle/Command/ConvertXmlTextToRichTextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ protected function baseExecute(InputInterface $input, OutputInterface $output, &
$this->imageContentTypeIdentifiers = ['image'];
}
$imageContentTypeIds = $this->gateway->getContentTypeIds($this->imageContentTypeIdentifiers);
if (count($imageContentTypeIds) !== count($this->imageContentTypeIdentifiers)) {
if (\count($imageContentTypeIds) !== \count($this->imageContentTypeIdentifiers)) {
throw new RuntimeException('Unable to lookup all content type identifiers, not found: ' . implode(',', array_diff($this->imageContentTypeIdentifiers, array_keys($imageContentTypeIds))));
}
$this->converter->setImageContentTypes($imageContentTypeIds);
}

protected function getCustomTagLogFileName()
{
return $this->kernelCacheDir . DIRECTORY_SEPARATOR . 'customtags.log';
return $this->kernelCacheDir . \DIRECTORY_SEPARATOR . 'customtags.log';
}

protected function createCustomTagLog()
Expand All @@ -297,14 +297,14 @@ protected function createCustomTagLog()
protected function writeCustomTagLog()
{
$customTagLog = $this->converter->getCustomTagLog();
if (count($customTagLog[RichTextConverter::INLINE_CUSTOM_TAG]) > 0) {
if (\count($customTagLog[RichTextConverter::INLINE_CUSTOM_TAG]) > 0) {
file_put_contents(
$this->getCustomTagLogFileName(),
RichTextConverter::INLINE_CUSTOM_TAG . ':' . implode(',', $customTagLog[RichTextConverter::INLINE_CUSTOM_TAG]) . PHP_EOL,
FILE_APPEND
);
}
if (count($customTagLog[RichTextConverter::BLOCK_CUSTOM_TAG]) > 0) {
if (\count($customTagLog[RichTextConverter::BLOCK_CUSTOM_TAG]) > 0) {
file_put_contents($this->getCustomTagLogFileName(),
RichTextConverter::BLOCK_CUSTOM_TAG . ':' . implode(',', $customTagLog[RichTextConverter::BLOCK_CUSTOM_TAG]) . PHP_EOL,
FILE_APPEND
Expand Down Expand Up @@ -350,13 +350,13 @@ protected function reportCustomTags(InputInterface $input, OutputInterface $outp
$io->text('Below are the list of custom tags found during conversion of ezxmltext fields');
$io->section('Inline custom tags');
$io->listing($inlines);
if (count($inlines) === 0) {
if (\count($inlines) === 0) {
$io->text('No inline custom tags converted');
}

$io->section('Block custom tags');
$io->listing($blocks);
if (count($blocks) === 0) {
if (\count($blocks) === 0) {
$io->text('No block custom tags converted');
}
}
Expand Down Expand Up @@ -487,7 +487,7 @@ protected function waitForAvailableProcessSlot(OutputInterface $output)

protected function processSlotAvailable()
{
return count($this->processes) < $this->maxConcurrency;
return \count($this->processes) < $this->maxConcurrency;
}

protected function waitForChild(OutputInterface $output)
Expand Down Expand Up @@ -584,21 +584,21 @@ private function getPhpPath()

protected function dumpOnErrors($errors, $dataText, $contentobjectId, $contentobjectAttribute, $version, $languageCode)
{
if (($this->exportDir !== '') && (count($errors) > 0)) {
if (($this->exportDir !== '') && (\count($errors) > 0)) {
$filterMatch = false;
$filename = $this->exportDir . DIRECTORY_SEPARATOR . "ezxmltext_${contentobjectId}_${contentobjectAttribute}_${version}_${languageCode}";
$filename = $this->exportDir . \DIRECTORY_SEPARATOR . "ezxmltext_${contentobjectId}_${contentobjectAttribute}_${version}_${languageCode}";

// Write error log
foreach ($errors as $logLevel => $logErrors) {
if (!in_array($logLevel, $this->exportDirFilter)) {
if (!\in_array($logLevel, $this->exportDirFilter)) {
continue;
}
$fileFlag = $filterMatch ? FILE_APPEND : 0;
$filterMatch = true;
foreach ($logErrors as $logError) {
$message = $logError['message'];
file_put_contents("$filename.log", "$logLevel: $message\n", $fileFlag);
if (array_key_exists('errors', $logError['context'])) {
if (\array_key_exists('errors', $logError['context'])) {
foreach ($logError['context']['errors'] as $contextError) {
file_put_contents("$filename.log", "- context : $contextError\n", FILE_APPEND);
}
Expand Down Expand Up @@ -711,7 +711,7 @@ protected function processFields($dryRun, $checkDuplicateIds, $checkIdValues, Ou
$offset += $objectsPerChild;
} while ($offset <= $count);

while (count($this->processes) > 0) {
while (\count($this->processes) > 0) {
$this->waitForChild($output);
$this->progressBarAdvance($objectsPerChild);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use eZ\Publish\Core\FieldType\XmlText\Value;

class ConvertXmlTextToRichTextCommandSubProcess extends ConvertXmlTextToRichTextCommand
{
Expand Down
10 changes: 5 additions & 5 deletions bundle/Command/ImportXmlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->imageContentTypeIdentifiers = ['image'];
}
$imageContentTypeIds = $this->gateway->getContentTypeIds($this->imageContentTypeIdentifiers);
if (count($imageContentTypeIds) !== count($this->imageContentTypeIdentifiers)) {
if (\count($imageContentTypeIds) !== \count($this->imageContentTypeIdentifiers)) {
throw new RuntimeException('Unable to lookup all content type identifiers, not found : ' . implode(',', array_diff($this->imageContentTypeIdentifiers, array_keys($imageContentTypeIds))));
}
$this->converter->setImageContentTypes($imageContentTypeIds);
Expand All @@ -132,7 +132,7 @@ protected function importDumps($dryRun)
if ($dirItem->isFile() && $dirItem->getExtension() === 'xml') {
$fileNameArray = explode('_', $dirItem->getBasename('.xml'));
if (
count($fileNameArray) !== 5 ||
\count($fileNameArray) !== 5 ||
$fileNameArray[0] !== 'ezxmltext' ||
!is_numeric($fileNameArray[1]) ||
!is_numeric($fileNameArray[2]) ||
Expand All @@ -146,7 +146,7 @@ protected function importDumps($dryRun)
$attributeId = $fileNameArray[2];
$version = $fileNameArray[3];
$language = $fileNameArray[4];
$filename = $this->exportDir . DIRECTORY_SEPARATOR . $dirItem->getFilename();
$filename = $this->exportDir . \DIRECTORY_SEPARATOR . $dirItem->getFilename();

if ($this->contentObjectId !== null && $this->contentObjectId !== $objectId) {
continue;
Expand All @@ -169,7 +169,7 @@ protected function validateConversion(DOMDocument $xmlDoc, $filename, $attribute
$result = false;

if (!empty($errors)) {
if (array_key_exists(LogLevel::ERROR, $errors)) {
if (\array_key_exists(LogLevel::ERROR, $errors)) {
$this->output->writeln("Error: Validation errors when trying to convert ezxmltext in file $filename to richtext, skipping :");
} else {
$this->output->writeln("Warning: Issues found when trying to convert ezxmltext in file $filename to richtext:");
Expand All @@ -178,7 +178,7 @@ protected function validateConversion(DOMDocument $xmlDoc, $filename, $attribute
foreach ($errors as $logLevel => $logErrors) {
foreach ($logErrors as $logError) {
$this->output->writeln("- $logLevel: " . $logError['message']);
if (array_key_exists('errors', $logError['context'])) {
if (\array_key_exists('errors', $logError['context'])) {
foreach ($logError['context']['errors'] as $contextError) {
$this->output->writeln(' - context: ' . $contextError);
}
Expand Down
4 changes: 2 additions & 2 deletions bundle/Converter/Html5.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
class Html5 extends BaseHtml5Converter
{
public function __construct($stylesheet, ConfigResolverInterface $configResolver, array $preConverters = array())
public function __construct($stylesheet, ConfigResolverInterface $configResolver, array $preConverters = [])
{
$customStylesheets = $configResolver->getParameter('fieldtypes.ezxml.custom_xsl');
$customStylesheets = $customStylesheets ?: array();
$customStylesheets = $customStylesheets ?: [];
parent::__construct($stylesheet, $customStylesheets, $preConverters);
}
}
6 changes: 3 additions & 3 deletions bundle/DependencyInjection/Compiler/XmlTextConverterPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function process(ContainerBuilder $container)
$html5ConverterDef = $container->getDefinition('ezpublish.fieldType.ezxmltext.converter.html5');
$taggedServiceIds = $container->findTaggedServiceIds('ezpublish.ezxml.converter');

$converterIdsByPriority = array();
$converterIdsByPriority = [];
foreach ($taggedServiceIds as $id => $tags) {
foreach ($tags as $tag) {
$priority = isset($tag['priority']) ? (int)$tag['priority'] : 0;
Expand All @@ -40,7 +40,7 @@ public function process(ContainerBuilder $container)
$converterIdsByPriority = $this->sortConverterIds($converterIdsByPriority);

foreach ($converterIdsByPriority as $referenceId) {
$html5ConverterDef->addMethodCall('addPreConverter', array(new Reference($referenceId)));
$html5ConverterDef->addMethodCall('addPreConverter', [new Reference($referenceId)]);
}
}

Expand All @@ -56,6 +56,6 @@ protected function sortConverterIds(array $converterIdsByPriority)
{
krsort($converterIdsByPriority, SORT_NUMERIC);

return call_user_func_array('array_merge', $converterIdsByPriority);
return \call_user_func_array('array_merge', $converterIdsByPriority);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function addFieldTypeSemanticConfig(NodeBuilder $nodeBuilder)
->arrayNode('custom_tags')
->info('Custom XSL stylesheets to use for XmlText transformation to HTML5. Useful for "custom tags".')
->example(
array(
[
'path' => '%kernel.root_dir%/../src/Acme/TestBundle/Resources/myTag.xsl',
'priority' => 10,
)
]
)
->prototype('array')
->children()
Expand Down
8 changes: 4 additions & 4 deletions bundle/Templating/Twig/Extension/XmlTextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public function getName()

public function getFilters()
{
return array(
return [
new Twig_SimpleFilter(
'xmltext_to_html5',
array($this, 'xmlTextToHtml5'),
array('is_safe' => array('html'))
[$this, 'xmlTextToHtml5'],
['is_safe' => ['html']]
),
);
];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/FieldType/XmlText/Converter/EmbedLinking.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function convert(DOMDocument $document)

$linkedEmbeds = $xpath->query($xpathExpression);

$collection = array();
$collection = [];
foreach ($linkedEmbeds as $embed) {
$collection[] = $embed;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ protected function unwrap(DOMElement $embed)
/** @var \DOMText|\DOMElement $node */
foreach ($link->childNodes as $node) {
if (!($node->nodeType === XML_TEXT_NODE && $node->isWhitespaceInElementContent())) {
$childCount += 1;
++$childCount;
}
}

Expand Down
32 changes: 16 additions & 16 deletions lib/FieldType/XmlText/Converter/EmbedToHtml5.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class EmbedToHtml5 implements Converter
*
* @var array
*/
protected $excludedAttributes = array();
protected $excludedAttributes = [];

/**
* @var \Symfony\Component\HttpKernel\Fragment\FragmentHandler
Expand Down Expand Up @@ -102,7 +102,7 @@ protected function processTag(DOMDocument $xmlDoc, $tagName)
try {
/** @var \eZ\Publish\API\Repository\Values\Content\Content $content */
$content = $this->repository->sudo(
function (Repository $repository) use ($contentId) {
static function (Repository $repository) use ($contentId) {
return $repository->getContentService()->loadContent($contentId);
}
);
Expand All @@ -111,26 +111,26 @@ function (Repository $repository) use ($contentId) {
!$this->repository->canUser('content', 'read', $content)
&& !$this->repository->canUser('content', 'view_embed', $content)
) {
throw new UnauthorizedException('content', 'read', array('contentId' => $contentId));
throw new UnauthorizedException('content', 'read', ['contentId' => $contentId]);
}

// Check published status of the Content
if (
$content->getVersionInfo()->status !== APIVersionInfo::STATUS_PUBLISHED
&& !$this->repository->canUser('content', 'versionread', $content)
) {
throw new UnauthorizedException('content', 'versionread', array('contentId' => $contentId));
throw new UnauthorizedException('content', 'versionread', ['contentId' => $contentId]);
}

$embedContent = $this->fragmentHandler->render(
new ControllerReference(
'ez_content:embedAction',
array(
[
'contentId' => $contentId,
'viewType' => $view,
'layout' => false,
'params' => $parameters,
)
]
)
);
} catch (APINotFoundException $e) {
Expand All @@ -145,7 +145,7 @@ function (Repository $repository) use ($contentId) {
try {
/** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
$location = $this->repository->sudo(
function (Repository $repository) use ($locationId) {
static function (Repository $repository) use ($locationId) {
return $repository->getLocationService()->loadLocation($locationId);
}
);
Expand All @@ -154,19 +154,19 @@ function (Repository $repository) use ($locationId) {
!$this->repository->canUser('content', 'read', $location->getContentInfo(), $location)
&& !$this->repository->canUser('content', 'view_embed', $location->getContentInfo(), $location)
) {
throw new UnauthorizedException('content', 'read', array('locationId' => $location->id));
throw new UnauthorizedException('content', 'read', ['locationId' => $location->id]);
}

$embedContent = $this->fragmentHandler->render(
new ControllerReference(
'ez_content:embedAction',
array(
[
'contentId' => $location->getContentInfo()->id,
'locationId' => $location->id,
'viewType' => $view,
'layout' => false,
'params' => $parameters,
)
]
)
);
} catch (APINotFoundException $e) {
Expand Down Expand Up @@ -200,10 +200,10 @@ function (Repository $repository) use ($locationId) {
*/
protected function getParameters(DOMElement $embed)
{
$parameters = array(
$parameters = [
'noLayout' => true,
'objectParameters' => array(),
);
'objectParameters' => [],
];

$linkParameters = $this->getLinkParameters($embed);

Expand Down Expand Up @@ -254,12 +254,12 @@ protected function getLinkParameters(DOMElement $embed)
$resourceId = $embed->getAttribute(EmbedLinking::TEMP_PREFIX . 'node_id');
}

$parameters = array(
$parameters = [
'href' => $embed->getAttribute('url'),
'resourceType' => $resourceType,
'resourceId' => $resourceId,
'wrapped' => $this->isLinkWrapped($embed),
);
];

if (!empty($resourceFragmentIdentifier)) {
$parameters['resourceFragmentIdentifier'] = $resourceFragmentIdentifier;
Expand Down Expand Up @@ -305,7 +305,7 @@ protected function isLinkWrapped(DOMElement $element)
/** @var \DOMText|\DOMElement $node */
foreach ($parentNode->childNodes as $node) {
if (!($node->nodeType === XML_TEXT_NODE && $node->isWhitespaceInElementContent())) {
$childCount += 1;
++$childCount;
}
}

Expand Down
20 changes: 10 additions & 10 deletions lib/FieldType/XmlText/Converter/Expanding.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class Expanding implements Converter
*
* @var array
*/
protected $containmentMap = array(
'embed' => array(
protected $containmentMap = [
'embed' => [
'link' => true,
),
'table' => array(),
'ul' => array(),
'ol' => array(),
'literal' => array(),
);
],
'table' => [],
'ul' => [],
'ol' => [],
'literal' => [],
];

public function convert(DOMDocument $document)
{
Expand All @@ -67,7 +67,7 @@ public function convert(DOMDocument $document)

$paragraphs = $xpath->query($xpathExpression);

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

foreach ($paragraphs as $paragraph) {
$paragraphsDepthSorted[$this->getNodeDepth($paragraph)][] = $paragraph;
Expand Down Expand Up @@ -352,7 +352,7 @@ protected function cloneAndEmpty(DOMElement $element)
{
$clone = $element->cloneNode(true);

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

// Collect child nodes first, as we can't iterate and
// remove from \DOMNodeList directly
Expand Down
Loading

0 comments on commit 2240dda

Please sign in to comment.