diff --git a/src/DependencyInjection/CmfCoreExtension.php b/src/DependencyInjection/CmfCoreExtension.php index e86eb535..1db99c8d 100644 --- a/src/DependencyInjection/CmfCoreExtension.php +++ b/src/DependencyInjection/CmfCoreExtension.php @@ -38,9 +38,9 @@ public function prepend(ContainerBuilder $container) $extensions = $container->getExtensions(); if (isset($config['multilang']['locales'], $extensions['cmf_routing'])) { - $container->prependExtensionConfig('cmf_routing', array( - 'dynamic' => array('locales' => $config['multilang']['locales']), - )); + $container->prependExtensionConfig('cmf_routing', [ + 'dynamic' => ['locales' => $config['multilang']['locales']], + ]); } if ($config['persistence']['phpcr']) { @@ -48,90 +48,90 @@ public function prepend(ContainerBuilder $container) $persistenceConfig = $config['persistence']['phpcr']; foreach ($container->getExtensions() as $name => $extension) { - $prependConfig = array(); + $prependConfig = []; switch ($name) { case 'cmf_block': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'block_basepath' => $persistenceConfig['basepath'].'/content', 'manager_name' => $persistenceConfig['manager_name'], - ), - ), - ); + ], + ], + ]; break; case 'cmf_content': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'content_basepath' => $persistenceConfig['basepath'].'/content', - ), - ), - ); + ], + ], + ]; break; case 'cmf_create': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], - ), - ), - ); + ], + ], + ]; // if cmf_media is there, it will prepend the image path to its media_basepath // setting. if (!isset($extensions['cmf_media'])) { - $prependConfig['persistence']['phpcr']['image'] = array( + $prependConfig['persistence']['phpcr']['image'] = [ 'enabled' => false, 'basepath' => $persistenceConfig['basepath'].'/media', - ); + ]; } break; case 'cmf_media': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'media_basepath' => $persistenceConfig['basepath'].'/media', 'manager_name' => $persistenceConfig['manager_name'], - ), - ), - ); + ], + ], + ]; break; case 'cmf_menu': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'content_basepath' => $persistenceConfig['basepath'].'/content', 'menu_basepath' => $persistenceConfig['basepath'].'/menu', 'manager_name' => $persistenceConfig['manager_name'], - ), - ), - ); + ], + ], + ]; break; case 'cmf_routing': - $routePaths = array($persistenceConfig['basepath'].'/routes'); - $prependConfig = array( - 'dynamic' => array( + $routePaths = [$persistenceConfig['basepath'].'/routes']; + $prependConfig = [ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'phpcr' => array( + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'content_basepath' => $persistenceConfig['basepath'].'/content', 'route_basepaths' => $routePaths, 'manager_name' => $persistenceConfig['manager_name'], - ), - ), - ), - ); + ], + ], + ], + ]; if (isset($bundles['CmfContentBundle'])) { $prependConfig['dynamic']['generic_controller'] = 'cmf_content.controller:indexAction'; @@ -139,63 +139,63 @@ public function prepend(ContainerBuilder $container) break; case 'cmf_routing_auto': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'route_basepath' => $persistenceConfig['basepath'].'/routes', - ), - ), - ); + ], + ], + ]; break; case 'cmf_search': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'search_basepath' => $persistenceConfig['basepath'].'/content', 'manager_name' => $persistenceConfig['manager_name'], 'manager_registry' => $persistenceConfig['manager_registry'], - ), - ), - ); + ], + ], + ]; if (!empty($persistenceConfig['translation_strategy'])) { $prependConfig['persistence']['phpcr']['translation_strategy'] = $persistenceConfig['translation_strategy']; } break; case 'cmf_simple_cms': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], 'basepath' => $persistenceConfig['basepath'].'/simple', 'manager_name' => $persistenceConfig['manager_name'], 'manager_registry' => $persistenceConfig['manager_registry'], - ), - ), - ); + ], + ], + ]; break; case 'cmf_tree_browser': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], - ), - ), - ); + ], + ], + ]; break; case 'cmf_seo': - $prependConfig = array( - 'persistence' => array( - 'phpcr' => array( + $prependConfig = [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => $persistenceConfig['enabled'], - ), - ), - ); + ], + ], + ]; break; } @@ -211,21 +211,21 @@ public function prepend(ContainerBuilder $container) $persistenceConfig = $config['persistence']['orm']; foreach ($container->getExtensions() as $name => $extension) { - $prependConfig = array(); + $prependConfig = []; switch ($name) { case 'cmf_routing': - $prependConfig = array( - 'dynamic' => array( + $prependConfig = [ + 'dynamic' => [ 'enabled' => true, - 'persistence' => array( - 'orm' => array( + 'persistence' => [ + 'orm' => [ 'enabled' => $persistenceConfig['enabled'], 'manager_name' => $persistenceConfig['manager_name'], - ), - ), - ), - ); + ], + ], + ], + ]; if (isset($bundles['CmfContentBundle'])) { $prependConfig['dynamic']['generic_controller'] = 'cmf_content.controller:indexAction'; @@ -233,13 +233,13 @@ public function prepend(ContainerBuilder $container) break; case 'cmf_seo': - $prependConfig = array( - 'persistence' => array( - 'orm' => array( + $prependConfig = [ + 'persistence' => [ + 'orm' => [ 'enabled' => $persistenceConfig['enabled'], - ), - ), - ); + ], + ], + ]; break; } @@ -265,10 +265,10 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter($this->getAlias().'.persistence.phpcr.basepath', $config['persistence']['phpcr']['basepath']); $templatingHelper = $container->getDefinition($this->getAlias().'.templating.helper'); - $templatingHelper->addMethodCall('setDoctrineRegistry', array( + $templatingHelper->addMethodCall('setDoctrineRegistry', [ new Reference($config['persistence']['phpcr']['manager_registry']), '%cmf_core.persistence.phpcr.manager_name%', - )); + ]); } if ($config['publish_workflow']['enabled']) { $this->loadPublishWorkflow($config['publish_workflow'], $loader, $container); @@ -306,7 +306,7 @@ public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loa // if there is twig, register our form type with twig if ($container->hasParameter('twig.form.resources')) { $resources = $container->getParameter('twig.form.resources'); - $container->setParameter('twig.form.resources', array_merge($resources, array('CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig'))); + $container->setParameter('twig.form.resources', array_merge($resources, ['CmfCoreBundle:Form:checkbox_url_label_form_type.html.twig'])); } } } diff --git a/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index c94dad48..f078d57e 100644 --- a/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -70,7 +70,7 @@ public function process(ContainerBuilder $container) $chainDriverDefService = $this->getChainDriverServiceName($container); $chainDriverDef = $container->getDefinition($chainDriverDefService); foreach ($this->namespaces as $namespace) { - $chainDriverDef->addMethodCall('addDriver', array($this->driver, $namespace)); + $chainDriverDef->addMethodCall('addDriver', [$this->driver, $namespace]); } } @@ -107,11 +107,11 @@ protected function getChainDriverServiceName(ContainerBuilder $container) * enable the mapping. Set to false to not do any check, * optional */ - public static function createXmlMappingDriver(array $mappings, array $managerParameters = array(), $enabledParameter = false) + public static function createXmlMappingDriver(array $mappings, array $managerParameters = [], $enabledParameter = false) { - $arguments = array($mappings, '.orm.xml'); + $arguments = [$mappings, '.orm.xml']; $locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments); - $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', array($locator)); + $driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', [$locator]); return new self($driver, $mappings, $managerParameters, $enabledParameter); } diff --git a/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php b/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php index 4ecc1556..65f3ffb8 100644 --- a/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php +++ b/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php @@ -28,9 +28,9 @@ class NonTranslatableMetadataListener implements EventSubscriber */ public function getSubscribedEvents() { - return array( + return [ 'loadClassMetadata', - ); + ]; } /** @@ -51,7 +51,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) foreach ($meta->translatableFields as $field) { unset($meta->mappings[$field]['translated']); } - $meta->translatableFields = array(); + $meta->translatableFields = []; if (null !== $meta->localeMapping) { unset($meta->mappings[$meta->localeMapping]); $meta->localeMapping = null; diff --git a/src/Doctrine/Phpcr/TranslatableMetadataListener.php b/src/Doctrine/Phpcr/TranslatableMetadataListener.php index 4168d0f7..abd7ace1 100644 --- a/src/Doctrine/Phpcr/TranslatableMetadataListener.php +++ b/src/Doctrine/Phpcr/TranslatableMetadataListener.php @@ -40,9 +40,9 @@ public function __construct($translationStrategy) */ public function getSubscribedEvents() { - return array( + return [ 'loadClassMetadata', - ); + ]; } /** diff --git a/src/EventListener/PublishWorkflowListener.php b/src/EventListener/PublishWorkflowListener.php index 74260621..4a23ba49 100644 --- a/src/EventListener/PublishWorkflowListener.php +++ b/src/EventListener/PublishWorkflowListener.php @@ -91,8 +91,8 @@ public function onKernelRequest(GetResponseEvent $event) */ public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array(array('onKernelRequest', 1)), - ); + return [ + KernelEvents::REQUEST => [['onKernelRequest', 1]], + ]; } } diff --git a/src/Form/Type/CheckboxUrlLabelFormType.php b/src/Form/Type/CheckboxUrlLabelFormType.php index 0d038fac..5a8f2ff1 100644 --- a/src/Form/Type/CheckboxUrlLabelFormType.php +++ b/src/Form/Type/CheckboxUrlLabelFormType.php @@ -54,10 +54,10 @@ public function __construct(RouterInterface $router) public function buildView(FormView $view, FormInterface $form, array $options) { $routes = $options['routes']; - $paths = array(); + $paths = []; foreach ($routes as $key => $route) { $name = isset($route['name']) ? $route['name'] : null; - $parameters = isset($route['parameters']) ? $route['parameters'] : array(); + $parameters = isset($route['parameters']) ? $route['parameters'] : []; $referenceType = isset($route['referenceType']) ? $route['referenceType'] : UrlGeneratorInterface::ABSOLUTE_PATH; $paths[$key] = $this->router->generate($name, $parameters, $referenceType); } @@ -75,9 +75,9 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( - 'routes' => array(), - )); + $resolver->setDefaults([ + 'routes' => [], + ]); } /** diff --git a/src/PublishWorkflow/PublishWorkflowChecker.php b/src/PublishWorkflow/PublishWorkflowChecker.php index ffacfbc0..3935f6d2 100644 --- a/src/PublishWorkflow/PublishWorkflowChecker.php +++ b/src/PublishWorkflow/PublishWorkflowChecker.php @@ -112,7 +112,7 @@ public function supportsClass($class) public function isGranted($attributes, $object = null) { if (!is_array($attributes)) { - $attributes = array($attributes); + $attributes = [$attributes]; } if (1 === count($attributes) diff --git a/src/Templating/Helper/CmfHelper.php b/src/Templating/Helper/CmfHelper.php index 67dd15c7..f88f4ccc 100644 --- a/src/Templating/Helper/CmfHelper.php +++ b/src/Templating/Helper/CmfHelper.php @@ -221,13 +221,13 @@ private function getDocument($document, $ignoreRole = false, $class = null) * * @return array */ - public function findMany($paths = array(), $limit = false, $offset = false, $ignoreRole = false, $class = null) + public function findMany($paths = [], $limit = false, $offset = false, $ignoreRole = false, $class = null) { if ($offset) { $paths = array_slice($paths, $offset); } - $result = array(); + $result = []; foreach ($paths as $path) { $document = $this->getDocument($path, $ignoreRole, $class); if (null === $document) { @@ -284,13 +284,13 @@ public function getLocalesFor($document, $includeFallbacks = false) } if (empty($document)) { - return array(); + return []; } try { $locales = $this->getDm()->getLocalesFor($document, $includeFallbacks); } catch (MissingTranslationException $e) { - $locales = array(); + $locales = []; } return $locales; @@ -335,7 +335,7 @@ public function getChild($parent, $name) public function getChildren($parent, $limit = false, $offset = false, $filter = null, $ignoreRole = false, $class = null) { if (empty($parent)) { - return array(); + return []; } if (is_object($parent)) { @@ -354,12 +354,12 @@ public function getChildren($parent, $limit = false, $offset = false, $filter = if ($offset) { $key = array_search($offset, $children); if (false === $key) { - return array(); + return []; } $children = array_slice($children, $key); } - $result = array(); + $result = []; foreach ($children as $name => $child) { // if we requested all children above, we did not filter yet if (strpos($name, 'phpcr_locale:') === 0) { @@ -478,10 +478,10 @@ private function getChildrenPaths($path, array &$children, $depth) public function getDescendants($parent, $depth = null) { if (empty($parent)) { - return array(); + return []; } - $children = array(); + $children = []; if (is_object($parent)) { $parent = $this->getDm()->getUnitOfWork()->getDocumentId($parent); } diff --git a/src/Twig/Extension/CmfExtension.php b/src/Twig/Extension/CmfExtension.php index ff2453b6..1c9b360c 100644 --- a/src/Twig/Extension/CmfExtension.php +++ b/src/Twig/Extension/CmfExtension.php @@ -29,29 +29,29 @@ public function __construct(CmfHelper $helper) */ public function getFunctions() { - $functions = array( - new \Twig_SimpleFunction('cmf_is_published', array($this, 'isPublished')), - new \Twig_SimpleFunction('cmf_child', array($this, 'getChild')), - new \Twig_SimpleFunction('cmf_children', array($this, 'getChildren')), - new \Twig_SimpleFunction('cmf_prev', array($this, 'getPrev')), - new \Twig_SimpleFunction('cmf_next', array($this, 'getNext')), - new \Twig_SimpleFunction('cmf_find', array($this, 'find')), - new \Twig_SimpleFunction('cmf_find_translation', array($this, 'findTranslation')), - new \Twig_SimpleFunction('cmf_find_many', array($this, 'findMany')), - new \Twig_SimpleFunction('cmf_descendants', array($this, 'getDescendants')), - new \Twig_SimpleFunction('cmf_nodename', array($this, 'getNodeName')), - new \Twig_SimpleFunction('cmf_parent_path', array($this, 'getParentPath')), - new \Twig_SimpleFunction('cmf_path', array($this, 'getPath')), - new \Twig_SimpleFunction('cmf_document_locales', array($this, 'getLocalesFor')), - ); + $functions = [ + new \Twig_SimpleFunction('cmf_is_published', [$this, 'isPublished']), + new \Twig_SimpleFunction('cmf_child', [$this, 'getChild']), + new \Twig_SimpleFunction('cmf_children', [$this, 'getChildren']), + new \Twig_SimpleFunction('cmf_prev', [$this, 'getPrev']), + new \Twig_SimpleFunction('cmf_next', [$this, 'getNext']), + new \Twig_SimpleFunction('cmf_find', [$this, 'find']), + new \Twig_SimpleFunction('cmf_find_translation', [$this, 'findTranslation']), + new \Twig_SimpleFunction('cmf_find_many', [$this, 'findMany']), + new \Twig_SimpleFunction('cmf_descendants', [$this, 'getDescendants']), + new \Twig_SimpleFunction('cmf_nodename', [$this, 'getNodeName']), + new \Twig_SimpleFunction('cmf_parent_path', [$this, 'getParentPath']), + new \Twig_SimpleFunction('cmf_path', [$this, 'getPath']), + new \Twig_SimpleFunction('cmf_document_locales', [$this, 'getLocalesFor']), + ]; if (interface_exists('Symfony\Cmf\Component\Routing\RouteReferrersReadInterface')) { - $functions = array_merge($functions, array( - new \Twig_SimpleFunction('cmf_is_linkable', array($this, 'isLinkable')), - new \Twig_SimpleFunction('cmf_prev_linkable', array($this, 'getPrevLinkable')), - new \Twig_SimpleFunction('cmf_next_linkable', array($this, 'getNextLinkable')), - new \Twig_SimpleFunction('cmf_linkable_children', array($this, 'getLinkableChildren')), - )); + $functions = array_merge($functions, [ + new \Twig_SimpleFunction('cmf_is_linkable', [$this, 'isLinkable']), + new \Twig_SimpleFunction('cmf_prev_linkable', [$this, 'getPrevLinkable']), + new \Twig_SimpleFunction('cmf_next_linkable', [$this, 'getNextLinkable']), + new \Twig_SimpleFunction('cmf_linkable_children', [$this, 'getLinkableChildren']), + ]); } return $functions; @@ -97,7 +97,7 @@ public function findTranslation($path, $locale, $fallback = true) return $this->helper->findTranslation($path, $locale, $fallback); } - public function findMany($paths = array(), $limit = false, $offset = false, $ignoreRole = false, $class = null) + public function findMany($paths = [], $limit = false, $offset = false, $ignoreRole = false, $class = null) { return $this->helper->findMany($paths, $limit, $offset, $ignoreRole, $class); } diff --git a/tests/Functional/DependencyInjection/CmfCoreExtensionTest.php b/tests/Functional/DependencyInjection/CmfCoreExtensionTest.php index 5d97d4d9..073b79d7 100644 --- a/tests/Functional/DependencyInjection/CmfCoreExtensionTest.php +++ b/tests/Functional/DependencyInjection/CmfCoreExtensionTest.php @@ -23,7 +23,7 @@ protected function setUp() { $this->container = new ContainerBuilder(); $this->container->registerExtension(new CmfCoreExtension()); - $this->container->setParameter('kernel.bundles', array('CmfCoreBundle' => true)); + $this->container->setParameter('kernel.bundles', ['CmfCoreBundle' => true]); } public function testPublishWorkflowDisabled() diff --git a/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php b/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php index 5dcdf1eb..b44ef0f5 100644 --- a/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php +++ b/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php @@ -23,7 +23,7 @@ class CheckboxUrlLabelFormTypeTest extends BaseTestCase { public function setUp() { - $this->db('PHPCR')->loadFixtures(array(LoadRouteData::class)); + $this->db('PHPCR')->loadFixtures([LoadRouteData::class]); } public function testFormTwigTemplate() @@ -39,18 +39,18 @@ public function testFormTwigTemplate() } $view = $this->getContainer()->get('form.factory')->createNamedBuilder('name') - ->add('terms', CheckboxUrlLabelFormType::class, array( + ->add('terms', CheckboxUrlLabelFormType::class, [ 'label' => '%a% and %b% and %c%', - 'routes' => array( - '%a%' => array('parameters' => array('content_id' => '/test/content/a')), - '%b%' => array('parameters' => array('content_id' => '/test/content/b')), - '%c%' => array('name' => 'hello', 'parameters' => array('name' => 'world'), 'referenceType' => UrlGeneratorInterface::ABSOLUTE_URL), - ), - )) + 'routes' => [ + '%a%' => ['parameters' => ['content_id' => '/test/content/a']], + '%b%' => ['parameters' => ['content_id' => '/test/content/b']], + '%c%' => ['name' => 'hello', 'parameters' => ['name' => 'world'], 'referenceType' => UrlGeneratorInterface::ABSOLUTE_URL], + ], + ]) ->getForm() ->createView(); - $template = $renderer->searchAndRenderBlock($view, 'widget', array()); + $template = $renderer->searchAndRenderBlock($view, 'widget', []); $this->assertMatchesXpath($template, '//label[@class="checkbox"][contains(.,"/a and /b and http://localhost/hello/world")]'); } diff --git a/tests/Functional/PublishWorkflow/PublishWorkflowTest.php b/tests/Functional/PublishWorkflow/PublishWorkflowTest.php index 03bd6f99..2d30c1b0 100644 --- a/tests/Functional/PublishWorkflow/PublishWorkflowTest.php +++ b/tests/Functional/PublishWorkflow/PublishWorkflowTest.php @@ -66,9 +66,9 @@ public function testIgnoreRoleHas() ->method('isPublishable') ->will($this->returnValue(false)) ; - $roles = array( + $roles = [ new Role('ROLE_CAN_VIEW_NON_PUBLISHED'), - ); + ]; $token = new UsernamePasswordToken('test', 'pass', 'testprovider', $roles); $tokenStorage = $this->getContainer()->get('security.token_storage'); $tokenStorage->setToken($token); @@ -84,9 +84,9 @@ public function testIgnoreRoleNotHas() ->method('isPublishable') ->will($this->returnValue(false)) ; - $roles = array( + $roles = [ new Role('OTHER_ROLE'), - ); + ]; $token = new UsernamePasswordToken('test', 'pass', 'testprovider', $roles); $tokenStorage = $this->getContainer()->get('security.token_storage'); $tokenStorage->setToken($token); diff --git a/tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php b/tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php index 25e2d7ac..9dd83c69 100644 --- a/tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php +++ b/tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php @@ -11,7 +11,9 @@ namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Functional\Templating\Helper; +use Doctrine\ODM\PHPCR\Document\Generic; use Symfony\Cmf\Bundle\CoreBundle\Templating\Helper\CmfHelper; +use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture\LoadHierarchyRouteData; use Symfony\Cmf\Component\Testing\Functional\BaseTestCase; use Symfony\Component\Security\Core\SecurityContextInterface; @@ -30,7 +32,7 @@ class CmfHelperHierarchyTest extends BaseTestCase public function setUp() { $dbManager = $this->db('PHPCR'); - $dbManager->loadFixtures(array('Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture\LoadHierarchyRouteData')); + $dbManager->loadFixtures([LoadHierarchyRouteData::class]); $this->publishWorkflowChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $this->publishWorkflowChecker->expects($this->any()) @@ -44,12 +46,12 @@ public function setUp() public function testGetDescendants() { - $this->assertEquals(array(), $this->helper->getDescendants(null)); + $this->assertEquals([], $this->helper->getDescendants(null)); - $expected = array('/a/b', '/a/b/c', '/a/b/d', '/a/b/e', '/a/f', '/a/f/g', '/a/f/g/h', '/a/i'); + $expected = ['/a/b', '/a/b/c', '/a/b/d', '/a/b/e', '/a/f', '/a/f/g', '/a/f/g/h', '/a/i']; $this->assertEquals($expected, $this->helper->getDescendants('/a')); - $expected = array('/a/b', '/a/f', '/a/i'); + $expected = ['/a/b', '/a/f', '/a/i']; $this->assertEquals($expected, $this->helper->getDescendants('/a', 1)); } @@ -69,33 +71,33 @@ public function testGetPrev($expected, $path, $anchor = null, $depth = null, $cl public static function getPrevData() { - return array( - array(null, null), - array(null, '/a'), - array(null, '/a/b'), - array(null, '/a/b/c'), - array('/a/b/c', '/a/b/d', null, null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array('/a/b/d', '/a/b/e'), - array('/a/b', '/a/f'), - array(null, '/a/f/g'), - array(null, '/a/f/g/h'), - array(null, '/a', '/a'), - array('/a', '/a/b', '/a'), - array('/a/b', '/a/b/c', '/a'), - array('/a/b/c', '/a/b/d', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array('/a/b/d', '/a/b/e', '/a'), - array('/a/b/e', '/a/f', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array('/a/f', '/a/f/g', '/a'), - array('/a/f/g', '/a/f/g/h', '/a'), - array('/a/f/g/h', '/a/i', '/a'), - array('/a/f/g', '/a/i', '/a', 2), - ); + return [ + [null, null], + [null, '/a'], + [null, '/a/b'], + [null, '/a/b/c'], + ['/a/b/c', '/a/b/d', null, null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + ['/a/b/d', '/a/b/e'], + ['/a/b', '/a/f'], + [null, '/a/f/g'], + [null, '/a/f/g/h'], + [null, '/a', '/a'], + ['/a', '/a/b', '/a'], + ['/a/b', '/a/b/c', '/a'], + ['/a/b/c', '/a/b/d', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + ['/a/b/d', '/a/b/e', '/a'], + ['/a/b/e', '/a/f', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + ['/a/f', '/a/f/g', '/a'], + ['/a/f/g', '/a/f/g/h', '/a'], + ['/a/f/g/h', '/a/i', '/a'], + ['/a/f/g', '/a/i', '/a', 2], + ]; } /** * @dataProvider getNextData */ - public function testGetNext($expected, $path, $anchor = null, $depth = null, $class = 'Doctrine\ODM\PHPCR\Document\Generic') + public function testGetNext($expected, $path, $anchor = null, $depth = null, $class = Generic::class) { $next = $this->helper->getNext($path, $anchor, $depth); if (null === $expected) { @@ -108,28 +110,28 @@ public function testGetNext($expected, $path, $anchor = null, $depth = null, $cl public static function getNextData() { - return array( - array(null, null), - array(null, '/a'), - array('/a/f', '/a/b'), - array('/a/b/d', '/a/b/c'), - array('/a/b/e', '/a/b/d', null, null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array(null, '/a/b/e'), - array('/a/i', '/a/f'), - array(null, '/a/f/g'), - array(null, '/a/f/g/h'), - array('/a/b', '/a', '/a'), - array('/a/b/c', '/a/b', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array('/a/b/d', '/a/b/c', '/a'), - array('/a/b/e', '/a/b/d', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'), - array('/a/f', '/a/b/e', '/a'), - array('/a/f/g', '/a/f', '/a'), - array('/a/f/g/h', '/a/f/g', '/a'), - array('/a/i', '/a/f/g/h', '/a'), - array(null, '/a/i', '/a'), - array(null, '/a/b/e', '/a/b'), - array('/a/i', '/a/f/g', '/a', 2), - ); + return [ + [null, null], + [null, '/a'], + ['/a/f', '/a/b'], + ['/a/b/d', '/a/b/c'], + ['/a/b/e', '/a/b/d', null, null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + [null, '/a/b/e'], + ['/a/i', '/a/f'], + [null, '/a/f/g'], + [null, '/a/f/g/h'], + ['/a/b', '/a', '/a'], + ['/a/b/c', '/a/b', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + ['/a/b/d', '/a/b/c', '/a'], + ['/a/b/e', '/a/b/d', '/a', null, 'Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware'], + ['/a/f', '/a/b/e', '/a'], + ['/a/f/g', '/a/f', '/a'], + ['/a/f/g/h', '/a/f/g', '/a'], + ['/a/i', '/a/f/g/h', '/a'], + [null, '/a/i', '/a'], + [null, '/a/b/e', '/a/b'], + ['/a/i', '/a/f/g', '/a', 2], + ]; } /** @@ -149,12 +151,12 @@ public function testGetPrevLinkable($expected, $path, $anchor = null, $depth = n public static function getPrevLinkableData() { // TODO: expand test case - return array( - array(null, null), - array(null, '/a/b/c'), - array('/a/b/c', '/a/b/d'), - array('/a/b/c', '/a/b/e'), - ); + return [ + [null, null], + [null, '/a/b/c'], + ['/a/b/c', '/a/b/d'], + ['/a/b/c', '/a/b/e'], + ]; } /** @@ -174,11 +176,11 @@ public function testGetNextLinkable($expected, $path, $anchor = null, $depth = n public static function getNextLinkableData() { // TODO: expand test case - return array( - array(null, null), - array('/a/b/e', '/a/b/c'), - array('/a/b/e', '/a/b/d'), - array(null, '/a/b/e'), - ); + return [ + [null, null], + ['/a/b/e', '/a/b/c'], + ['/a/b/e', '/a/b/d'], + [null, '/a/b/e'], + ]; } } diff --git a/tests/Resources/Document/RouteAware.php b/tests/Resources/Document/RouteAware.php index 5c37a394..b8befa94 100644 --- a/tests/Resources/Document/RouteAware.php +++ b/tests/Resources/Document/RouteAware.php @@ -29,6 +29,6 @@ public function getId() public function getRoutes() { - return array(1, 2); + return [1, 2]; } } diff --git a/tests/Resources/app/AppKernel.php b/tests/Resources/app/AppKernel.php index 27e869aa..9dd30720 100644 --- a/tests/Resources/app/AppKernel.php +++ b/tests/Resources/app/AppKernel.php @@ -16,12 +16,12 @@ class AppKernel extends TestKernel { public function configure() { - $this->requireBundleSets(array('default', 'phpcr_odm')); + $this->requireBundleSets(['default', 'phpcr_odm']); - $this->addBundles(array( + $this->addBundles([ new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(), new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(), - )); + ]); } public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/tests/Unit/DependencyInjection/XmlSchemaTest.php b/tests/Unit/DependencyInjection/XmlSchemaTest.php index dafe503c..08273d4d 100644 --- a/tests/Unit/DependencyInjection/XmlSchemaTest.php +++ b/tests/Unit/DependencyInjection/XmlSchemaTest.php @@ -19,11 +19,11 @@ public function testSchema() { $xmlFiles = array_map(function ($file) { return __DIR__.'/../../Resources/Fixtures/config/'.$file; - }, array( + }, [ 'config1.xml', 'config2.xml', 'config3.xml', - )); + ]); $this->assertSchemaAcceptsXml($xmlFiles, __DIR__.'/../../../src/Resources/config/schema/core-1.0.xsd'); } diff --git a/tests/Unit/Form/CheckboxUrlLabelFormTypeTest.php b/tests/Unit/Form/CheckboxUrlLabelFormTypeTest.php index be0037bd..d91f753c 100644 --- a/tests/Unit/Form/CheckboxUrlLabelFormTypeTest.php +++ b/tests/Unit/Form/CheckboxUrlLabelFormTypeTest.php @@ -35,7 +35,7 @@ public function getRouteCollection() { } - public function generate($name, $parameters = array(), $absolute = false) + public function generate($name, $parameters = [], $absolute = false) { return '/test/'.$name; } @@ -45,9 +45,9 @@ class CheckboxUrlLabelFormTypeTest extends TypeTestCase { public function testContentPathsAreSet() { - $checkboxUrlLabelForm = $this->factory->create(CheckboxUrlLabelFormType::class, null, array( - 'routes' => array('a' => array('name' => 'a'), 'b' => array('name' => 'b')), - )); + $checkboxUrlLabelForm = $this->factory->create(CheckboxUrlLabelFormType::class, null, [ + 'routes' => ['a' => ['name' => 'a'], 'b' => ['name' => 'b']], + ]); $view = $checkboxUrlLabelForm->createView(); $this->assertSame('/test/a', $view->vars['paths']['a']); @@ -56,10 +56,10 @@ public function testContentPathsAreSet() protected function getExtensions() { - return array_merge(parent::getExtensions(), array( - new PreloadedExtension(array( + return array_merge(parent::getExtensions(), [ + new PreloadedExtension([ CheckboxUrlLabelFormType::class => new CheckboxUrlLabelFormType(new Router()), - ), array()), - )); + ], []), + ]); } } diff --git a/tests/Unit/PublishWorkflow/PublishWorkflowCheckerTest.php b/tests/Unit/PublishWorkflow/PublishWorkflowCheckerTest.php index 93dcb13d..57ea2e8b 100644 --- a/tests/Unit/PublishWorkflow/PublishWorkflowCheckerTest.php +++ b/tests/Unit/PublishWorkflow/PublishWorkflowCheckerTest.php @@ -53,7 +53,7 @@ public function testIsGranted() $this->accessDecisionManager ->shouldReceive('decide')->once() - ->with($token, array(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE), $this->document) + ->with($token, [PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE], $this->document) ->andReturn(true); $this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $this->document)); @@ -68,7 +68,7 @@ public function testNotHasBypassRole() $this->accessDecisionManager ->shouldReceive('decide')->once() - ->with($token, array(PublishWorkflowChecker::VIEW_ATTRIBUTE), $this->document) + ->with($token, [PublishWorkflowChecker::VIEW_ATTRIBUTE], $this->document) ->andReturn(true); $this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->document)); @@ -94,7 +94,7 @@ public function testNoFirewall() $this->accessDecisionManager ->shouldReceive('decide')->once() - ->with(\Mockery::type('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'), array(PublishWorkflowChecker::VIEW_ATTRIBUTE), $this->document) + ->with(\Mockery::type('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken'), [PublishWorkflowChecker::VIEW_ATTRIBUTE], $this->document) ->andReturn(true); $this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->document)); diff --git a/tests/Unit/PublishWorkflow/Voter/PublishTimePeriodVoterTest.php b/tests/Unit/PublishWorkflow/Voter/PublishTimePeriodVoterTest.php index 16dd9284..c37b0f62 100644 --- a/tests/Unit/PublishWorkflow/Voter/PublishTimePeriodVoterTest.php +++ b/tests/Unit/PublishWorkflow/Voter/PublishTimePeriodVoterTest.php @@ -37,65 +37,65 @@ public function setUp() public function providePublishWorkflowChecker() { - return array( - array( + return [ + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'startDate' => new \DateTime('01/01/2000'), 'endDate' => new \DateTime('01/02/2030'), - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_DENIED, 'startDate' => new \DateTime('01/01/2000'), 'endDate' => new \DateTime('01/01/2001'), - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'startDate' => new \DateTime('01/01/2000'), 'endDate' => null, - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_DENIED, 'startDate' => new \DateTime('01/01/2030'), 'endDate' => null, - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'startDate' => null, 'endDate' => new \DateTime('01/01/2030'), - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_DENIED, 'startDate' => null, 'endDate' => new \DateTime('01/01/2000'), - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'startDate' => null, 'endDate' => null, - ), + ], // unsupported attribute - array( + [ 'expected' => VoterInterface::ACCESS_ABSTAIN, 'startDate' => new \DateTime('01/01/2000'), 'endDate' => new \DateTime('01/01/2030'), - 'attributes' => array(PublishWorkflowChecker::VIEW_ATTRIBUTE, 'other'), - ), + 'attributes' => [PublishWorkflowChecker::VIEW_ATTRIBUTE, 'other'], + ], // Test overwrite current time - array( + [ 'expected' => VoterInterface::ACCESS_DENIED, 'startDate' => null, 'endDate' => new \DateTime('01/01/2030'), 'attributes' => PublishWorkflowChecker::VIEW_ATTRIBUTE, 'currentTime' => new \DateTime('02/02/2030'), - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'startDate' => null, 'endDate' => new \DateTime('01/01/2000'), 'attributes' => PublishWorkflowChecker::VIEW_ATTRIBUTE, 'currentTime' => new \DateTime('01/01/1980'), - ), - ); + ], + ]; } /** @@ -128,7 +128,7 @@ public function testUnsupportedClass() $result = $this->voter->vote( $this->token, $this, - array(PublishWorkflowChecker::VIEW_ATTRIBUTE) + [PublishWorkflowChecker::VIEW_ATTRIBUTE] ); $this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result); } diff --git a/tests/Unit/PublishWorkflow/Voter/PublishableVoterTest.php b/tests/Unit/PublishWorkflow/Voter/PublishableVoterTest.php index e75fe156..1ecf2cf6 100644 --- a/tests/Unit/PublishWorkflow/Voter/PublishableVoterTest.php +++ b/tests/Unit/PublishWorkflow/Voter/PublishableVoterTest.php @@ -37,41 +37,41 @@ public function setUp() public function providePublishWorkflowChecker() { - return array( - array( + return [ + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'isPublishable' => true, 'attributes' => PublishWorkflowChecker::VIEW_ATTRIBUTE, - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_DENIED, 'isPublishable' => false, 'attributes' => PublishWorkflowChecker::VIEW_ATTRIBUTE, - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_GRANTED, 'isPublishable' => true, - 'attributes' => array( + 'attributes' => [ PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, PublishWorkflowChecker::VIEW_ATTRIBUTE, - ), - ), - array( + ], + ], + [ 'expected' => VoterInterface::ACCESS_DENIED, 'isPublishable' => false, 'attributes' => PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_ABSTAIN, 'isPublishable' => true, 'attributes' => 'other', - ), - array( + ], + [ 'expected' => VoterInterface::ACCESS_ABSTAIN, 'isPublishable' => true, - 'attributes' => array(PublishWorkflowChecker::VIEW_ATTRIBUTE, 'other'), - ), - ); + 'attributes' => [PublishWorkflowChecker::VIEW_ATTRIBUTE, 'other'], + ], + ]; } /** @@ -96,7 +96,7 @@ public function testUnsupportedClass() $result = $this->voter->vote( $this->token, $this, - array(PublishWorkflowChecker::VIEW_ATTRIBUTE) + [PublishWorkflowChecker::VIEW_ATTRIBUTE] ); $this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result); } diff --git a/tests/Unit/Templating/Helper/CmfHelperTest.php b/tests/Unit/Templating/Helper/CmfHelperTest.php index 281b83f5..41b88867 100644 --- a/tests/Unit/Templating/Helper/CmfHelperTest.php +++ b/tests/Unit/Templating/Helper/CmfHelperTest.php @@ -31,7 +31,7 @@ public function setUp() $this->managerRegistry = $this->getMockBuilder('Doctrine\Bundle\PHPCRBundle\ManagerRegistry') ->disableOriginalConstructor() - ->setMethods(array('getManager')) + ->setMethods(['getManager']) ->getMock() ; @@ -153,7 +153,7 @@ public function testFindTranslation() public function testFindMany() { - $this->assertEquals(array(), $this->extension->findMany()); + $this->assertEquals([], $this->extension->findMany()); } public function testFindManyFilterClass() @@ -166,8 +166,8 @@ public function testFindManyFilterClass() ->will($this->onConsecutiveCalls($documentA, null, $documentA, $documentB)) ; - $this->assertEquals(array(), $this->extension->findMany(array('/foo', 'bar'), false, false, null, 'Exception')); - $this->assertEquals(array($documentA, $documentB), $this->extension->findMany(array('/foo', 'bar'), false, false, null, 'stdClass')); + $this->assertEquals([], $this->extension->findMany(['/foo', 'bar'], false, false, null, 'Exception')); + $this->assertEquals([$documentA, $documentB], $this->extension->findMany(['/foo', 'bar'], false, false, null, 'stdClass')); } public function testFindManyIgnoreRole() @@ -185,7 +185,7 @@ public function testFindManyIgnoreRole() ->will($this->onConsecutiveCalls(false, true)) ; - $this->assertEquals(array($documentB), $this->extension->findMany(array('/foo', '/bar'), false, false, true)); + $this->assertEquals([$documentB], $this->extension->findMany(['/foo', '/bar'], false, false, true)); } public function testFindManyIgnoreWorkflow() @@ -276,7 +276,7 @@ public function testIsLinkable() $content ->expects($this->once()) ->method('getRoutes') - ->will($this->returnValue(array())) + ->will($this->returnValue([])) ; $this->assertFalse($this->extension->isLinkable($content)); @@ -292,7 +292,7 @@ public function testIsLinkable() public function testGetLocalesFor() { - $this->assertEquals(array(), $this->extension->getLocalesFor(null)); + $this->assertEquals([], $this->extension->getLocalesFor(null)); $document = new \stdClass(); @@ -302,7 +302,7 @@ public function testGetLocalesFor() ->will($this->onConsecutiveCalls(null, $document)) ; - $this->assertEquals(array(), $this->extension->getLocalesFor('/foo')); + $this->assertEquals([], $this->extension->getLocalesFor('/foo')); $this->manager->expects($this->once()) ->method('getLocalesFor') @@ -376,7 +376,7 @@ public function testGetChildrenLimitOffset() public function testGetLinkableChildren() { - $this->assertEquals(array(), $this->extension->getLinkableChildren(null)); + $this->assertEquals([], $this->extension->getLinkableChildren(null)); $this->markTestIncomplete('TODO: write test'); } diff --git a/tests/Unit/Twig/Extension/CmfExtensionTest.php b/tests/Unit/Twig/Extension/CmfExtensionTest.php index 85b4a097..4d9d3bf7 100644 --- a/tests/Unit/Twig/Extension/CmfExtensionTest.php +++ b/tests/Unit/Twig/Extension/CmfExtensionTest.php @@ -33,14 +33,14 @@ public function setUp() )->disableOriginalConstructor()->getMock(); $this->cmfExtension = new CmfExtension($this->cmfHelper); - $this->env = new \Twig_Environment(new \Twig_Loader_Array(array())); + $this->env = new \Twig_Environment(new \Twig_Loader_Array([])); $this->env->addExtension($this->cmfExtension); } /** * @dataProvider getFunctionsData */ - public function testFunctions($methodName, array $methodArguments, $helperMethod = null, array $helperArguments = array()) + public function testFunctions($methodName, array $methodArguments, $helperMethod = null, array $helperArguments = []) { if (null === $helperMethod) { $helperMethod = $methodName;