diff --git a/bundle/Command/ConvertXmlTextToRichTextCommand.php b/bundle/Command/ConvertXmlTextToRichTextCommand.php index eacd95bc..2ba4ecb5 100644 --- a/bundle/Command/ConvertXmlTextToRichTextCommand.php +++ b/bundle/Command/ConvertXmlTextToRichTextCommand.php @@ -277,7 +277,7 @@ 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); @@ -285,7 +285,7 @@ protected function baseExecute(InputInterface $input, OutputInterface $output, & protected function getCustomTagLogFileName() { - return $this->kernelCacheDir . DIRECTORY_SEPARATOR . 'customtags.log'; + return $this->kernelCacheDir . \DIRECTORY_SEPARATOR . 'customtags.log'; } protected function createCustomTagLog() @@ -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 @@ -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'); } } @@ -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) @@ -584,13 +584,13 @@ 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; @@ -598,7 +598,7 @@ protected function dumpOnErrors($errors, $dataText, $contentobjectId, $contentob 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); } @@ -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); } diff --git a/bundle/Command/ConvertXmlTextToRichTextCommandSubProcess.php b/bundle/Command/ConvertXmlTextToRichTextCommandSubProcess.php index 8c3ab992..92b4c686 100644 --- a/bundle/Command/ConvertXmlTextToRichTextCommandSubProcess.php +++ b/bundle/Command/ConvertXmlTextToRichTextCommandSubProcess.php @@ -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 { diff --git a/bundle/Command/ImportXmlCommand.php b/bundle/Command/ImportXmlCommand.php index 0df3e10c..20b879f3 100644 --- a/bundle/Command/ImportXmlCommand.php +++ b/bundle/Command/ImportXmlCommand.php @@ -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); @@ -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]) || @@ -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; @@ -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:"); @@ -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); } diff --git a/bundle/Converter/Html5.php b/bundle/Converter/Html5.php index 1d2efca5..d81c5ff6 100644 --- a/bundle/Converter/Html5.php +++ b/bundle/Converter/Html5.php @@ -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); } } diff --git a/bundle/DependencyInjection/Compiler/XmlTextConverterPass.php b/bundle/DependencyInjection/Compiler/XmlTextConverterPass.php index 85fe2ae0..71ae41f3 100644 --- a/bundle/DependencyInjection/Compiler/XmlTextConverterPass.php +++ b/bundle/DependencyInjection/Compiler/XmlTextConverterPass.php @@ -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; @@ -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)]); } } @@ -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); } } diff --git a/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlText.php b/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlText.php index 9d64a3cc..67ecffcf 100644 --- a/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlText.php +++ b/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlText.php @@ -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() diff --git a/bundle/Templating/Twig/Extension/XmlTextExtension.php b/bundle/Templating/Twig/Extension/XmlTextExtension.php index ca7fbd36..7f62fd9b 100644 --- a/bundle/Templating/Twig/Extension/XmlTextExtension.php +++ b/bundle/Templating/Twig/Extension/XmlTextExtension.php @@ -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']] ), - ); + ]; } /** diff --git a/lib/FieldType/XmlText/Converter/EmbedLinking.php b/lib/FieldType/XmlText/Converter/EmbedLinking.php index 21c42f88..6603add5 100644 --- a/lib/FieldType/XmlText/Converter/EmbedLinking.php +++ b/lib/FieldType/XmlText/Converter/EmbedLinking.php @@ -37,7 +37,7 @@ public function convert(DOMDocument $document) $linkedEmbeds = $xpath->query($xpathExpression); - $collection = array(); + $collection = []; foreach ($linkedEmbeds as $embed) { $collection[] = $embed; } @@ -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; } } diff --git a/lib/FieldType/XmlText/Converter/EmbedToHtml5.php b/lib/FieldType/XmlText/Converter/EmbedToHtml5.php index a6c23e0a..02a42447 100644 --- a/lib/FieldType/XmlText/Converter/EmbedToHtml5.php +++ b/lib/FieldType/XmlText/Converter/EmbedToHtml5.php @@ -52,7 +52,7 @@ class EmbedToHtml5 implements Converter * * @var array */ - protected $excludedAttributes = array(); + protected $excludedAttributes = []; /** * @var \Symfony\Component\HttpKernel\Fragment\FragmentHandler @@ -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); } ); @@ -111,7 +111,7 @@ 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 @@ -119,18 +119,18 @@ function (Repository $repository) use ($contentId) { $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) { @@ -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); } ); @@ -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) { @@ -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); @@ -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; @@ -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; } } diff --git a/lib/FieldType/XmlText/Converter/Expanding.php b/lib/FieldType/XmlText/Converter/Expanding.php index 852b5466..d17e8067 100644 --- a/lib/FieldType/XmlText/Converter/Expanding.php +++ b/lib/FieldType/XmlText/Converter/Expanding.php @@ -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) { @@ -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; @@ -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 diff --git a/lib/FieldType/XmlText/Converter/ExpandingList.php b/lib/FieldType/XmlText/Converter/ExpandingList.php index b3e98a1d..5f7d682c 100644 --- a/lib/FieldType/XmlText/Converter/ExpandingList.php +++ b/lib/FieldType/XmlText/Converter/ExpandingList.php @@ -42,10 +42,10 @@ */ class ExpandingList extends ExpandingToRichText { - protected $containmentMap = array( - 'ul' => array(), - 'ol' => array(), - ); + protected $containmentMap = [ + 'ul' => [], + 'ol' => [], + ]; protected function isTemporary(DOMElement $paragraph) { diff --git a/lib/FieldType/XmlText/Converter/ExpandingToRichText.php b/lib/FieldType/XmlText/Converter/ExpandingToRichText.php index 1c4c7114..327780f0 100644 --- a/lib/FieldType/XmlText/Converter/ExpandingToRichText.php +++ b/lib/FieldType/XmlText/Converter/ExpandingToRichText.php @@ -26,14 +26,14 @@ class ExpandingToRichText extends Expanding * * @var array */ - protected $containmentMap = array( - 'embed' => array( + protected $containmentMap = [ + 'embed' => [ 'link' => true, - ), - 'table' => array(), - 'literal' => array(), - 'header' => array(), - ); + ], + 'table' => [], + 'literal' => [], + 'header' => [], + ]; /** * Checks whether a paragraph can be considered as temporary and can then be diff --git a/lib/FieldType/XmlText/Converter/Html5.php b/lib/FieldType/XmlText/Converter/Html5.php index 1081d522..fea5e95e 100644 --- a/lib/FieldType/XmlText/Converter/Html5.php +++ b/lib/FieldType/XmlText/Converter/Html5.php @@ -33,7 +33,7 @@ class Html5 implements Converter * * @var array */ - protected $customStylesheets = array(); + protected $customStylesheets = []; /** * @var \XSLTProcessor @@ -56,7 +56,7 @@ class Html5 implements Converter * * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType */ - public function __construct($stylesheet, array $customStylesheets = array(), array $preConverters = array()) + public function __construct($stylesheet, array $customStylesheets = [], array $preConverters = []) { $this->stylesheet = $stylesheet; $this->setCustomStylesheets($customStylesheets); @@ -88,7 +88,7 @@ public function setCustomStylesheets($customStylesheets) } foreach ($customStylesheets as $stylesheet) { if (!isset($this->customStylesheets[$stylesheet['priority']])) { - $this->customStylesheets[$stylesheet['priority']] = array(); + $this->customStylesheets[$stylesheet['priority']] = []; } $this->customStylesheets[$stylesheet['priority']][] = $stylesheet['path']; @@ -161,7 +161,7 @@ protected function getXSLTProcessor() */ private function getSortedCustomStylesheets() { - $sortedStylesheets = array(); + $sortedStylesheets = []; ksort($this->customStylesheets); foreach ($this->customStylesheets as $stylesheets) { $sortedStylesheets = array_merge($sortedStylesheets, $stylesheets); diff --git a/lib/FieldType/XmlText/Converter/RichText.php b/lib/FieldType/XmlText/Converter/RichText.php index 1543da3e..cb5f16a1 100644 --- a/lib/FieldType/XmlText/Converter/RichText.php +++ b/lib/FieldType/XmlText/Converter/RichText.php @@ -172,7 +172,7 @@ protected function reportNonUniqueIds(DOMDocument $document, $contentFieldId) foreach ($nodes as $node) { $id = $node->attributes->getNamedItem('id')->nodeValue; // id has format "duplicated_id_foo_bar_idm45226413447104" where "foo_bar" is the duplicated id - $duplicatedId = substr($id, strlen('duplicated_id_'), strrpos($id, '_') - strlen('duplicated_id_')); + $duplicatedId = substr($id, \strlen('duplicated_id_'), strrpos($id, '_') - \strlen('duplicated_id_')); $this->log(LogLevel::WARNING, "Duplicated id in original ezxmltext for contentobject_attribute.id=$contentFieldId, automatically generated new id : $duplicatedId --> $id"); } } @@ -217,7 +217,7 @@ protected function validateAttributeValues(DOMDocument $document, $contentFieldI /** * @param $id * @param bool $isContentId Whatever provided $id is a content id or location id - * @param null|int $contentFieldId + * @param int|null $contentFieldId * @return bool */ protected function isImageContentType($id, $isContentId, $contentFieldId) @@ -251,7 +251,7 @@ protected function isImageContentType($id, $isContentId, $contentFieldId) return false; } - return in_array($contentInfo->contentTypeId, $this->imageContentTypes); + return \in_array($contentInfo->contentTypeId, $this->imageContentTypes); } /** @@ -302,7 +302,7 @@ private function removeXhtmlClassValue(DOMNode $node, $value) } if ($classNameFound) { - if (count($attributes) === 0) { + if (\count($attributes) === 0) { $node->removeAttribute('ezxhtml:class'); } else { $classAttributes->value = implode(' ', $attributes); @@ -319,7 +319,7 @@ private function removeXhtmlClassValue(DOMNode $node, $value) * being embedded in the $richtextDocument. * * @param DOMDocument $richtextDocument - * @param null|int $contentFieldId + * @param int|null $contentFieldId * @return int Number of ezembed tags which where changed */ public function tagEmbeddedImages(DOMDocument $richtextDocument, $contentFieldId) @@ -352,7 +352,7 @@ public function tagEmbeddedImages(DOMDocument $richtextDocument, $contentFieldId /** * Check if $inputDocument has any embed|embed-inline tags without node_id or object_id. * @param DOMDocument $inputDocument - * @param null|int $contentFieldId + * @param int|null $contentFieldId */ protected function checkEmptyEmbedTags(DOMDocument $inputDocument, $contentFieldId) { @@ -370,7 +370,7 @@ protected function checkEmptyEmbedTags(DOMDocument $inputDocument, $contentField * being linked to in the $document. * @param DOMDocument $document - * @param null|int $contentFieldId + * @param int|null $contentFieldId */ protected function fixLinksWithRemoteIds(DOMDocument $document, $contentFieldId) { @@ -417,7 +417,7 @@ protected function fixLinksWithRemoteIds(DOMDocument $document, $contentFieldId) * ezxmltext may contain link elements below another link element. This method flattens such structure. * * @param DOMDocument $document - * @param null|int $contentFieldId + * @param int|null $contentFieldId */ protected function flattenLinksInLinks(DOMDocument $document, $contentFieldId) { @@ -479,7 +479,7 @@ protected function moveEmbedsInHeaders(DOMDocument $document, $contentFieldId) * Those needs to be removed as we use ez-temporary for internal housekeeping. * * @param DOMDocument $document - * @param null|int $contentFieldId + * @param int|null $contentFieldId */ protected function removeEzTemporaryAttributes(DOMDocument $document, $contentFieldId) { @@ -522,7 +522,7 @@ public function getErrors() /** * @param DOMDocument $document - * @param null|int $contentFieldId + * @param int|null $contentFieldId */ protected function writeWarningOnNonSupportedCustomTags(DOMDocument $document, $contentFieldId) { @@ -538,7 +538,7 @@ protected function writeWarningOnNonSupportedCustomTags(DOMDocument $document, $ $blockCustomTag = ($parent->localName === 'paragraph' && $parent->hasAttribute('ez-temporary')) || $parent->localName === 'section'; // These legacy custom tags are not custom tags in richtext - if (in_array($customTagName, ['quote', 'underline', 'strike', 'sub', 'sup'])) { + if (\in_array($customTagName, ['quote', 'underline', 'strike', 'sub', 'sup'])) { continue; } @@ -579,7 +579,7 @@ protected function encodeLiteral(DOMDocument $document) * @param DOMDocument $inputDocument * @param bool $checkDuplicateIds * @param bool $checkIdValues - * @param null|int $contentFieldId + * @param int|null $contentFieldId * @return string * @throws \Exception */ diff --git a/lib/FieldType/XmlText/FormMapper.php b/lib/FieldType/XmlText/FormMapper.php index 7d7405aa..685e0b57 100644 --- a/lib/FieldType/XmlText/FormMapper.php +++ b/lib/FieldType/XmlText/FormMapper.php @@ -16,10 +16,10 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) ->create( 'value', FormType::class, - array( + [ 'required' => $data->fieldDefinition->isRequired, 'label' => $data->fieldDefinition->getName(), - ) + ] ) ->setAutoInitialize(false) ->getForm() diff --git a/lib/FieldType/XmlText/FormType.php b/lib/FieldType/XmlText/FormType.php index 0e243935..8f87a58a 100644 --- a/lib/FieldType/XmlText/FormType.php +++ b/lib/FieldType/XmlText/FormType.php @@ -23,7 +23,7 @@ public function __construct(FieldTypeService $fieldTypeService) public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('xml', TextareaType::class, array('attr' => array('rows' => 10))) + ->add('xml', TextareaType::class, ['attr' => ['rows' => 10]]) ->addModelTransformer( new FieldValueTransformer( $this->fieldTypeService->getFieldType('ezxmltext') diff --git a/lib/FieldType/XmlText/Input/EzXml.php b/lib/FieldType/XmlText/Input/EzXml.php index e4ff22b3..19696616 100644 --- a/lib/FieldType/XmlText/Input/EzXml.php +++ b/lib/FieldType/XmlText/Input/EzXml.php @@ -42,7 +42,7 @@ public function __construct($xmlString, $schemaPath = null) libxml_clear_errors(); $doc->loadXML($xmlString); if (!$doc->schemaValidate($schemaPath)) { - $messages = array(); + $messages = []; foreach (libxml_get_errors() as $error) { $messages[] = trim($error->message); diff --git a/lib/FieldType/XmlText/InternalLinkValidator.php b/lib/FieldType/XmlText/InternalLinkValidator.php index 2b2949fb..0d2ff799 100644 --- a/lib/FieldType/XmlText/InternalLinkValidator.php +++ b/lib/FieldType/XmlText/InternalLinkValidator.php @@ -109,7 +109,7 @@ protected function validateEzNode($nodeId) * * @param string $scheme * @param string $target - * @param null|string $anchorName + * @param string|null $anchorName * @return string */ protected function getInvalidLinkError($scheme, $target, $anchorName = null) diff --git a/lib/FieldType/XmlText/Persistence/Legacy/ContentModelGateway.php b/lib/FieldType/XmlText/Persistence/Legacy/ContentModelGateway.php index b1169fcf..a1effb0f 100644 --- a/lib/FieldType/XmlText/Persistence/Legacy/ContentModelGateway.php +++ b/lib/FieldType/XmlText/Persistence/Legacy/ContentModelGateway.php @@ -99,7 +99,7 @@ public function getContentTypeFieldTypeUpdateQuery($fromFieldTypeIdentifier, $to */ public function getRowCountOfContentObjectAttributes($datatypes, $contentId) { - if (!is_array($datatypes)) { + if (!\is_array($datatypes)) { $datatypes = [$datatypes]; } @@ -140,7 +140,7 @@ public function getRowCountOfContentObjectAttributes($datatypes, $contentId) */ public function getFieldRows($datatypes, $contentId, $offset, $limit) { - if (!is_array($datatypes)) { + if (!\is_array($datatypes)) { $datatypes = [$datatypes]; } diff --git a/lib/FieldType/XmlText/SearchField.php b/lib/FieldType/XmlText/SearchField.php index cecf23ae..c8537347 100644 --- a/lib/FieldType/XmlText/SearchField.php +++ b/lib/FieldType/XmlText/SearchField.php @@ -35,7 +35,7 @@ public function getIndexData(Field $field, FieldDefinition $fieldDefinition) $document = new DOMDocument(); $document->loadXML($field->value->data); - return array( + return [ new Search\Field( 'value', $this->extractShortText($document), @@ -46,7 +46,7 @@ public function getIndexData(Field $field, FieldDefinition $fieldDefinition) $this->extractText($document->documentElement), new Search\FieldType\FullTextField() ), - ); + ]; } /** @@ -105,9 +105,9 @@ private function extractShortText(DOMDocument $document) */ public function getIndexDefinition() { - return array( + return [ 'value' => new Search\FieldType\StringField(), - ); + ]; } /** diff --git a/lib/FieldType/XmlText/Type.php b/lib/FieldType/XmlText/Type.php index 37cdbd8f..6b402623 100644 --- a/lib/FieldType/XmlText/Type.php +++ b/lib/FieldType/XmlText/Type.php @@ -38,7 +38,7 @@ class Type extends FieldType const TAG_PRESET_SIMPLE_FORMATTING = 1; /** - * @var null|\eZ\Publish\Core\FieldType\XmlText\InternalLinkValidator + * @var \eZ\Publish\Core\FieldType\XmlText\InternalLinkValidator|null */ protected $internalLinkValidator; @@ -49,21 +49,21 @@ class Type extends FieldType * * @var array */ - protected $settingsSchema = array( - 'numRows' => array( + protected $settingsSchema = [ + 'numRows' => [ 'type' => 'int', 'default' => 10, - ), - 'tagPreset' => array( + ], + 'tagPreset' => [ 'type' => 'choice', 'default' => self::TAG_PRESET_DEFAULT, - ), - ); + ], + ]; /** * Type constructor. * - * @param null|\eZ\Publish\Core\FieldType\XmlText\InternalLinkValidator $internalLinkValidator + * @param \eZ\Publish\Core\FieldType\XmlText\InternalLinkValidator|null $internalLinkValidator */ public function __construct(InternalLinkValidator $internalLinkValidator = null) { @@ -107,7 +107,7 @@ public function getName(SPIValue $value) $result = $value->xml->documentElement->textContent; } - return trim(preg_replace(array('/\n/', '/\s\s+/'), ' ', $result)); + return trim(preg_replace(['/\n/', '/\s\s+/'], ' ', $result)); } /** @@ -146,7 +146,7 @@ public function isEmptyValue(SPIValue $value) */ protected function createValueFromInput($inputValue) { - if (is_string($inputValue)) { + if (\is_string($inputValue)) { if (empty($inputValue)) { $inputValue = Value::EMPTY_VALUE; } @@ -219,7 +219,7 @@ public function fromHash($hash) */ public function toHash(SPIValue $value) { - return array('xml' => (string)$value); + return ['xml' => (string)$value]; } /** @@ -243,11 +243,11 @@ public function fromPersistenceValue(FieldValue $fieldValue) public function toPersistenceValue(SPIValue $value) { return new FieldValue( - array( + [ 'data' => $value->xml->saveXML(), 'externalData' => null, 'sortKey' => $this->getSortInfo($value), - ) + ] ); } @@ -273,7 +273,7 @@ public function isSearchable() */ public function validate(FieldDefinition $fieldDefinition, SPIValue $value) { - $validationErrors = array(); + $validationErrors = []; if ($this->internalLinkValidator !== null) { $errors = $this->internalLinkValidator->validate($value->xml); @@ -294,35 +294,35 @@ public function validate(FieldDefinition $fieldDefinition, SPIValue $value) */ public function validateFieldSettings($fieldSettings) { - $validationErrors = array(); + $validationErrors = []; foreach ($fieldSettings as $name => $value) { if (isset($this->settingsSchema[$name])) { switch ($name) { case 'numRows': - if (!is_int($value)) { + if (!\is_int($value)) { $validationErrors[] = new ValidationError( "Setting '%setting%' value must be of integer type", null, - array( + [ 'setting' => $name, - ), + ], "[$name]" ); } break; case 'tagPreset': - $definedTagPresets = array( + $definedTagPresets = [ self::TAG_PRESET_DEFAULT, self::TAG_PRESET_SIMPLE_FORMATTING, - ); - if (!empty($value) && !in_array($value, $definedTagPresets, true)) { + ]; + if (!empty($value) && !\in_array($value, $definedTagPresets, true)) { $validationErrors[] = new ValidationError( "Setting '%setting%' is of unknown tag preset", null, - array( + [ 'setting' => $name, - ), + ], "[$name]" ); } @@ -332,9 +332,9 @@ public function validateFieldSettings($fieldSettings) $validationErrors[] = new ValidationError( "Setting '%setting%' is unknown", null, - array( + [ 'setting' => $name, - ), + ], "[$name]" ); } @@ -370,14 +370,14 @@ public function validateFieldSettings($fieldSettings) */ public function getRelations(SPIValue $value) { - $relations = array(); + $relations = []; /** @var \eZ\Publish\Core\FieldType\XmlText\Value $value */ if ($value->xml instanceof DOMDocument) { - $relations = array( + $relations = [ Relation::LINK => $this->getRelatedObjectIds($value, Relation::LINK), Relation::EMBED => $this->getRelatedObjectIds($value, Relation::EMBED), - ); + ]; } return $relations; @@ -391,8 +391,8 @@ protected function getRelatedObjectIds(Value $fieldValue, $relationType) $tagName = 'link'; } - $locationIds = array(); - $contentIds = array(); + $locationIds = []; + $contentIds = []; $linkTags = $fieldValue->xml->getElementsByTagName($tagName); if ($linkTags->length > 0) { /** @var $link \DOMElement */ @@ -409,9 +409,9 @@ protected function getRelatedObjectIds(Value $fieldValue, $relationType) } } - return array( + return [ 'locationIds' => array_unique($locationIds), 'contentIds' => array_unique($contentIds), - ); + ]; } } diff --git a/lib/FieldType/XmlText/XmlTextStorage/Gateway/LegacyStorage.php b/lib/FieldType/XmlText/XmlTextStorage/Gateway/LegacyStorage.php index 7e229814..258762de 100644 --- a/lib/FieldType/XmlText/XmlTextStorage/Gateway/LegacyStorage.php +++ b/lib/FieldType/XmlText/XmlTextStorage/Gateway/LegacyStorage.php @@ -52,13 +52,13 @@ public function getFieldData(Field $field) $linkTags = $doc->getElementsByTagName('link'); if ($linkTags->length > 0) { - $links = array(); + $links = []; foreach ($linkTags as $link) { $urlId = $link->getAttribute('url_id'); if (!empty($urlId)) { if (!isset($links[$urlId])) { - $links[$urlId] = array(); + $links[$urlId] = []; } $links[$urlId][] = $link; } @@ -100,10 +100,10 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field) } // Get all element tag types that contain url's or object_remote_id - $urls = array(); - $remoteIds = array(); - $elements = array(); - foreach (array('link', 'embed', 'embed-inline') as $tagName) { + $urls = []; + $remoteIds = []; + $elements = []; + foreach (['link', 'embed', 'embed-inline'] as $tagName) { $tags = $doc->getElementsByTagName($tagName); if ($tags->length === 0) { continue; @@ -137,7 +137,7 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field) if (!empty($elements)) { $linksIds = $this->getUrlIdMap(array_keys($urls)); $objectRemoteIdMap = $this->getObjectId(array_keys($remoteIds)); - $urlLinkSet = array(); + $urlLinkSet = []; // Now loop again to insert the right value in "url_id" attribute and fix "object_remote_id" /** @var $element \DOMElement */ @@ -205,7 +205,7 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field) */ protected function getObjectId(array $linksRemoteIds) { - $objectRemoteIdMap = array(); + $objectRemoteIdMap = []; if (!empty($linksRemoteIds)) { /** @var $q \eZ\Publish\Core\Persistence\Database\SelectQuery */ diff --git a/lib/Persistence/Legacy/Content/FieldValue/Converter/XmlTextConverter.php b/lib/Persistence/Legacy/Content/FieldValue/Converter/XmlTextConverter.php index 3b931f3f..7831f289 100644 --- a/lib/Persistence/Legacy/Content/FieldValue/Converter/XmlTextConverter.php +++ b/lib/Persistence/Legacy/Content/FieldValue/Converter/XmlTextConverter.php @@ -80,10 +80,10 @@ public function toStorageFieldDefinition(FieldDefinition $fieldDefinition, Stora public function toFieldDefinition(StorageFieldDefinition $storageDefinition, FieldDefinition $fieldDefinition) { $fieldDefinition->fieldTypeConstraints->fieldSettings = new FieldSettings( - array( + [ 'numRows' => $storageDefinition->dataInt1, 'tagPreset' => $storageDefinition->dataText2 ? (int)$storageDefinition->dataText2 : Type::TAG_PRESET_DEFAULT, - ) + ] ); $defaultValue = null; diff --git a/tests/bundle/DependencyInjection/Compiler/XmlTextConverterPassTest.php b/tests/bundle/DependencyInjection/Compiler/XmlTextConverterPassTest.php index 70c603c5..88873612 100644 --- a/tests/bundle/DependencyInjection/Compiler/XmlTextConverterPassTest.php +++ b/tests/bundle/DependencyInjection/Compiler/XmlTextConverterPassTest.php @@ -33,7 +33,7 @@ public function testProcess() $pass->process($container); $this->assertTrue($html5ConvertDef->hasMethodCall('addPreConverter')); $calls = $html5ConvertDef->getMethodCalls(); - $this->assertSame(1, count($calls)); + $this->assertCount(1, $calls); list($method, $arguments) = $calls[0]; $this->assertSame('addPreConverter', $method); $this->assertInstanceOf(Reference::class, $arguments[0]); @@ -64,7 +64,7 @@ public function testAddPreConverter() $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( 'ezpublish.fieldType.ezxmltext.converter.html5', 'addPreConverter', - array(new Reference($serviceId)) + [new Reference($serviceId)] ); } @@ -77,15 +77,15 @@ public function testSortConverterIds() $container->setDefinition('ezpublish.fieldType.ezxmltext.converter.html5', $html5ConvertDef); $preConverterDef1 = new Definition(); - $preConverterDef1->addTag('ezpublish.ezxml.converter', array('priority' => 10)); + $preConverterDef1->addTag('ezpublish.ezxml.converter', ['priority' => 10]); $container->setDefinition('foo.converter1', $preConverterDef1); $preConverterDef2 = new Definition(); - $preConverterDef2->addTag('ezpublish.ezxml.converter', array('priority' => 5)); + $preConverterDef2->addTag('ezpublish.ezxml.converter', ['priority' => 5]); $container->setDefinition('foo.converter2', $preConverterDef2); $preConverterDef3 = new Definition(); - $preConverterDef3->addTag('ezpublish.ezxml.converter', array('priority' => 15)); + $preConverterDef3->addTag('ezpublish.ezxml.converter', ['priority' => 15]); $container->setDefinition('foo.converter3', $preConverterDef3); $html5ConvertDef @@ -93,7 +93,7 @@ public function testSortConverterIds() ->method('addMethodCall') ->with( 'addPreConverter', - array(new Reference('foo.converter3')) + [new Reference('foo.converter3')] ); $html5ConvertDef @@ -101,7 +101,7 @@ public function testSortConverterIds() ->method('addMethodCall') ->with( 'addPreConverter', - array(new Reference('foo.converter1')) + [new Reference('foo.converter1')] ); $html5ConvertDef @@ -109,7 +109,7 @@ public function testSortConverterIds() ->method('addMethodCall') ->with( 'addPreConverter', - array(new Reference('foo.converter2')) + [new Reference('foo.converter2')] ); $pass = new XmlTextConverterPass(); diff --git a/tests/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlTextTest.php b/tests/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlTextTest.php index 008734a5..bbe829ba 100644 --- a/tests/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlTextTest.php +++ b/tests/bundle/DependencyInjection/Configuration/Parser/FieldType/XmlTextTest.php @@ -26,7 +26,7 @@ class XmlTextTest extends AbstractParserTestCase */ protected function getContainerExtensions() { - $extension = new EzPublishCoreExtension(array(new XmlTextConfigParser())); + $extension = new EzPublishCoreExtension([new XmlTextConfigParser()]); $extension->addDefaultSettings( __DIR__ . '/../../../../../../bundle/Resources/config', @@ -49,11 +49,11 @@ protected function getMinimalConfiguration() public function testXmlTextSettings(array $config, array $expected) { $this->load( - array( - 'system' => array( + [ + 'system' => [ 'ezdemo_site' => $config, - ), - ) + ], + ] ); foreach ($expected as $key => $val) { @@ -63,30 +63,30 @@ public function testXmlTextSettings(array $config, array $expected) public function xmlTextSettingsProvider() { - return array( - array( - array( - 'fieldtypes' => array( - 'ezxml' => array( - 'custom_tags' => array( - array('path' => '/foo/bar.xsl', 'priority' => 123), - array('path' => '/foo/custom.xsl', 'priority' => -10), - array('path' => '/another/custom.xsl', 'priority' => 27), - ), - ), - ), - ), - array( - 'fieldtypes.ezxml.custom_xsl' => array( + return [ + [ + [ + 'fieldtypes' => [ + 'ezxml' => [ + 'custom_tags' => [ + ['path' => '/foo/bar.xsl', 'priority' => 123], + ['path' => '/foo/custom.xsl', 'priority' => -10], + ['path' => '/another/custom.xsl', 'priority' => 27], + ], + ], + ], + ], + [ + 'fieldtypes.ezxml.custom_xsl' => [ // Default settings will be added - array('path' => '%kernel.root_dir%/../vendor/ezsystems/ezplatform-xmltext-fieldtype/lib/FieldType/XmlText/Input/Resources/stylesheets/eZXml2Html5_core.xsl', 'priority' => 0), - array('path' => '%kernel.root_dir%/../vendor/ezsystems/ezplatform-xmltext-fieldtype/lib/FieldType/XmlText/Input/Resources/stylesheets/eZXml2Html5_custom.xsl', 'priority' => 0), - array('path' => '/foo/bar.xsl', 'priority' => 123), - array('path' => '/foo/custom.xsl', 'priority' => -10), - array('path' => '/another/custom.xsl', 'priority' => 27), - ), - ), - ), - ); + ['path' => '%kernel.root_dir%/../vendor/ezsystems/ezplatform-xmltext-fieldtype/lib/FieldType/XmlText/Input/Resources/stylesheets/eZXml2Html5_core.xsl', 'priority' => 0], + ['path' => '%kernel.root_dir%/../vendor/ezsystems/ezplatform-xmltext-fieldtype/lib/FieldType/XmlText/Input/Resources/stylesheets/eZXml2Html5_custom.xsl', 'priority' => 0], + ['path' => '/foo/bar.xsl', 'priority' => 123], + ['path' => '/foo/custom.xsl', 'priority' => -10], + ['path' => '/another/custom.xsl', 'priority' => 27], + ], + ], + ], + ]; } } diff --git a/tests/lib/FieldType/Converter/BaseTest.php b/tests/lib/FieldType/Converter/BaseTest.php index ce701050..795fefb5 100644 --- a/tests/lib/FieldType/Converter/BaseTest.php +++ b/tests/lib/FieldType/Converter/BaseTest.php @@ -37,7 +37,7 @@ public function providerForTestConvert() { $fixtureSubdirectories = $this->getFixtureSubdirectories(); - $map = array(); + $map = []; foreach (glob(__DIR__ . "/Xslt/_fixtures/{$fixtureSubdirectories['input']}/*.xml") as $inputFile) { $basename = basename($inputFile, '.xml'); @@ -48,7 +48,7 @@ public function providerForTestConvert() $outputFile = $outputFileLossy; } - $map[] = array($inputFile, $outputFile); + $map[] = [$inputFile, $outputFile]; } $lossySubdirectory = "Xslt/_fixtures/{$fixtureSubdirectories['input']}/lossy"; @@ -62,7 +62,7 @@ public function providerForTestConvert() continue; } - $map[] = array($inputFile, $outputFile); + $map[] = [$inputFile, $outputFile]; } return $map; @@ -87,7 +87,7 @@ protected function removeComments(DOMDocument $document) public function testConvert($inputFile, $outputFile) { $endsWith = '.lossy.xml'; - if (substr_compare($inputFile, $endsWith, -strlen($endsWith), strlen($endsWith)) === 0) { + if (substr_compare($inputFile, $endsWith, -\strlen($endsWith), \strlen($endsWith)) === 0) { $this->markTestSkipped('Skipped lossy conversion.'); } @@ -211,7 +211,7 @@ abstract public function getFixtureSubdirectories(); */ protected function getCustomConversionTransformationStylesheets() { - return array(); + return []; } /** @@ -221,6 +221,6 @@ protected function getCustomConversionTransformationStylesheets() */ protected function getConversionValidationSchema() { - return array(); + return []; } } diff --git a/tests/lib/FieldType/Converter/EmbedLinkingTest.php b/tests/lib/FieldType/Converter/EmbedLinkingTest.php index 425b1005..e125be36 100644 --- a/tests/lib/FieldType/Converter/EmbedLinkingTest.php +++ b/tests/lib/FieldType/Converter/EmbedLinkingTest.php @@ -26,13 +26,13 @@ class EmbedLinkingTest extends TestCase */ public function providerForTestConvert() { - $map = array(); + $map = []; foreach (glob(__DIR__ . '/_fixtures/embed_linking/input/*.xml') as $inputFilePath) { $basename = basename($inputFilePath, '.xml'); $outputFilePath = __DIR__ . "/_fixtures/embed_linking/output/{$basename}.xml"; - $map[] = array($inputFilePath, $outputFilePath); + $map[] = [$inputFilePath, $outputFilePath]; } return $map; diff --git a/tests/lib/FieldType/Converter/EmbedToHtml5Test.php b/tests/lib/FieldType/Converter/EmbedToHtml5Test.php index 0546063a..c9b2f964 100644 --- a/tests/lib/FieldType/Converter/EmbedToHtml5Test.php +++ b/tests/lib/FieldType/Converter/EmbedToHtml5Test.php @@ -37,84 +37,84 @@ class EmbedToHtml5Test extends TestCase */ public function providerEmbedXmlSampleContent() { - return array( - array( + return [ + [ '
', 104, APIVersionInfo::STATUS_DRAFT, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 3, 'limit' => 5, - ), + ], 'noLayout' => true, - ), - array( - array('content', 'read', true), - array('content', 'versionread', true), - ), - ), - array( + ], + [ + ['content', 'read', true], + ['content', 'versionread', true], + ], + ], + [ '
', 107, APIVersionInfo::STATUS_DRAFT, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'size' => 'medium', 'funkyattrib' => 3, 'limit' => 5, - ), + ], 'noLayout' => true, - ), - array( - array('content', 'read', false), - array('content', 'view_embed', true), - array('content', 'versionread', true), - ), - ), - array( + ], + [ + ['content', 'read', false], + ['content', 'view_embed', true], + ['content', 'versionread', true], + ], + ], + [ '
', 110, APIVersionInfo::STATUS_PUBLISHED, 'embed-inline', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'size' => 'small', - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
', 113, APIVersionInfo::STATUS_DRAFT, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'left', 'size' => 'large', 'limit' => '5', 'offset' => '0', - ), - ), - array( - array('content', 'read', true), - array('content', 'versionread', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ['content', 'versionread', true], + ], + ], + [ '
@@ -133,27 +133,27 @@ class="itemized_sub_items" 104, APIVersionInfo::STATUS_DRAFT, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 3, 'limit' => 5, - ), + ], 'noLayout' => true, - 'linkParameters' => array( + 'linkParameters' => [ 'href' => 'http://ez.no', 'resourceType' => 'URL', 'resourceId' => null, 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - array('content', 'versionread', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ['content', 'versionread', true], + ], + ], + [ '
@@ -176,14 +176,14 @@ class="itemized_sub_items" 107, APIVersionInfo::STATUS_DRAFT, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'size' => 'medium', 'funkyattrib' => 3, 'limit' => 5, - ), + ], 'noLayout' => true, - 'linkParameters' => array( + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -192,15 +192,15 @@ class="itemized_sub_items" 'resourceType' => 'LOCATION', 'resourceId' => '111', 'wrapped' => false, - ), - ), - array( - array('content', 'read', false), - array('content', 'view_embed', true), - array('content', 'versionread', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', false], + ['content', 'view_embed', true], + ['content', 'versionread', true], + ], + ], + [ '
@@ -215,23 +215,23 @@ class="itemized_sub_items" 110, APIVersionInfo::STATUS_PUBLISHED, 'embed-inline', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'size' => 'small', - ), - 'linkParameters' => array( + ], + 'linkParameters' => [ 'href' => 'http://ez.no', 'resourceType' => 'URL', 'resourceId' => null, 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
@@ -253,15 +253,15 @@ class="itemized_sub_items" 113, APIVersionInfo::STATUS_DRAFT, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'left', 'size' => 'large', 'limit' => '5', 'offset' => '0', - ), - 'linkParameters' => array( + ], + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -270,14 +270,14 @@ class="itemized_sub_items" 'resourceType' => 'URL', 'resourceId' => null, 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - array('content', 'versionread', true), - ), - ), - ); + ], + ], + [ + ['content', 'read', true], + ['content', 'versionread', true], + ], + ], + ]; } /** @@ -285,45 +285,45 @@ class="itemized_sub_items" */ public function providerEmbedXmlSampleLocation() { - return array( - array( + return [ + [ '
', 114, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 2, 'limit' => 7, - ), + ], 'noLayout' => true, - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + [ + ['content', 'read', true], + ], + ], + [ '
', 114, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 2, 'limit' => 7, - ), + ], 'noLayout' => true, - ), - array( - array('content', 'read', false), - array('content', 'view_embed', true), - ), - ), - array( + ], + [ + ['content', 'read', false], + ['content', 'view_embed', true], + ], + ], + [ '
@@ -343,26 +343,26 @@ class="itemized_sub_items"
', 114, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 2, 'limit' => 7, - ), + ], 'noLayout' => true, - 'linkParameters' => array( + 'linkParameters' => [ 'href' => 'http://ez.no', 'resourceType' => 'CONTENT', 'resourceId' => '333', 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
@@ -387,15 +387,15 @@ class="itemized_sub_items"
', 114, 'embed', - array( - 'objectParameters' => array( + [ + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'offset' => 2, 'limit' => 7, - ), + ], 'noLayout' => true, - 'linkParameters' => array( + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -405,14 +405,14 @@ class="itemized_sub_items" 'resourceId' => null, 'resourceFragmentIdentifier' => 'anchovy', 'wrapped' => false, - ), - ), - array( - array('content', 'read', false), - array('content', 'view_embed', true), - ), - ), - ); + ], + ], + [ + ['content', 'read', false], + ['content', 'view_embed', true], + ], + ], + ]; } /** @@ -420,27 +420,27 @@ class="itemized_sub_items" */ public function providerEmbedXmlBadSample() { - return array( - array( + return [ + [ '
', 104, APIVersionInfo::STATUS_PUBLISHED, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'limit' => 5, 'offset' => 3, - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
@@ -465,15 +465,15 @@ class="itemized_sub_items" 104, APIVersionInfo::STATUS_PUBLISHED, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'limit' => 5, 'offset' => 3, - ), - 'linkParameters' => array( + ], + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -482,13 +482,13 @@ class="itemized_sub_items" 'resourceType' => 'LOCATION', 'resourceId' => '222', 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
@@ -516,15 +516,15 @@ class="itemized_sub_items" 104, APIVersionInfo::STATUS_PUBLISHED, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'limit' => 5, 'offset' => 3, - ), - 'linkParameters' => array( + ], + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -533,13 +533,13 @@ class="itemized_sub_items" 'resourceType' => 'LOCATION', 'resourceId' => '222', 'wrapped' => true, - ), - ), - array( - array('content', 'read', true), - ), - ), - array( + ], + ], + [ + ['content', 'read', true], + ], + ], + [ '
@@ -566,15 +566,15 @@ class="itemized_sub_items" 104, APIVersionInfo::STATUS_PUBLISHED, 'embed', - array( + [ 'noLayout' => true, - 'objectParameters' => array( + 'objectParameters' => [ 'align' => 'right', 'size' => 'medium', 'limit' => 5, 'offset' => 3, - ), - 'linkParameters' => array( + ], + 'linkParameters' => [ 'href' => 'http://ez.no', 'target' => 'target', 'title' => 'title', @@ -583,13 +583,13 @@ class="itemized_sub_items" 'resourceType' => 'LOCATION', 'resourceId' => '222', 'wrapped' => false, - ), - ), - array( - array('content', 'read', true), - ), - ), - ); + ], + ], + [ + ['content', 'read', true], + ], + ], + ]; } /** @@ -638,7 +638,7 @@ protected function getMockRepository($contentService, $locationService) ->method('sudo') ->with($this->anything()) ->will($this->returnCallback( - function ($callback) use ($repository) { + static function ($callback) use ($repository) { return $callback($repository); } )); @@ -706,19 +706,19 @@ public function runNodeEmbedContent($xmlString, $contentId, $status, $view, $par ->with( new ControllerReference( 'ez_content:embedAction', - array( + [ 'contentId' => $contentId, 'viewType' => $view, 'layout' => false, 'params' => $parameters, - ) + ] ) ); $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $this->getLoggerMock() ); @@ -740,8 +740,8 @@ public function runNodeEmbedLocation($xmlString, $locationId, $view, $parameters $fragmentHandler = $this->getMockFragmentHandler(); $locationService = $this->getMockLocationService(); - $contentInfo = new ContentInfo(array('id' => 42)); - $location = new Location(array('id' => $locationId, 'contentInfo' => $contentInfo)); + $contentInfo = new ContentInfo(['id' => 42]); + $location = new Location(['id' => $locationId, 'contentInfo' => $contentInfo]); $locationService->expects($this->once()) ->method('loadLocation') @@ -768,20 +768,20 @@ public function runNodeEmbedLocation($xmlString, $locationId, $view, $parameters ->with( new ControllerReference( 'ez_content:embedAction', - array( + [ 'contentId' => $location->getContentInfo()->id, 'locationId' => $location->id, 'viewType' => $view, 'layout' => false, 'params' => $parameters, - ) + ] ) ); $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $this->getLoggerMock() ); @@ -820,35 +820,36 @@ public function testImproperEmbeds($xmlString, $contentId, $status, $view, $para public function providerForTestEmbedContentThrowsUnauthorizedException() { - return array( - array( - array( - array('content', 'read', false), - array('content', 'view_embed', false), - ), - ), - array( - array( - array('content', 'read', false), - array('content', 'view_embed', true), - array('content', 'versionread', false), - ), - ), - array( - array( - array('content', 'read', true), - array('content', 'versionread', false), - ), - ), - ); + return [ + [ + [ + ['content', 'read', false], + ['content', 'view_embed', false], + ], + ], + [ + [ + ['content', 'read', false], + ['content', 'view_embed', true], + ['content', 'versionread', false], + ], + ], + [ + [ + ['content', 'read', true], + ['content', 'versionread', false], + ], + ], + ]; } /** * @dataProvider providerForTestEmbedContentThrowsUnauthorizedException - * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException */ public function testEmbedContentThrowsUnauthorizedException($permissionsMap) { + $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); + $dom = new \DOMDocument(); $dom->loadXML('
'); @@ -889,18 +890,17 @@ public function testEmbedContentThrowsUnauthorizedException($permissionsMap) $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $this->getLoggerMock() ); $converter->convert($dom); } - /** - * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException - */ public function testEmbedLocationThrowsUnauthorizedException() { + $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); + $dom = new \DOMDocument(); $dom->loadXML('
'); @@ -936,7 +936,7 @@ public function testEmbedLocationThrowsUnauthorizedException() $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $this->getLoggerMock() ); @@ -945,24 +945,24 @@ public function testEmbedLocationThrowsUnauthorizedException() public function dataProviderForTestEmbedContentNotFound() { - return array( - array( + return [ + [ '
', '
', - ), - array( + ], + [ '
hello goodbye
', '
hello goodbye
', - ), - array( + ], + [ '
hello goodbye
', '
hello goodbye
', - ), - array( + ], + [ '
', '
', - ), - ); + ], + ]; } /** @@ -996,7 +996,7 @@ public function testEmbedContentNotFound($input, $output) $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $logger ); @@ -1013,24 +1013,24 @@ public function testEmbedContentNotFound($input, $output) public function dataProviderForTestEmbedLocationNotFound() { - return array( - array( + return [ + [ '
', '
', - ), - array( + ], + [ '
hello goodbye
', '
hello goodbye
', - ), - array( + ], + [ '
hello goodbye
', '
hello goodbye
', - ), - array( + ], + [ '
', '
', - ), - ); + ], + ]; } /** @@ -1064,7 +1064,7 @@ public function testEmbedLocationNotFound($input, $output) $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $logger ); @@ -1090,10 +1090,10 @@ public function testEmbedLocationNotFound($input, $output) public function testEmbedRemovesTextContent($input, $output, $contentReplacement, $contentId) { $status = APIVersionInfo::STATUS_DRAFT; - $permissionsMap = array( - array('content', 'read', true), - array('content', 'versionread', true), - ); + $permissionsMap = [ + ['content', 'read', true], + ['content', 'versionread', true], + ]; $dom = new \DOMDocument(); $dom->loadXML($input); @@ -1139,7 +1139,7 @@ public function testEmbedRemovesTextContent($input, $output, $contentReplacement $converter = new EmbedToHtml5( $fragmentHandler, $repository, - array('view', 'class', 'node_id', 'object_id'), + ['view', 'class', 'node_id', 'object_id'], $this->getLoggerMock() ); @@ -1161,19 +1161,19 @@ public function providerEmbedRemovesTextContent()
'; - return array( - array( + return [ + [ sprintf($xmlFramework, 'content to be removed'), sprintf($xmlFramework, 'ContentReplacement'), 'ContentReplacement', 123, - ), - array( + ], + [ sprintf($xmlFramework, 'Content to be removed'), sprintf($xmlFramework, 'Other random content'), 'Other random content', 789, - ), - ); + ], + ]; } } diff --git a/tests/lib/FieldType/Converter/ExpandingTest.php b/tests/lib/FieldType/Converter/ExpandingTest.php index e3c34313..5b5480e4 100644 --- a/tests/lib/FieldType/Converter/ExpandingTest.php +++ b/tests/lib/FieldType/Converter/ExpandingTest.php @@ -26,13 +26,13 @@ class ExpandingTest extends TestCase */ public function providerForTestConvert() { - $map = array(); + $map = []; foreach (glob(__DIR__ . '/_fixtures/expanding/input/*.xml') as $inputFilePath) { $basename = basename($inputFilePath, '.xml'); $outputFilePath = __DIR__ . "/_fixtures/expanding/output/{$basename}.xml"; - $map[] = array($inputFilePath, $outputFilePath); + $map[] = [$inputFilePath, $outputFilePath]; } return $map; diff --git a/tests/lib/FieldType/Converter/EzLinkToHtml5Test.php b/tests/lib/FieldType/Converter/EzLinkToHtml5Test.php index 52969d3e..63f76fa5 100644 --- a/tests/lib/FieldType/Converter/EzLinkToHtml5Test.php +++ b/tests/lib/FieldType/Converter/EzLinkToHtml5Test.php @@ -35,38 +35,38 @@ class EzLinkToHtml5Test extends TestCase */ public function providerLinkXmlSample() { - return array( - array( + return [ + [ '
This is an object link.
', '/test', - ), - array( + ], + [ '
This is an object link.
', '/test#anchor', - ), - array( + ], + [ '
', '/test', - ), - array( + ], + [ '
', '/test#anchor', - ), - array( + ], + [ '
', '/test', - ), - array( + ], + [ '
', '/test#anchor', - ), - ); + ], + ]; } /** @@ -74,56 +74,56 @@ public function providerLinkXmlSample() */ public function providerObjectLinkXmlSample() { - return array( - array( + return [ + [ '
This is an object link.
', 104, 106, 'test', 'test', - ), - array( + ], + [ '
This is an object link.
', 104, 106, 'test', 'test#anchor', - ), - array( + ], + [ '
', 104, 106, 'test', 'test', - ), - array( + ], + [ '
', 104, 106, 'test', 'test#anchor', - ), - array( + ], + [ '
', 104, 106, 'test', 'test', - ), - array( + ], + [ '
', 104, 106, 'test', 'test#anchor', - ), - ); + ], + ]; } /** @@ -131,50 +131,50 @@ public function providerObjectLinkXmlSample() */ public function providerLocationLinkXmlSample() { - return array( - array( + return [ + [ '
This is a node link.
', 106, 'test', 'test', - ), - array( + ], + [ '
This is a node link.
', 106, 'test', 'test#anchor', - ), - array( + ], + [ '
', 106, 'test', 'test', - ), - array( + ], + [ '
', 106, 'test', 'test#anchor', - ), - array( + ], + [ '
', 106, 'test', 'test', - ), - array( + ], + [ '
', 106, 'test', 'test#anchor', - ), - ); + ], + ]; } /** @@ -182,56 +182,56 @@ public function providerLocationLinkXmlSample() */ public function providerBadLocationSample() { - return array( - array( + return [ + [ '
This is a node link.
', 106, new APINotFoundException('Location', 106), 'warning', 'While generating links for xmltext, could not locate Location with ID 106', - ), - array( + ], + [ '
This is a node link.
', 106, new APIUnauthorizedException('Location', 106), 'notice', 'While generating links for xmltext, unauthorized to load Location with ID 106', - ), - array( + ], + [ '
', 106, new APINotFoundException('Location', 106), 'warning', 'While generating links for xmltext, could not locate Location with ID 106', - ), - array( + ], + [ '
', 106, new APIUnauthorizedException('Location', 106), 'notice', 'While generating links for xmltext, unauthorized to load Location with ID 106', - ), - array( + ], + [ '
', 106, new APINotFoundException('Location', 106), 'warning', 'While generating links for xmltext, could not locate Location with ID 106', - ), - array( + ], + [ '
', 106, new APIUnauthorizedException('Location', 106), 'notice', 'While generating links for xmltext, unauthorized to load Location with ID 106', - ), - ); + ], + ]; } /** @@ -239,56 +239,56 @@ public function providerBadLocationSample() */ public function providerBadObjectSample() { - return array( - array( + return [ + [ '
This is an object link.
', 205, new APINotFoundException('Content', 205), 'warning', 'While generating links for xmltext, could not locate Content object with ID 205', - ), - array( + ], + [ '
This is an object link.
', 205, new APIUnauthorizedException('Content', 205), 'notice', 'While generating links for xmltext, unauthorized to load Content object with ID 205', - ), - array( + ], + [ '
', 205, new APINotFoundException('Content', 205), 'warning', 'While generating links for xmltext, could not locate Content object with ID 205', - ), - array( + ], + [ '
', 205, new APIUnauthorizedException('Content', 205), 'notice', 'While generating links for xmltext, unauthorized to load Content object with ID 205', - ), - array( + ], + [ '
', 205, new APINotFoundException('Content', 205), 'warning', 'While generating links for xmltext, could not locate Content object with ID 205', - ), - array( + ], + [ '
', 205, new APIUnauthorizedException('Content', 205), 'notice', 'While generating links for xmltext, unauthorized to load Content object with ID 205', - ), - ); + ], + ]; } /** diff --git a/tests/lib/FieldType/Converter/EzxmlToDocbookTest.php b/tests/lib/FieldType/Converter/EzxmlToDocbookTest.php index 65c91cd2..71390cc5 100644 --- a/tests/lib/FieldType/Converter/EzxmlToDocbookTest.php +++ b/tests/lib/FieldType/Converter/EzxmlToDocbookTest.php @@ -106,9 +106,9 @@ protected function getConverter($inputFile) */ public function getFixtureSubdirectories() { - return array( + return [ 'input' => 'ezxml', 'output' => 'docbook', - ); + ]; } } diff --git a/tests/lib/FieldType/Converter/Html5Test.php b/tests/lib/FieldType/Converter/Html5Test.php index 3513d4dc..1d612897 100644 --- a/tests/lib/FieldType/Converter/Html5Test.php +++ b/tests/lib/FieldType/Converter/Html5Test.php @@ -48,22 +48,23 @@ protected function getPreConvertMock() public function dataProviderConstructorException() { - return array( - array( - array(1, 2), - array(1, $this->getPreConvertMock()), - array($this->getPreConvertMock(), 1), - ), - ); + return [ + [ + [1, 2], + [1, $this->getPreConvertMock()], + [$this->getPreConvertMock(), 1], + ], + ]; } /** * @dataProvider dataProviderConstructorException - * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType */ public function testConstructorException(array $preConverters) { - new Html5('', array(), $preConverters); + $this->expectException(\eZ\Publish\Core\Base\Exceptions\InvalidArgumentType::class); + + new Html5('', [], $preConverters); } public function testPreConverterCalled() @@ -83,11 +84,11 @@ public function testPreConverterCalled() $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ $preConverterMock1, $preConverterMock2, - ) + ] ); $html5->convert($dom); } @@ -96,26 +97,26 @@ public function dataProviderAnchor() { $that = $this; - return array( - array( + return [ + [ '
This is the start
', '//a[@id="start"]', - function (DOMNodeList $xpathResult) use ($that) { + static function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($xpathResult->length, 1); $anchor = $xpathResult->item(0); $that->assertEquals($anchor->parentNode->localName, 'p'); }, - ), - array( + ], + [ '
This is the start
', '//a[@id]', - function (DOMNodeList $xpathResult) use ($that) { - $ids = array('start', 'middle', 'end'); - $that->assertEquals($xpathResult->length, count($ids)); + static function (DOMNodeList $xpathResult) use ($that) { + $ids = ['start', 'middle', 'end']; + $that->assertEquals($xpathResult->length, \count($ids)); foreach ($xpathResult as $k => $anchor) { $that->assertEquals( $anchor->getAttribute('id'), @@ -124,12 +125,12 @@ function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($anchor->parentNode->localName, 'p'); } }, - ), - array( + ], + [ '
This is a long line with an anchor in the middle
', '//a[@id="inside"]', - function (DOMNodeList $xpathResult) use ($that) { + static function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($xpathResult->length, 1); $doc = $xpathResult->item(0)->ownerDocument; $that->assertEquals( @@ -137,8 +138,8 @@ function (DOMNodeList $xpathResult) use ($that) { '

This is a long line with an anchor in the middle

' ); }, - ), - ); + ], + ]; } /** @@ -148,7 +149,7 @@ public function testAnchorRendering($xml, $xpathCheck, $checkClosure) { $dom = new DomDocument(); $dom->loadXML($xml); - $html5 = new Html5($this->getDefaultStylesheet(), array()); + $html5 = new Html5($this->getDefaultStylesheet(), []); $result = new DomDocument(); $result->loadXML($html5->convert($dom)); @@ -160,12 +161,12 @@ public function dataProviderLiteral() { $that = $this; - return array( - array( + return [ + [ '
This is a <em>emphasized</em> text
', '//pre', - function (DOMNodeList $xpathResult) use ($that) { + static function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($xpathResult->length, 1); $doc = $xpathResult->item(0)->ownerDocument; $that->assertEquals( @@ -173,12 +174,12 @@ function (DOMNodeList $xpathResult) use ($that) { trim($doc->saveXML($doc->documentElement)) ); }, - ), - array( + ], + [ '
<iframe src="http://www.ez.no" width="500"/>
', '//iframe', - function (DOMNodeList $xpathResult) use ($that) { + static function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($xpathResult->length, 1); $doc = $xpathResult->item(0)->ownerDocument; $that->assertEquals( @@ -186,12 +187,12 @@ function (DOMNodeList $xpathResult) use ($that) { $doc->saveXML($doc->documentElement) ); }, - ), - array( + ], + [ '
<div class="dummy"><p>First paragraph</p><p>Second paragraph with <strong>strong</strong></p></div>
', '//div', - function (DOMNodeList $xpathResult) use ($that) { + static function (DOMNodeList $xpathResult) use ($that) { $that->assertEquals($xpathResult->length, 1); $doc = $xpathResult->item(0)->ownerDocument; $that->assertEquals( @@ -199,8 +200,8 @@ function (DOMNodeList $xpathResult) use ($that) { $doc->saveXML($doc->documentElement) ); }, - ), - ); + ], + ]; } /** @@ -212,11 +213,11 @@ public function testLiteralRendering($xml, $xpathCheck, $checkClosure) $dom->loadXML($xml); $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = new DomDocument(); @@ -234,11 +235,11 @@ public function testConvertReturnsNotValidXml() ); $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = $html5->convert($dom); @@ -254,11 +255,11 @@ public function testConvertReturnsNotValidXml() ); $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = $html5->convert($dom); @@ -277,7 +278,7 @@ public function testAddPreConverter() $converter2 = $this->getPreConvertMock(); $html5Converter->addPreConverter($converter2); - $this->assertSame(array($converter1, $converter2), $html5Converter->getPreConverters()); + $this->assertSame([$converter1, $converter2], $html5Converter->getPreConverters()); } public function testTableRendering() @@ -328,11 +329,11 @@ public function testTableRendering() $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = $html5->convert($xmlDoc); @@ -377,23 +378,23 @@ public function testTableRendering() public function dataProviderEmbedRendering() { - return array( - array( + return [ + [ '
', '
', - ), - array( + ], + [ '
First paragraphSecond paragraph
', '

First paragraph

Second paragraph

', - ), - array( + ], + [ '
FirstparagraphSecond paragraph
', '

Firstparagraph

Second paragraph

', - ), - ); + ], + ]; } /** @@ -406,11 +407,11 @@ public function testEmbedRendering($xml, $expected) $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = $html5->convert($dom); @@ -427,13 +428,13 @@ public function testEmbedRendering($xml, $expected) */ public function providerForTestConvert() { - $map = array(); + $map = []; foreach (glob(__DIR__ . '/_fixtures/html5/input/*.xml') as $inputFilePath) { $basename = basename($inputFilePath, '.xml'); $outputFilePath = __DIR__ . "/_fixtures/html5/output/{$basename}.xml"; - $map[] = array($inputFilePath, $outputFilePath); + $map[] = [$inputFilePath, $outputFilePath]; } return $map; @@ -473,11 +474,11 @@ public function testConvert($inputFilePath, $outputFilePath) $html5 = new Html5( $this->getDefaultStylesheet(), - array(), - array( + [], + [ new Expanding(), new EmbedLinking(), - ) + ] ); $result = $html5->convert($inputDocument); diff --git a/tests/lib/FieldType/Converter/MethodCallCountConstraint.php b/tests/lib/FieldType/Converter/MethodCallCountConstraint.php index 7d5ea53a..dd24af45 100644 --- a/tests/lib/FieldType/Converter/MethodCallCountConstraint.php +++ b/tests/lib/FieldType/Converter/MethodCallCountConstraint.php @@ -8,9 +8,9 @@ */ namespace EzSystems\EzPlatformXmlTextFieldType\Tests\FieldType\Converter; -use PHPUnit_Framework_MockObject_Invocation; -use PHPUnit_Framework_MockObject_Matcher_InvokedRecorder; -use PHPUnit_Framework_ExpectationFailedException; +use PHPUnit\Framework\MockObject\Invocation; +use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder; +use PHPUnit\Framework\ExpectationFailedException; /** * Class MethodCallCountConstraint. @@ -24,7 +24,7 @@ * * Based on workaround proposed on https://github.com/sebastianbergmann/phpunit-mock-objects/issues/65 */ -class MethodCallCountConstraint extends PHPUnit_Framework_MockObject_Matcher_InvokedRecorder +class MethodCallCountConstraint extends InvokedRecorder { /** * @var int @@ -44,7 +44,7 @@ public function __construct($expectedCount) * @return mixed|void * @throws PHPUnit_Framework_ExpectationFailedException */ - public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) + public function invoked(Invocation $invocation) { parent::invoked($invocation); @@ -53,7 +53,7 @@ public function invoked(PHPUnit_Framework_MockObject_Invocation $invocation) if ($count > $this->expectedCount) { $message = 'Call to ' . $invocation->toString() . ' unexpected'; - throw new PHPUnit_Framework_ExpectationFailedException($message); + throw new ExpectationFailedException($message); } } diff --git a/tests/lib/FieldType/Converter/RichTextTest.php b/tests/lib/FieldType/Converter/RichTextTest.php index 313795e0..a66b52e5 100644 --- a/tests/lib/FieldType/Converter/RichTextTest.php +++ b/tests/lib/FieldType/Converter/RichTextTest.php @@ -197,7 +197,7 @@ private function createLoggerStub($logFilePath) ->with($logLevel, $this->callback(function ($actualLogMessage) use ($logMessage) { $expectedLogMessage = substr($logMessage, 0, strpos($logMessage, '*')); - $this->assertEquals($expectedLogMessage, substr($actualLogMessage, 0, strlen($expectedLogMessage)), 'Actual log message do not match the expected one'); + $this->assertEquals($expectedLogMessage, substr($actualLogMessage, 0, \strlen($expectedLogMessage)), 'Actual log message do not match the expected one'); return true; })); @@ -257,10 +257,10 @@ public function testConvert($inputFilePath, $outputFilePath, $logFilePath) public function getValidator() { return new Validator( - array( + [ './vendor/ezsystems/ezplatform-richtext/src/lib/eZ/RichText/Resources/schemas/docbook/ezpublish.rng', './vendor/ezsystems/ezplatform-richtext/src/lib/eZ/RichText/Resources/schemas/docbook/docbook.iso.sch.xsl', - ) + ] ); } @@ -277,7 +277,7 @@ public function testTagEmbeddedImages($inputFilePath, $outputFilePath) $inputDocument = $this->createDocument($inputFilePath); $richText = new RichText($apiRepositoryStub, null, $validator); - $richText->setImageContentTypes(array(27)); + $richText->setImageContentTypes([27]); $richText->tagEmbeddedImages($inputDocument, null); diff --git a/tests/lib/FieldType/Gateway/LegacyStorageTest.php b/tests/lib/FieldType/Gateway/LegacyStorageTest.php index e3cb1813..f5387a40 100644 --- a/tests/lib/FieldType/Gateway/LegacyStorageTest.php +++ b/tests/lib/FieldType/Gateway/LegacyStorageTest.php @@ -47,143 +47,143 @@ public function providerForTestStoreFieldData() * 6. Expected return value * 7. Resulting XML */ - return array( + return [ // LINK - array( + [ '
This is an object link.
', - array(array('/test'), array('/test' => 55)), - array(array(), array()), - array(), - array(55, null), + [['/test'], ['/test' => 55]], + [[], []], + [], + [55, null], true, '
This is an object link.
', - ), - array( + ], + [ '
This is an object linkobject link.
', - array(array('/test'), array('/test' => 55)), - array(array(), array()), - array(), - array(55, null), + [['/test'], ['/test' => 55]], + [[], []], + [], + [55, null], true, '
This is an object linkobject link.
', - ), - array( + ], + [ '
This is an object link.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array('34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55)), - array(), - array(), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], ['34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55]], + [], + [], true, '
This is an object link.
', - ), - array( + ], + [ '
This is an object linkobject link.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array('34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55)), - array(), - array(), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], ['34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55]], + [], + [], true, '
This is an object linkobject link.
', - ), - array( + ], + [ '
This is an object link.
', - array(array('/newUrl'), array()), - array(array(), array()), - array('/newUrl', 66), - array(66, null), + [['/newUrl'], []], + [[], []], + ['/newUrl', 66], + [66, null], true, '
This is an object link.
', - ), - array( + ], + [ '
This is an object link.
', - array(), - array(), - array(), - array(), + [], + [], + [], + [], false, '
This is an object link.
', - ), + ], // EMBED - array( + [ '
This is an object embed.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array('34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55)), - array(), - array(), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], ['34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55]], + [], + [], true, '
This is an object embed.
', - ), - array( + ], + [ '
This is an object embed.
', - array(), - array(), - array(), - array(), + [], + [], + [], + [], false, '
This is an object embed.
', - ), + ], // EMBED-INLINE - array( + [ '
This is an object embed.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array('34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55)), - array(), - array(), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], ['34oi5ne5tj5iojte8oj58otehj5tjheo8' => 55]], + [], + [], true, '
This is an object embed.
', - ), - array( + ], + [ '
This is an object embed.
', - array(), - array(), - array(), - array(), + [], + [], + [], + [], false, '
This is an object embed.
', - ), - ); + ], + ]; } /** @@ -199,15 +199,15 @@ public function testStoreFieldData( $expectedResultXML ) { $versionInfo = new VersionInfo(); - $field = new Field(array('value' => new FieldValue(array('data' => $inputXML)))); - $legacyStorage = $this->getPartlyMockedLegacyStorage(array('getUrlIdMap', 'getObjectId', 'insertUrl', 'linkUrl')); + $field = new Field(['value' => new FieldValue(['data' => $inputXML])]); + $legacyStorage = $this->getPartlyMockedLegacyStorage(['getUrlIdMap', 'getObjectId', 'insertUrl', 'linkUrl']); - $methodMap = array( + $methodMap = [ 'getUrlIdMap' => $getLinksIdData, 'getObjectId' => $getObjectIdData, 'insertUrl' => $insertLinkData, 'linkUrl' => $linkUrlData, - ); + ]; foreach ($methodMap as $method => $data) { if (empty($data)) { $legacyStorage->expects($this->never()) @@ -237,50 +237,49 @@ public function providerForTestStoreFieldDataException() * 5. Expected return value * 6. Resulting XML */ - return array( + return [ // LINK - array( + [ '
This is an object link.
', - array(array(), array()), - array(array(), array()), - array(), - ), - array( + [[], []], + [[], []], + [], + ], + [ '
This is an object link.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array()), - array(), - ), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], []], + [], + ], // EMBED - array( + [ '
This is an object link.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array()), - array(), - ), + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], []], + [], + ], // EMBED-INLINE - array( + [ '
This is an object link.
', - array(array(), array()), - array(array('34oi5ne5tj5iojte8oj58otehj5tjheo8'), array()), - array(), - ), - ); + [[], []], + [['34oi5ne5tj5iojte8oj58otehj5tjheo8'], []], + [], + ], + ]; } /** * @dataProvider providerForTestStoreFieldDataException - * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException */ public function testStoreFieldDataException( $inputXML, @@ -288,15 +287,17 @@ public function testStoreFieldDataException( $getObjectIdData, $insertLinkData ) { + $this->expectException(\eZ\Publish\Core\Base\Exceptions\NotFoundException::class); + $versionInfo = new VersionInfo(); - $field = new Field(array('value' => new FieldValue(array('data' => $inputXML)))); - $legacyStorage = $this->getPartlyMockedLegacyStorage(array('getUrlIdMap', 'getObjectId', 'insertUrl')); + $field = new Field(['value' => new FieldValue(['data' => $inputXML])]); + $legacyStorage = $this->getPartlyMockedLegacyStorage(['getUrlIdMap', 'getObjectId', 'insertUrl']); - $methodMap = array( + $methodMap = [ 'getUrlIdMap' => $getLinksIdData, 'getObjectId' => $getObjectIdData, 'insertUrl' => $insertLinkData, - ); + ]; foreach ($methodMap as $method => $data) { if (empty($data)) { $legacyStorage->expects($this->never()) @@ -322,36 +323,36 @@ public function providerForTestGetFieldData() * 2. Use of getLinksUrl() in form of array( array $arguments, array $return ), empty means no call * 6. Resulting XML */ - return array( + return [ // LINK - array( + [ '
This is an object link.
', - array(array(55), array(55 => '/test')), + [[55], [55 => '/test']], '
This is an object link.
', - ), - array( + ], + [ '
This is an object linkobject link.
', - array(array(55), array(55 => '/test')), + [[55], [55 => '/test']], '
This is an object linkobject link.
', - ), - array( + ], + [ '
This is an object link.
', - array(), + [], '
This is an object link.
', - ), - ); + ], + ]; } /** @@ -362,8 +363,8 @@ public function testGetFieldData( $getLinksUrlData, $expectedResultXML ) { - $field = new Field(array('value' => new FieldValue(array('data' => $inputXML)))); - $legacyStorage = $this->getPartlyMockedLegacyStorage(array('getIdUrlMap')); + $field = new Field(['value' => new FieldValue(['data' => $inputXML])]); + $legacyStorage = $this->getPartlyMockedLegacyStorage(['getIdUrlMap']); if (empty($getLinksUrlData)) { $legacyStorage->expects($this->never()) diff --git a/tests/lib/FieldType/Input/EzXmlTest.php b/tests/lib/FieldType/Input/EzXmlTest.php index 14998377..fc17f0a4 100644 --- a/tests/lib/FieldType/Input/EzXmlTest.php +++ b/tests/lib/FieldType/Input/EzXmlTest.php @@ -27,33 +27,33 @@ public function testConvertCorrect($xmlString) public function providerForTestConvertCorrect() { - return array( - array( + return [ + [ '
<test>
', - ), - array( + ], + [ '
test
', - ), - array( + ], + [ '
Multiline
', - ), - array( + ], + [ '
Underline
', - ), - array( + ], + [ '
Multiline
', - ), - ); + ], + ]; } /** @@ -74,12 +74,12 @@ public function testConvertIncorrect($xmlString, $exceptionMessage) public function providerForTestConvertIncorrect() { - return array( - array( + return [ + [ '
', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'wrongTag': This element is not expected. Expected is one of ( section, paragraph, header ).", - ), - array( + ], + [ '
Some content
@@ -90,19 +90,19 @@ public function providerForTestConvertIncorrect() Element 'tr': Missing child element(s). Expected is one of ( th, td ). Element 'link', attribute 'node_id': 'abc' is not a valid value of the atomic type 'xs:integer'. Element 'link': This element is not expected. Expected is one of ( custom, strong, emphasize, embed, embed-inline ).", - ), - array( + ], + [ '
With a literalliteral
', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'literal': This element is not expected. Expected is one of ( custom, strong, emphasize, link, anchor, line ).", - ), - array( + ], + [ '
With a embed
', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'embed': This element is not expected. Expected is one of ( custom, strong, emphasize, link, anchor, line ).", - ), - array( + ], + [ '
With a embed
', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'embed-inline': This element is not expected. Expected is one of ( custom, strong, emphasize, link, anchor, line ).", - ), - ); + ], + ]; } } diff --git a/tests/lib/FieldType/Persistence/Legacy/BaseTest.php b/tests/lib/FieldType/Persistence/Legacy/BaseTest.php index 8655cfd8..0d3ed96f 100644 --- a/tests/lib/FieldType/Persistence/Legacy/BaseTest.php +++ b/tests/lib/FieldType/Persistence/Legacy/BaseTest.php @@ -32,7 +32,7 @@ protected function insertDatabaseFixture($file) $q->insertInto($db->quoteIdentifier($table)); // Contains the bound parameters - $values = array(); + $values = []; // Binding the parameters foreach ($rows[0] as $col => $val) { diff --git a/tests/lib/FieldType/Persistence/Legacy/ContentModelGatewayTest.php b/tests/lib/FieldType/Persistence/Legacy/ContentModelGatewayTest.php index e82df1eb..3eb52721 100644 --- a/tests/lib/FieldType/Persistence/Legacy/ContentModelGatewayTest.php +++ b/tests/lib/FieldType/Persistence/Legacy/ContentModelGatewayTest.php @@ -388,11 +388,11 @@ public function testGetFieldRows($datatypeString, $contentId, $offset, $limit, $ $statement = $gatewayService->getFieldRows($datatypeString, $contentId, $offset, $limit); $index = 0; while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { - $this->assertLessThan(count($expectedRows), $index, 'Too many rows returned by getFieldRows'); + $this->assertLessThan(\count($expectedRows), $index, 'Too many rows returned by getFieldRows'); $this->assertEquals($expectedRows[$index], $row, 'Result from getFieldRows() did not return expected result'); ++$index; } - $this->assertEquals(count($expectedRows), $index, 'Too few rows returned by getFieldRows'); + $this->assertEquals(\count($expectedRows), $index, 'Too few rows returned by getFieldRows'); } protected function getFieldRows($contentId) diff --git a/tests/lib/FieldType/Persistence/Legacy/_fixtures/contentclass.php b/tests/lib/FieldType/Persistence/Legacy/_fixtures/contentclass.php index 82e2ed7a..37f187ac 100644 --- a/tests/lib/FieldType/Persistence/Legacy/_fixtures/contentclass.php +++ b/tests/lib/FieldType/Persistence/Legacy/_fixtures/contentclass.php @@ -1,8 +1,8 @@ array( - 0 => array( +return [ + 'ezcontentclass' => [ + 0 => [ 'always_available' => 0, 'contentobject_name' => '', 'created' => 1024392098, @@ -21,8 +21,8 @@ 'sort_order' => 1, 'url_alias_name' => '', 'version' => 0, - ), - 1 => array( + ], + 1 => [ 'always_available' => 0, 'contentobject_name' => '', 'created' => 1024392098, @@ -41,8 +41,8 @@ 'sort_order' => 1, 'url_alias_name' => '', 'version' => 0, - ), - 2 => array( + ], + 2 => [ 'always_available' => 0, 'contentobject_name' => '', 'created' => 1024392098, @@ -61,6 +61,6 @@ 'sort_order' => 1, 'url_alias_name' => '', 'version' => 0, - ), - ), -); + ], + ], +]; diff --git a/tests/lib/FieldType/XmlTextTest.php b/tests/lib/FieldType/XmlTextTest.php index 93e3f1b2..5f828fcc 100644 --- a/tests/lib/FieldType/XmlTextTest.php +++ b/tests/lib/FieldType/XmlTextTest.php @@ -53,7 +53,7 @@ protected function getTransformationProcessorMock() { return $this->getMockForAbstractClass( TransformationProcessor::class, - array(), + [], '', false, true, @@ -80,16 +80,16 @@ public function testSettingsSchema() { $ft = $this->getFieldType(); self::assertSame( - array( - 'numRows' => array( + [ + 'numRows' => [ 'type' => 'int', 'default' => 10, - ), - 'tagPreset' => array( + ], + 'tagPreset' => [ 'type' => 'choice', 'default' => XmlTextType::TAG_PRESET_DEFAULT, - ), - ), + ], + ], $ft->getSettingsSchema(), 'The settings schema does not match what is expected.' ); @@ -109,7 +109,7 @@ public function testValidateFieldSettingsValid($settings) 'The method validateFieldSettings() must return an array.' ); $this->assertEquals( - array(), + [], $validationResult, 'validateFieldSettings() considered the input settings invalid, while they should be valid: ' ); @@ -130,7 +130,7 @@ public function testValidateFieldSettingsInvalid($settings) ); $this->assertNotEquals( - array(), + [], $validationResult, 'validateFieldSettings() considered the input settings valid, while they should be invalid.' ); @@ -146,10 +146,11 @@ public function testValidateFieldSettingsInvalid($settings) /** * @covers \eZ\Publish\Core\FieldType\XmlText\Type::acceptValue - * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException */ public function testAcceptValueInvalidType() { + $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); + $this->getFieldType()->acceptValue($this->createMock(Value::class)); } @@ -177,7 +178,7 @@ public function testAcceptValueInvalidFormat($input, $errorMessage) $this->assertEquals($errorMessage, $e->getMessage()); } catch (Exception $e) { $this->fail( - 'An InvalidArgumentException was expected! ' . get_class($e) . ' thrown with message: ' . $e->getMessage() + 'An InvalidArgumentException was expected! ' . \get_class($e) . ' thrown with message: ' . $e->getMessage() ); } } @@ -204,86 +205,86 @@ public function testToPersistenceValue() public static function providerForTestValidateFieldSettingsValid() { - return array( - array( - array( + return [ + [ + [ 'numRows' => 10, 'tagPreset' => '', - ), - ), - array( - array( + ], + ], + [ + [ 'numRows' => 10, 'tagPreset' => 0, - ), - ), - ); + ], + ], + ]; } public static function providerForTestValidateFieldSettingsInvalid() { - return array( - array( - array( + return [ + [ + [ 'numRows' => '', 'tagPreset' => '', - ), - ), - array( - array( + ], + ], + [ + [ 'numRows' => 10, 'tagPreset' => 'a', - ), - ), - array( - array( + ], + ], + [ + [ 'numRows' => 'a', 'tagPreset' => 0, - ), - ), - ); + ], + ], + ]; } public static function providerForTestAcceptValueValidFormat() { - return array( - array( + return [ + [ $xml = '
This is a piece of text
', - ), - array(new EzXml($xml)), + ], + [new EzXml($xml)], - array( + [ $xml = '
', - ), - array(new EzXml($xml)), - ); + ], + [new EzXml($xml)], + ]; } public static function providerForTestAcceptValueInvalidFormat() { - return array( - array( + return [ + [ '

This is a piece of text

', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'h1': This element is not expected. Expected is one of ( section, paragraph, header ).", - ), + ], - array( + [ 'This is not XML at all!', "Argument 'xmlString' is invalid: Validation of XML content failed: Start tag expected, '<' not found\nThe document has no document element.", - ), + ], - array( + [ '', "Argument 'xmlString' is invalid: Validation of XML content failed: Element 'unknown': No matching global declaration available for the validation root.", - ), - ); + ], + ]; } /** @@ -316,87 +317,87 @@ public function testGetNamePassingXML($xml, $value) public static function providerForTestGetName() { - return array( - array( + return [ + [ '
This is a piece of text
', 'This is a piece of text', - ), + ], - array( + [ '
This is a piece of text
', /* @todo FIXME: should probably be "This is a piece of text" */ 'This is a piece of', - ), + ], - array( + [ '
This is a piece of text
', /* @todo FIXME: should probably be "This is a piece of text" */ 'This is a piece', - ), + ], - array( + [ '
This is a piece of text
', /* @todo FIXME: should probably be "This is a piece of text" */ 'This is', - ), + ], - array( + [ '
First cellSecond cell
Third cellFourth cell
Text after table
', /* @todo FIXME: should probably be "First cell" */ 'First cellSecond cell', - ), + ], - array( + [ '
  • List item
', 'List item', - ), + ], - array( + [ '
  • List item
', 'List item', - ), + ], - array( + [ '
', '', - ), + ], - array( + [ '
A simple paragraph!
', 'A simple', - ), + ], - array('
test
', 'test'), + ['
test
', 'test'], - array('
testtest
', 'test'), - ); + ['
testtest
', 'test'], + ]; } /** @@ -428,16 +429,16 @@ public function testGetRelations() $ft = $this->getFieldType(); $this->assertEquals( - array( - Relation::LINK => array( - 'locationIds' => array(72, 61), - 'contentIds' => array(70, 75), - ), - Relation::EMBED => array( - 'locationIds' => array(52, 42), - 'contentIds' => array(72, 74), - ), - ), + [ + Relation::LINK => [ + 'locationIds' => [72, 61], + 'contentIds' => [70, 75], + ], + Relation::EMBED => [ + 'locationIds' => [52, 42], + 'contentIds' => [72, 74], + ], + ], $ft->getRelations($ft->acceptValue($xml)) ); } @@ -449,6 +450,6 @@ protected function provideFieldTypeIdentifier() public function provideDataForGetName() { - return array(); + return []; } } diff --git a/tests/lib/REST/Common/FieldTypeProcessor/XmlTextProcessorTest.php b/tests/lib/REST/Common/FieldTypeProcessor/XmlTextProcessorTest.php index a1bc768b..44aec40d 100644 --- a/tests/lib/REST/Common/FieldTypeProcessor/XmlTextProcessorTest.php +++ b/tests/lib/REST/Common/FieldTypeProcessor/XmlTextProcessorTest.php @@ -20,12 +20,12 @@ public function fieldSettingsHashes() { return [ [ - array('tagPreset' => 'TAG_PRESET_DEFAULT'), - array('tagPreset' => Type::TAG_PRESET_DEFAULT), + ['tagPreset' => 'TAG_PRESET_DEFAULT'], + ['tagPreset' => Type::TAG_PRESET_DEFAULT], ], [ - array('tagPreset' => 'TAG_PRESET_SIMPLE_FORMATTING'), - array('tagPreset' => Type::TAG_PRESET_SIMPLE_FORMATTING), + ['tagPreset' => 'TAG_PRESET_SIMPLE_FORMATTING'], + ['tagPreset' => Type::TAG_PRESET_SIMPLE_FORMATTING], ], ]; } diff --git a/tests/lib/XmlTextAPIIntegrationTest.php b/tests/lib/XmlTextAPIIntegrationTest.php index 68933c8a..533d7c42 100644 --- a/tests/lib/XmlTextAPIIntegrationTest.php +++ b/tests/lib/XmlTextAPIIntegrationTest.php @@ -79,36 +79,36 @@ public function getCreateExpectedRelations(Content $content) { $contentService = $this->getRepository()->getContentService(); - return array( + return [ new Relation( - array( + [ 'type' => Relation::LINK, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(56), - ) + ] ), new Relation( - array( + [ 'type' => Relation::LINK, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(54), - ) + ] ), new Relation( - array( + [ 'type' => Relation::EMBED, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(58), - ) + ] ), new Relation( - array( + [ 'type' => Relation::EMBED, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(56), - ) + ] ), - ); + ]; } /** @@ -120,22 +120,22 @@ public function getUpdateExpectedRelations(Content $content) { $contentService = $this->getRepository()->getContentService(); - return array( + return [ new Relation( - array( + [ 'type' => Relation::LINK, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(58), - ) + ] ), new Relation( - array( + [ 'type' => Relation::EMBED, 'sourceContentInfo' => $content->contentInfo, 'destinationContentInfo' => $contentService->loadContentInfo(56), - ) + ] ), - ); + ]; } /** @@ -155,16 +155,16 @@ public function getTypeName() */ public function getSettingsSchema() { - return array( - 'numRows' => array( + return [ + 'numRows' => [ 'type' => 'int', 'default' => 10, - ), - 'tagPreset' => array( + ], + 'tagPreset' => [ 'type' => 'choice', 'default' => XmlTextType::TAG_PRESET_DEFAULT, - ), - ); + ], + ]; } /** @@ -174,10 +174,10 @@ public function getSettingsSchema() */ public function getValidFieldSettings() { - return array( + return [ 'numRows' => 0, 'tagPreset' => XmlTextType::TAG_PRESET_DEFAULT, - ); + ]; } /** @@ -187,9 +187,9 @@ public function getValidFieldSettings() */ public function getInvalidFieldSettings() { - return array( + return [ 'somethingUnknown' => 0, - ); + ]; } /** @@ -199,7 +199,7 @@ public function getInvalidFieldSettings() */ public function getValidatorSchema() { - return array(); + return []; } /** @@ -209,7 +209,7 @@ public function getValidatorSchema() */ public function getValidValidatorConfiguration() { - return array(); + return []; } /** @@ -219,9 +219,9 @@ public function getValidValidatorConfiguration() */ public function getInvalidValidatorConfiguration() { - return array( - 'unknown' => array('value' => 23), - ); + return [ + 'unknown' => ['value' => 23], + ]; } /** @@ -275,9 +275,9 @@ public function assertFieldDataLoadedCorrect(Field $field) ); $this->assertPropertiesCorrect( - array( + [ 'xml' => $this->createdDOMValue, - ), + ], $field->value ); } @@ -305,12 +305,12 @@ public function assertFieldDataLoadedCorrect(Field $field) */ public function provideInvalidCreationFieldData() { - return array( - array( + return [ + [ new \stdClass(), InvalidArgumentType::class, - ), - ); + ], + ]; } /** @@ -338,9 +338,9 @@ public function assertUpdatedFieldDataLoadedCorrect(Field $field) ); $this->assertPropertiesCorrect( - array( + [ 'xml' => $this->updatedDOMValue, - ), + ], $field->value ); } @@ -387,9 +387,9 @@ public function assertCopiedFieldDataLoadedCorrectly(Field $field) ); $this->assertPropertiesCorrect( - array( + [ 'xml' => $this->createdDOMValue, - ), + ], $field->value ); } @@ -425,12 +425,12 @@ public function provideToHashData() EOT ); - return array( - array( + return [ + [ new XmlTextValue($xml), - array('xml' => $xml->saveXML()), - ), - ); + ['xml' => $xml->saveXML()], + ], + ]; } /** @@ -442,17 +442,17 @@ public function provideToHashData() */ public function provideFromHashData() { - return array( - array( - array( + return [ + [ + [ 'xml' => '
Foobar
', - ), - ), - ); + ], + ], + ]; } /** @@ -481,10 +481,10 @@ public function providerForTestIsEmptyValue() $doc = new DOMDocument(); $doc->loadXML('
'); - return array( - array(new XmlTextValue()), - array(new XmlTextValue($doc)), - ); + return [ + [new XmlTextValue()], + [new XmlTextValue($doc)], + ]; } public function providerForTestIsNotEmptyValue() @@ -494,13 +494,13 @@ public function providerForTestIsNotEmptyValue() $doc2 = new DOMDocument(); $doc2->loadXML('
'); - return array( - array( + return [ + [ $this->getValidCreationFieldData(), - ), - array(new XmlTextValue($doc)), - array(new XmlTextValue($doc2)), - ); + ], + [new XmlTextValue($doc)], + [new XmlTextValue($doc2)], + ]; } /** @@ -515,8 +515,8 @@ public function providerForTestConvertRemoteObjectIdToObjectId() $remote_id = '[RemoteId]'; $object_id = '[ObjectId]'; - return array( - array( + return [ + [ // test link '
@@ -528,8 +528,8 @@ public function providerForTestConvertRemoteObjectIdToObjectId() link
', - ), - array( + ], + [ // test embed '
@@ -541,8 +541,8 @@ public function providerForTestConvertRemoteObjectIdToObjectId()
', - ), - array( + ], + [ // test embed-inline '
@@ -554,8 +554,8 @@ public function providerForTestConvertRemoteObjectIdToObjectId()
', - ), - ); + ], + ]; } /** @@ -580,7 +580,7 @@ public function testConvertRemoteObjectIdToObjectId($test, $expected) $createStruct->setField('name', 'Folder Link'); $draft = $contentService->createContent( $createStruct, - array($locationService->newLocationCreateStruct(2)) + [$locationService->newLocationCreateStruct(2)] ); $target = $contentService->publishVersion( @@ -604,7 +604,7 @@ public function testConvertRemoteObjectIdToObjectId($test, $expected) ); $test = $contentService->createContent( $testStruct, - array($locationService->newLocationCreateStruct($node_id)) + [$locationService->newLocationCreateStruct($node_id)] ); $this->assertEquals( @@ -615,7 +615,7 @@ public function testConvertRemoteObjectIdToObjectId($test, $expected) protected function checkSearchEngineSupport() { - if (ltrim(get_class($this->getSetupFactory()), '\\') === LegacySetupFactory::class) { + if (ltrim(\get_class($this->getSetupFactory()), '\\') === LegacySetupFactory::class) { $this->markTestSkipped( "'ezxmltext' field type is not searchable with Legacy Search Engine" ); @@ -656,8 +656,8 @@ protected function getSearchTargetValueTwo() protected function getFullTextIndexedFieldData() { - return array( - array('mediocrity', 'analysis'), - ); + return [ + ['mediocrity', 'analysis'], + ]; } } diff --git a/tests/lib/XmlTextSPIIntegrationTest.php b/tests/lib/XmlTextSPIIntegrationTest.php index cc04fc70..3b7a52bb 100644 --- a/tests/lib/XmlTextSPIIntegrationTest.php +++ b/tests/lib/XmlTextSPIIntegrationTest.php @@ -96,24 +96,24 @@ public function getTypeConstraints() */ public function getFieldDefinitionData() { - return array( + return [ // The ezxmltext field type does not have any special field definition // properties - array('fieldType', 'ezxmltext'), - array( + ['fieldType', 'ezxmltext'], + [ 'fieldTypeConstraints', new FieldTypeConstraints( - array( + [ 'fieldSettings' => new FieldSettings( - array( + [ 'numRows' => 0, 'tagPreset' => null, - ) + ] ), - ) + ] ), - ), - ); + ], + ]; } /** @@ -126,11 +126,11 @@ public function getInitialValue() $xml = '
Paragraph content…
'; return new FieldValue( - array( + [ 'data' => $xml, 'externalData' => null, 'sortKey' => null, - ) + ] ); } @@ -146,11 +146,11 @@ public function getUpdatedValue() $xml = '
Some different content…
'; return new FieldValue( - array( + [ 'data' => $xml, 'externalData' => null, 'sortKey' => null, - ) + ] ); } }