switched array() to []
This commit is contained in:
parent
c7f46e4795
commit
33a001e460
16
.php_cs.dist
16
.php_cs.dist
@ -5,26 +5,26 @@ if (!file_exists(__DIR__.'/src')) {
|
||||
}
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'@PHPUnit48Migration:risky' => true,
|
||||
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
|
||||
'array_syntax' => array('syntax' => 'short'),
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'fopen_flags' => false,
|
||||
'ordered_imports' => true,
|
||||
'protected_to_private' => false,
|
||||
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
|
||||
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
|
||||
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
|
||||
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
|
||||
'phpdoc_types_order' => array('null_adjustment' => 'always_last', 'sort_algorithm' => 'none'),
|
||||
))
|
||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->append(array(__FILE__))
|
||||
->exclude(array(
|
||||
->append([__FILE__])
|
||||
->exclude([
|
||||
// directories containing files with content that is autogenerated by `var_export`, which breaks CS in output code
|
||||
'Symfony/Component/DependencyInjection/Tests/Fixtures',
|
||||
'Symfony/Component/Routing/Tests/Fixtures/dumper',
|
||||
@ -38,7 +38,7 @@ return PhpCsFixer\Config::create()
|
||||
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
|
||||
// explicit trigger_error tests
|
||||
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
|
||||
))
|
||||
])
|
||||
// Support for older PHPunit version
|
||||
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
|
||||
// file content autogenerated by `var_export`
|
||||
|
@ -27,8 +27,8 @@ class ContainerAwareEventManager extends EventManager
|
||||
*
|
||||
* <event> => <listeners>
|
||||
*/
|
||||
private $listeners = array();
|
||||
private $initialized = array();
|
||||
private $listeners = [];
|
||||
private $initialized = [];
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
|
@ -33,7 +33,7 @@ class DoctrineDataCollector extends DataCollector
|
||||
/**
|
||||
* @var DebugStack[]
|
||||
*/
|
||||
private $loggers = array();
|
||||
private $loggers = [];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
@ -58,24 +58,24 @@ class DoctrineDataCollector extends DataCollector
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
$queries = array();
|
||||
$queries = [];
|
||||
foreach ($this->loggers as $name => $logger) {
|
||||
$queries[$name] = $this->sanitizeQueries($name, $logger->queries);
|
||||
}
|
||||
|
||||
$this->data = array(
|
||||
$this->data = [
|
||||
'queries' => $queries,
|
||||
'connections' => $this->connections,
|
||||
'managers' => $this->managers,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->data = array();
|
||||
$this->data = [];
|
||||
|
||||
foreach ($this->loggers as $logger) {
|
||||
$logger->queries = array();
|
||||
$logger->queries = [];
|
||||
$logger->currentQuery = 0;
|
||||
}
|
||||
}
|
||||
@ -133,10 +133,10 @@ class DoctrineDataCollector extends DataCollector
|
||||
{
|
||||
$query['explainable'] = true;
|
||||
if (null === $query['params']) {
|
||||
$query['params'] = array();
|
||||
$query['params'] = [];
|
||||
}
|
||||
if (!\is_array($query['params'])) {
|
||||
$query['params'] = array($query['params']);
|
||||
$query['params'] = [$query['params']];
|
||||
}
|
||||
foreach ($query['params'] as $j => $param) {
|
||||
if (isset($query['types'][$j])) {
|
||||
@ -184,12 +184,12 @@ class DoctrineDataCollector extends DataCollector
|
||||
$className = \get_class($var);
|
||||
|
||||
return method_exists($var, '__toString') ?
|
||||
array(sprintf('Object(%s): "%s"', $className, $var->__toString()), false) :
|
||||
array(sprintf('Object(%s)', $className), false);
|
||||
[sprintf('Object(%s): "%s"', $className, $var->__toString()), false] :
|
||||
[sprintf('Object(%s)', $className), false];
|
||||
}
|
||||
|
||||
if (\is_array($var)) {
|
||||
$a = array();
|
||||
$a = [];
|
||||
$original = true;
|
||||
foreach ($var as $k => $v) {
|
||||
list($value, $orig) = $this->sanitizeParam($v);
|
||||
@ -197,13 +197,13 @@ class DoctrineDataCollector extends DataCollector
|
||||
$a[$k] = $value;
|
||||
}
|
||||
|
||||
return array($a, $original);
|
||||
return [$a, $original];
|
||||
}
|
||||
|
||||
if (\is_resource($var)) {
|
||||
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
|
||||
return [sprintf('Resource(%s)', get_resource_type($var)), false];
|
||||
}
|
||||
|
||||
return array($var, true);
|
||||
return [$var, true];
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
/**
|
||||
* Used inside metadata driver method to simplify aggregation of data.
|
||||
*/
|
||||
protected $aliasMap = array();
|
||||
protected $aliasMap = [];
|
||||
|
||||
/**
|
||||
* Used inside metadata driver method to simplify aggregation of data.
|
||||
*/
|
||||
protected $drivers = array();
|
||||
protected $drivers = [];
|
||||
|
||||
/**
|
||||
* @param array $objectManager A configured object manager
|
||||
@ -46,10 +46,10 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
// automatically register bundle mappings
|
||||
foreach (array_keys($container->getParameter('kernel.bundles')) as $bundle) {
|
||||
if (!isset($objectManager['mappings'][$bundle])) {
|
||||
$objectManager['mappings'][$bundle] = array(
|
||||
$objectManager['mappings'][$bundle] = [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,11 +59,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
continue;
|
||||
}
|
||||
|
||||
$mappingConfig = array_replace(array(
|
||||
$mappingConfig = array_replace([
|
||||
'dir' => false,
|
||||
'type' => false,
|
||||
'prefix' => false,
|
||||
), (array) $mappingConfig);
|
||||
], (array) $mappingConfig);
|
||||
|
||||
$mappingConfig['dir'] = $container->getParameterBag()->resolveValue($mappingConfig['dir']);
|
||||
// a bundle configuration is detected by realizing that the specified dir is not absolute and existing
|
||||
@ -153,7 +153,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
}
|
||||
|
||||
if (!$bundleConfig['dir']) {
|
||||
if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
|
||||
if (\in_array($bundleConfig['type'], ['annotation', 'staticphp'])) {
|
||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
|
||||
} else {
|
||||
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
|
||||
@ -197,25 +197,25 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
}
|
||||
$mappingDriverDef->setArguments($args);
|
||||
} elseif ('annotation' == $driverType) {
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
|
||||
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
|
||||
array_values($driverPaths),
|
||||
));
|
||||
]);
|
||||
} else {
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array(
|
||||
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
|
||||
array_values($driverPaths),
|
||||
));
|
||||
]);
|
||||
}
|
||||
$mappingDriverDef->setPublic(false);
|
||||
if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) {
|
||||
$mappingDriverDef->setArguments(array(array_flip($driverPaths)));
|
||||
$mappingDriverDef->addMethodCall('setGlobalBasename', array('mapping'));
|
||||
$mappingDriverDef->setArguments([array_flip($driverPaths)]);
|
||||
$mappingDriverDef->addMethodCall('setGlobalBasename', ['mapping']);
|
||||
}
|
||||
|
||||
$container->setDefinition($mappingService, $mappingDriverDef);
|
||||
|
||||
foreach ($driverPaths as $prefix => $driverPath) {
|
||||
$chainDriverDef->addMethodCall('addDriver', array(new Reference($mappingService), $prefix));
|
||||
$chainDriverDef->addMethodCall('addDriver', [new Reference($mappingService), $prefix]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
|
||||
}
|
||||
|
||||
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
|
||||
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp'])) {
|
||||
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
|
||||
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
|
||||
'You can register them by adding a new driver to the '.
|
||||
@ -326,11 +326,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
$cacheDef = new Definition($memcacheClass);
|
||||
$memcacheInstance = new Definition($memcacheInstanceClass);
|
||||
$memcacheInstance->setPrivate(true);
|
||||
$memcacheInstance->addMethodCall('connect', array(
|
||||
$memcacheInstance->addMethodCall('connect', [
|
||||
$memcacheHost, $memcachePort,
|
||||
));
|
||||
]);
|
||||
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)), $memcacheInstance);
|
||||
$cacheDef->addMethodCall('setMemcache', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)))));
|
||||
$cacheDef->addMethodCall('setMemcache', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManagerName)))]);
|
||||
break;
|
||||
case 'memcached':
|
||||
$memcachedClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcached.class').'%';
|
||||
@ -340,11 +340,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
$cacheDef = new Definition($memcachedClass);
|
||||
$memcachedInstance = new Definition($memcachedInstanceClass);
|
||||
$memcachedInstance->setPrivate(true);
|
||||
$memcachedInstance->addMethodCall('addServer', array(
|
||||
$memcachedInstance->addMethodCall('addServer', [
|
||||
$memcachedHost, $memcachedPort,
|
||||
));
|
||||
]);
|
||||
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)), $memcachedInstance);
|
||||
$cacheDef->addMethodCall('setMemcached', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))));
|
||||
$cacheDef->addMethodCall('setMemcached', [new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManagerName)))]);
|
||||
break;
|
||||
case 'redis':
|
||||
$redisClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.redis.class').'%';
|
||||
@ -354,11 +354,11 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
$cacheDef = new Definition($redisClass);
|
||||
$redisInstance = new Definition($redisInstanceClass);
|
||||
$redisInstance->setPrivate(true);
|
||||
$redisInstance->addMethodCall('connect', array(
|
||||
$redisInstance->addMethodCall('connect', [
|
||||
$redisHost, $redisPort,
|
||||
));
|
||||
]);
|
||||
$container->setDefinition($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)), $redisInstance);
|
||||
$cacheDef->addMethodCall('setRedis', array(new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))));
|
||||
$cacheDef->addMethodCall('setRedis', [new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManagerName)))]);
|
||||
break;
|
||||
case 'apc':
|
||||
case 'apcu':
|
||||
@ -387,7 +387,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
$cacheDriver['namespace'] = $namespace;
|
||||
}
|
||||
|
||||
$cacheDef->addMethodCall('setNamespace', array($cacheDriver['namespace']));
|
||||
$cacheDef->addMethodCall('setNamespace', [$cacheDriver['namespace']]);
|
||||
|
||||
$container->setDefinition($cacheDriverServiceId, $cacheDef);
|
||||
|
||||
@ -410,10 +410,10 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$managerConfigs[$autoMappedManager]['mappings'][$bundle] = array(
|
||||
$managerConfigs[$autoMappedManager]['mappings'][$bundle] = [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
);
|
||||
];
|
||||
}
|
||||
$managerConfigs[$autoMappedManager]['auto_mapping'] = false;
|
||||
}
|
||||
|
@ -65,13 +65,13 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
|
||||
foreach ($taggedSubscribers as $taggedSubscriber) {
|
||||
list($id, $tag) = $taggedSubscriber;
|
||||
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
|
||||
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
|
||||
foreach ($connections as $con) {
|
||||
if (!isset($this->connections[$con])) {
|
||||
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
|
||||
}
|
||||
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', array(new Reference($id)));
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', [new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
|
||||
}
|
||||
|
||||
$connections = isset($tag['connection']) ? array($tag['connection']) : array_keys($this->connections);
|
||||
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
|
||||
foreach ($connections as $con) {
|
||||
if (!isset($this->connections[$con])) {
|
||||
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
|
||||
@ -99,7 +99,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
// we add one call per event per service so we have the correct order
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $lazy ? $id : new Reference($id)));
|
||||
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', [[$tag['event']], $lazy ? $id : new Reference($id)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,12 +130,12 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
|
||||
*/
|
||||
private function findAndSortTags($tagName, ContainerBuilder $container)
|
||||
{
|
||||
$sortedTags = array();
|
||||
$sortedTags = [];
|
||||
|
||||
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $tags) {
|
||||
foreach ($tags as $attributes) {
|
||||
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
|
||||
$sortedTags[$priority][] = array($serviceId, $attributes);
|
||||
$sortedTags[$priority][] = [$serviceId, $attributes];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
||||
* register alias
|
||||
* @param string[] $aliasMap Map of alias to namespace
|
||||
*/
|
||||
public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = array())
|
||||
public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = [])
|
||||
{
|
||||
$this->driver = $driver;
|
||||
$this->namespaces = $namespaces;
|
||||
@ -146,7 +146,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
||||
// Definition for a Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
|
||||
$chainDriverDef = $container->getDefinition($chainDriverDefService);
|
||||
foreach ($this->namespaces as $namespace) {
|
||||
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
|
||||
$chainDriverDef->addMethodCall('addDriver', [$mappingDriverDef, $namespace]);
|
||||
}
|
||||
|
||||
if (!\count($this->aliasMap)) {
|
||||
@ -157,7 +157,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
|
||||
// Definition of the Doctrine\...\Configuration class specific to the Doctrine flavour.
|
||||
$configurationServiceDefinition = $container->getDefinition($configurationServiceName);
|
||||
foreach ($this->aliasMap as $alias => $namespace) {
|
||||
$configurationServiceDefinition->addMethodCall($this->registerAliasMethodName, array($alias, $namespace));
|
||||
$configurationServiceDefinition->addMethodCall($this->registerAliasMethodName, [$alias, $namespace]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
// Performance optimization
|
||||
if (empty($choices)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Optimize performance for single-field identifiers. We already
|
||||
@ -101,7 +101,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
||||
|
||||
// Attention: This optimization does not check choices for existence
|
||||
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
|
||||
$values = array();
|
||||
$values = [];
|
||||
|
||||
// Maintain order and indices of the given objects
|
||||
foreach ($choices as $i => $object) {
|
||||
@ -129,7 +129,7 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
||||
// statements, consequently no test fails when this code is removed.
|
||||
// https://github.com/symfony/symfony/pull/8981#issuecomment-24230557
|
||||
if (empty($values)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Optimize performance in case we have an object loader and
|
||||
@ -138,8 +138,8 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
|
||||
|
||||
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
|
||||
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
|
||||
$objectsById = array();
|
||||
$objects = array();
|
||||
$objectsById = [];
|
||||
$objects = [];
|
||||
|
||||
// Maintain order and indices from the given $values
|
||||
// An alternative approach to the following loop is to add the
|
||||
|
@ -43,7 +43,7 @@ class IdReader
|
||||
$this->om = $om;
|
||||
$this->classMetadata = $classMetadata;
|
||||
$this->singleId = 1 === \count($ids);
|
||||
$this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint'));
|
||||
$this->intId = $this->singleId && \in_array($idType, ['integer', 'smallint', 'bigint']);
|
||||
$this->idField = current($ids);
|
||||
|
||||
// single field association are resolved, since the schema column could be an int
|
||||
|
@ -64,7 +64,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
// Guess type
|
||||
$entity = current($qb->getRootEntities());
|
||||
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
|
||||
if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
|
||||
if (\in_array($metadata->getTypeOfField($identifier), ['integer', 'bigint', 'smallint'])) {
|
||||
$parameterType = Connection::PARAM_INT_ARRAY;
|
||||
|
||||
// Filter out non-integer values (e.g. ""). If we don't, some
|
||||
@ -72,7 +72,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
$values = array_values(array_filter($values, function ($v) {
|
||||
return (string) $v === (string) (int) $v || ctype_digit($v);
|
||||
}));
|
||||
} elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
|
||||
} elseif (\in_array($metadata->getTypeOfField($identifier), ['uuid', 'guid'])) {
|
||||
$parameterType = Connection::PARAM_STR_ARRAY;
|
||||
|
||||
// Like above, but we just filter out empty strings.
|
||||
@ -83,7 +83,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
$parameterType = Connection::PARAM_STR_ARRAY;
|
||||
}
|
||||
if (!$values) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return $qb->andWhere($where)
|
||||
|
@ -31,7 +31,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface
|
||||
public function transform($collection)
|
||||
{
|
||||
if (null === $collection) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// For cases when the collection getter returns $collection->toArray()
|
||||
@ -57,7 +57,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface
|
||||
public function reverseTransform($array)
|
||||
{
|
||||
if ('' === $array || null === $array) {
|
||||
$array = array();
|
||||
$array = [];
|
||||
} else {
|
||||
$array = (array) $array;
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ class DoctrineOrmExtension extends AbstractExtension
|
||||
|
||||
protected function loadTypes()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new EntityType($this->registry),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function loadTypeGuesser()
|
||||
|
@ -26,7 +26,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
{
|
||||
protected $registry;
|
||||
|
||||
private $cache = array();
|
||||
private $cache = [];
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
@ -39,7 +39,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
public function guessType($class, $property)
|
||||
{
|
||||
if (!$ret = $this->getMetadata($class)) {
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
|
||||
}
|
||||
|
||||
list($metadata, $name) = $ret;
|
||||
@ -48,37 +48,37 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
$multiple = $metadata->isCollectionValuedAssociation($property);
|
||||
$mapping = $metadata->getAssociationMapping($property);
|
||||
|
||||
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', array('em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', ['em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple], Guess::HIGH_CONFIDENCE);
|
||||
}
|
||||
|
||||
switch ($metadata->getTypeOfField($property)) {
|
||||
case Type::TARRAY:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::BOOLEAN:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DATETIME:
|
||||
case Type::DATETIMETZ:
|
||||
case 'vardatetime':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE);
|
||||
case 'dateinterval':
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DATE:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::TIME:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', array(), Guess::HIGH_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', [], Guess::HIGH_CONFIDENCE);
|
||||
case Type::DECIMAL:
|
||||
case Type::FLOAT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::INTEGER:
|
||||
case Type::BIGINT:
|
||||
case Type::SMALLINT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::STRING:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
case Type::TEXT:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', array(), Guess::MEDIUM_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', [], Guess::MEDIUM_CONFIDENCE);
|
||||
default:
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', array(), Guess::LOW_CONFIDENCE);
|
||||
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
|
||||
}
|
||||
|
||||
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
|
||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
{
|
||||
$ret = $this->getMetadata($class);
|
||||
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
|
||||
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
|
||||
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
|
||||
}
|
||||
}
|
||||
@ -164,7 +164,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
$this->cache[$class] = null;
|
||||
foreach ($this->registry->getManagers() as $name => $em) {
|
||||
try {
|
||||
return $this->cache[$class] = array($em->getClassMetadata($class), $name);
|
||||
return $this->cache[$class] = [$em->getClassMetadata($class), $name];
|
||||
} catch (MappingException $e) {
|
||||
// not an entity or mapped super class
|
||||
} catch (LegacyMappingException $e) {
|
||||
|
@ -35,12 +35,12 @@ class MergeDoctrineCollectionListener implements EventSubscriberInterface
|
||||
{
|
||||
// Higher priority than core MergeCollectionListener so that this one
|
||||
// is called before
|
||||
return array(
|
||||
FormEvents::SUBMIT => array(
|
||||
array('onBind', 10), // deprecated
|
||||
array('onSubmit', 5),
|
||||
),
|
||||
);
|
||||
return [
|
||||
FormEvents::SUBMIT => [
|
||||
['onBind', 10], // deprecated
|
||||
['onSubmit', 5],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function onSubmit(FormEvent $event)
|
||||
|
@ -35,12 +35,12 @@ abstract class DoctrineType extends AbstractType
|
||||
/**
|
||||
* @var IdReader[]
|
||||
*/
|
||||
private $idReaders = array();
|
||||
private $idReaders = [];
|
||||
|
||||
/**
|
||||
* @var DoctrineChoiceLoader[]
|
||||
*/
|
||||
private $choiceLoaders = array();
|
||||
private $choiceLoaders = [];
|
||||
|
||||
/**
|
||||
* Creates the label for a choice.
|
||||
@ -126,11 +126,11 @@ abstract class DoctrineType extends AbstractType
|
||||
// also if concrete Type can return important QueryBuilder parts to generate
|
||||
// hash key we go for it as well
|
||||
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
|
||||
$hash = CachingFactoryDecorator::generateHash(array(
|
||||
$hash = CachingFactoryDecorator::generateHash([
|
||||
$options['em'],
|
||||
$options['class'],
|
||||
$qbParts,
|
||||
));
|
||||
]);
|
||||
|
||||
if (isset($this->choiceLoaders[$hash])) {
|
||||
return $this->choiceLoaders[$hash];
|
||||
@ -167,7 +167,7 @@ abstract class DoctrineType extends AbstractType
|
||||
// field name. We can only use numeric IDs as names, as we cannot
|
||||
// guarantee that a non-numeric ID contains a valid form name
|
||||
if ($idReader->isIntId()) {
|
||||
return array(__CLASS__, 'createChoiceName');
|
||||
return [__CLASS__, 'createChoiceName'];
|
||||
}
|
||||
|
||||
// Otherwise, an incrementing integer is used as name automatically
|
||||
@ -183,7 +183,7 @@ abstract class DoctrineType extends AbstractType
|
||||
|
||||
// If the entity has a single-column ID, use that ID as value
|
||||
if ($idReader->isSingleId()) {
|
||||
return array($idReader, 'getIdValue');
|
||||
return [$idReader, 'getIdValue'];
|
||||
}
|
||||
|
||||
// Otherwise, an incrementing integer is used as value automatically
|
||||
@ -221,10 +221,10 @@ abstract class DoctrineType extends AbstractType
|
||||
// Set the "id_reader" option via the normalizer. This option is not
|
||||
// supposed to be set by the user.
|
||||
$idReaderNormalizer = function (Options $options) {
|
||||
$hash = CachingFactoryDecorator::generateHash(array(
|
||||
$hash = CachingFactoryDecorator::generateHash([
|
||||
$options['em'],
|
||||
$options['class'],
|
||||
));
|
||||
]);
|
||||
|
||||
// The ID reader is a utility that is needed to read the object IDs
|
||||
// when generating the field values. The callback generating the
|
||||
@ -240,25 +240,25 @@ abstract class DoctrineType extends AbstractType
|
||||
return $this->idReaders[$hash];
|
||||
};
|
||||
|
||||
$resolver->setDefaults(array(
|
||||
$resolver->setDefaults([
|
||||
'em' => null,
|
||||
'query_builder' => null,
|
||||
'choices' => null,
|
||||
'choice_loader' => $choiceLoader,
|
||||
'choice_label' => array(__CLASS__, 'createChoiceLabel'),
|
||||
'choice_label' => [__CLASS__, 'createChoiceLabel'],
|
||||
'choice_name' => $choiceName,
|
||||
'choice_value' => $choiceValue,
|
||||
'id_reader' => null, // internal
|
||||
'choice_translation_domain' => false,
|
||||
));
|
||||
]);
|
||||
|
||||
$resolver->setRequired(array('class'));
|
||||
$resolver->setRequired(['class']);
|
||||
|
||||
$resolver->setNormalizer('em', $emNormalizer);
|
||||
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
|
||||
$resolver->setNormalizer('id_reader', $idReaderNormalizer);
|
||||
|
||||
$resolver->setAllowedTypes('em', array('null', 'string', 'Doctrine\Common\Persistence\ObjectManager'));
|
||||
$resolver->setAllowedTypes('em', ['null', 'string', 'Doctrine\Common\Persistence\ObjectManager']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,6 +279,6 @@ abstract class DoctrineType extends AbstractType
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->choiceLoaders = array();
|
||||
$this->choiceLoaders = [];
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class EntityType extends DoctrineType
|
||||
};
|
||||
|
||||
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
|
||||
$resolver->setAllowedTypes('query_builder', array('null', 'callable', 'Doctrine\ORM\QueryBuilder'));
|
||||
$resolver->setAllowedTypes('query_builder', ['null', 'callable', 'Doctrine\ORM\QueryBuilder']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,10 +78,10 @@ class EntityType extends DoctrineType
|
||||
*/
|
||||
public function getQueryBuilderPartsForCachingHash($queryBuilder)
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
$queryBuilder->getQuery()->getSQL(),
|
||||
array_map(array($this, 'parameterToArray'), $queryBuilder->getParameters()->toArray()),
|
||||
);
|
||||
array_map([$this, 'parameterToArray'], $queryBuilder->getParameters()->toArray()),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,6 +91,6 @@ class EntityType extends DoctrineType
|
||||
*/
|
||||
private function parameterToArray(Parameter $parameter)
|
||||
{
|
||||
return array($parameter->getName(), $parameter->getType(), $parameter->getValue());
|
||||
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,6 @@ final class DbalSessionHandlerSchema extends Schema
|
||||
$table->addColumn('sess_id', 'string');
|
||||
$table->addColumn('sess_data', 'text')->setNotNull(true);
|
||||
$table->addColumn('sess_time', 'integer')->setNotNull(true)->setUnsigned(true);
|
||||
$table->setPrimaryKey(array('sess_id'));
|
||||
$table->setPrimaryKey(['sess_id']);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class DbalLogger implements SQLLogger
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->log($sql, null === $params ? array() : $this->normalizeParams($params));
|
||||
$this->log($sql, null === $params ? [] : $this->normalizeParams($params));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProperties($class, array $context = array())
|
||||
public function getProperties($class, array $context = [])
|
||||
{
|
||||
try {
|
||||
$metadata = $this->classMetadataFactory->getMetadataFor($class);
|
||||
@ -63,7 +63,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTypes($class, $property, array $context = array())
|
||||
public function getTypes($class, $property, array $context = [])
|
||||
{
|
||||
try {
|
||||
$metadata = $this->classMetadataFactory->getMetadataFor($class);
|
||||
@ -85,7 +85,7 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
$nullable = false;
|
||||
}
|
||||
|
||||
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class));
|
||||
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)];
|
||||
}
|
||||
|
||||
$collectionKeyType = Type::BUILTIN_TYPE_INT;
|
||||
@ -112,18 +112,18 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
}
|
||||
}
|
||||
|
||||
return array(new Type(
|
||||
return [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type($collectionKeyType),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, $class)
|
||||
));
|
||||
)];
|
||||
}
|
||||
|
||||
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && isset($metadata->embeddedClasses[$property])) {
|
||||
return array(new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class']));
|
||||
return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])];
|
||||
}
|
||||
|
||||
if ($metadata->hasField($property)) {
|
||||
@ -136,30 +136,30 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
case DBALType::DATETIMETZ:
|
||||
case 'vardatetime':
|
||||
case DBALType::TIME:
|
||||
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
|
||||
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime')];
|
||||
|
||||
case 'date_immutable':
|
||||
case 'datetime_immutable':
|
||||
case 'datetimetz_immutable':
|
||||
case 'time_immutable':
|
||||
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable'));
|
||||
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable')];
|
||||
|
||||
case 'dateinterval':
|
||||
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval'));
|
||||
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval')];
|
||||
|
||||
case DBALType::TARRAY:
|
||||
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
|
||||
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
|
||||
|
||||
case DBALType::SIMPLE_ARRAY:
|
||||
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)));
|
||||
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))];
|
||||
|
||||
case DBALType::JSON_ARRAY:
|
||||
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
|
||||
return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)];
|
||||
|
||||
default:
|
||||
$builtinType = $this->getPhpType($typeOfField);
|
||||
|
||||
return $builtinType ? array(new Type($builtinType, $nullable)) : null;
|
||||
return $builtinType ? [new Type($builtinType, $nullable)] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
||||
// the alias for lastUsed works around case insensitivity in PostgreSQL
|
||||
$sql = 'SELECT class, username, value, lastUsed AS last_used'
|
||||
.' FROM rememberme_token WHERE series=:series';
|
||||
$paramValues = array('series' => $series);
|
||||
$paramTypes = array('series' => \PDO::PARAM_STR);
|
||||
$paramValues = ['series' => $series];
|
||||
$paramTypes = ['series' => \PDO::PARAM_STR];
|
||||
$stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes);
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
@ -71,8 +71,8 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
||||
public function deleteTokenBySeries($series)
|
||||
{
|
||||
$sql = 'DELETE FROM rememberme_token WHERE series=:series';
|
||||
$paramValues = array('series' => $series);
|
||||
$paramTypes = array('series' => \PDO::PARAM_STR);
|
||||
$paramValues = ['series' => $series];
|
||||
$paramTypes = ['series' => \PDO::PARAM_STR];
|
||||
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||
}
|
||||
|
||||
@ -83,16 +83,16 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
||||
{
|
||||
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed'
|
||||
.' WHERE series=:series';
|
||||
$paramValues = array(
|
||||
$paramValues = [
|
||||
'value' => $tokenValue,
|
||||
'lastUsed' => $lastUsed,
|
||||
'series' => $series,
|
||||
);
|
||||
$paramTypes = array(
|
||||
];
|
||||
$paramTypes = [
|
||||
'value' => \PDO::PARAM_STR,
|
||||
'lastUsed' => DoctrineType::DATETIME,
|
||||
'series' => \PDO::PARAM_STR,
|
||||
);
|
||||
];
|
||||
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||
if ($updated < 1) {
|
||||
throw new TokenNotFoundException('No token found.');
|
||||
@ -107,20 +107,20 @@ class DoctrineTokenProvider implements TokenProviderInterface
|
||||
$sql = 'INSERT INTO rememberme_token'
|
||||
.' (class, username, series, value, lastUsed)'
|
||||
.' VALUES (:class, :username, :series, :value, :lastUsed)';
|
||||
$paramValues = array(
|
||||
$paramValues = [
|
||||
'class' => $token->getClass(),
|
||||
'username' => $token->getUsername(),
|
||||
'series' => $token->getSeries(),
|
||||
'value' => $token->getTokenValue(),
|
||||
'lastUsed' => $token->getLastUsed(),
|
||||
);
|
||||
$paramTypes = array(
|
||||
];
|
||||
$paramTypes = [
|
||||
'class' => \PDO::PARAM_STR,
|
||||
'username' => \PDO::PARAM_STR,
|
||||
'series' => \PDO::PARAM_STR,
|
||||
'value' => \PDO::PARAM_STR,
|
||||
'lastUsed' => DoctrineType::DATETIME,
|
||||
);
|
||||
];
|
||||
$this->conn->executeUpdate($sql, $paramValues, $paramTypes);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class EntityUserProvider implements UserProviderInterface
|
||||
{
|
||||
$repository = $this->getRepository();
|
||||
if (null !== $this->property) {
|
||||
$user = $repository->findOneBy(array($this->property => $username));
|
||||
$user = $repository->findOneBy([$this->property => $username]);
|
||||
} else {
|
||||
if (!$repository instanceof UserLoaderInterface) {
|
||||
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
|
||||
|
@ -42,10 +42,10 @@ class DoctrineTestHelper
|
||||
$config = self::createTestConfiguration();
|
||||
}
|
||||
|
||||
$params = array(
|
||||
$params = [
|
||||
'driver' => 'pdo_sqlite',
|
||||
'memory' => true,
|
||||
);
|
||||
];
|
||||
|
||||
return EntityManager::create($params, $config);
|
||||
}
|
||||
@ -56,7 +56,7 @@ class DoctrineTestHelper
|
||||
public static function createTestConfiguration()
|
||||
{
|
||||
$config = new Configuration();
|
||||
$config->setEntityNamespaces(array('SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'));
|
||||
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
|
||||
$config->setAutoGenerateProxyClasses(true);
|
||||
$config->setProxyDir(\sys_get_temp_dir());
|
||||
$config->setProxyNamespace('SymfonyTests\Doctrine');
|
||||
|
@ -24,7 +24,7 @@ final class TestRepositoryFactory implements RepositoryFactory
|
||||
/**
|
||||
* @var ObjectRepository[]
|
||||
*/
|
||||
private $repositoryList = array();
|
||||
private $repositoryList = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -43,15 +43,15 @@ class ContainerAwareEventManagerTest extends TestCase
|
||||
$this->evm->addEventListener('foo', 'bar');
|
||||
$this->evm->addEventListener('foo', $listener = new MyListener());
|
||||
|
||||
$listeners = array('foo' => array('_service_bar' => 'bar', spl_object_hash($listener) => $listener));
|
||||
$listeners = ['foo' => ['_service_bar' => 'bar', spl_object_hash($listener) => $listener]];
|
||||
$this->assertSame($listeners, $this->evm->getListeners());
|
||||
$this->assertSame($listeners['foo'], $this->evm->getListeners('foo'));
|
||||
|
||||
$this->evm->removeEventListener('foo', $listener);
|
||||
$this->assertSame(array('_service_bar' => 'bar'), $this->evm->getListeners('foo'));
|
||||
$this->assertSame(['_service_bar' => 'bar'], $this->evm->getListeners('foo'));
|
||||
|
||||
$this->evm->removeEventListener('foo', 'bar');
|
||||
$this->assertSame(array(), $this->evm->getListeners('foo'));
|
||||
$this->assertSame([], $this->evm->getListeners('foo'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,27 +22,27 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
{
|
||||
public function testCollectConnections()
|
||||
{
|
||||
$c = $this->createCollector(array());
|
||||
$c = $this->createCollector([]);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(array('default' => 'doctrine.dbal.default_connection'), $c->getConnections());
|
||||
$this->assertEquals(['default' => 'doctrine.dbal.default_connection'], $c->getConnections());
|
||||
}
|
||||
|
||||
public function testCollectManagers()
|
||||
{
|
||||
$c = $this->createCollector(array());
|
||||
$c = $this->createCollector([]);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(array('default' => 'doctrine.orm.default_entity_manager'), $c->getManagers());
|
||||
$this->assertEquals(['default' => 'doctrine.orm.default_entity_manager'], $c->getManagers());
|
||||
}
|
||||
|
||||
public function testCollectQueryCount()
|
||||
{
|
||||
$c = $this->createCollector(array());
|
||||
$c = $this->createCollector([]);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(0, $c->getQueryCount());
|
||||
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 0),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 0],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(1, $c->getQueryCount());
|
||||
@ -50,21 +50,21 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
|
||||
public function testCollectTime()
|
||||
{
|
||||
$c = $this->createCollector(array());
|
||||
$c = $this->createCollector([]);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(0, $c->getTime());
|
||||
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(1, $c->getTime());
|
||||
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
|
||||
array('sql' => 'SELECT * FROM table2', 'params' => array(), 'types' => array(), 'executionMS' => 2),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
|
||||
['sql' => 'SELECT * FROM table2', 'params' => [], 'types' => [], 'executionMS' => 2],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
$this->assertEquals(3, $c->getTime());
|
||||
@ -75,9 +75,9 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
*/
|
||||
public function testCollectQueries($param, $types, $expected, $explainable)
|
||||
{
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => [$param], 'types' => $types, 'executionMS' => 1],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
@ -88,32 +88,32 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
|
||||
public function testCollectQueryWithNoParams()
|
||||
{
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => null, 'types' => null, 'executionMS' => 1),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
|
||||
['sql' => 'SELECT * FROM table1', 'params' => null, 'types' => null, 'executionMS' => 1],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$collectedQueries = $c->getQueries();
|
||||
$this->assertEquals(array(), $collectedQueries['default'][0]['params']);
|
||||
$this->assertEquals([], $collectedQueries['default'][0]['params']);
|
||||
$this->assertTrue($collectedQueries['default'][0]['explainable']);
|
||||
$this->assertEquals(array(), $collectedQueries['default'][1]['params']);
|
||||
$this->assertEquals([], $collectedQueries['default'][1]['params']);
|
||||
$this->assertTrue($collectedQueries['default'][1]['explainable']);
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1', 'params' => array(), 'types' => array(), 'executionMS' => 1),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$c->reset();
|
||||
$c->collect(new Request(), new Response());
|
||||
|
||||
$this->assertEquals(array('default' => array()), $c->getQueries());
|
||||
$this->assertEquals(['default' => []], $c->getQueries());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,9 +121,9 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
*/
|
||||
public function testSerialization($param, $types, $expected, $explainable)
|
||||
{
|
||||
$queries = array(
|
||||
array('sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => array($param), 'types' => $types, 'executionMS' => 1),
|
||||
);
|
||||
$queries = [
|
||||
['sql' => 'SELECT * FROM table1 WHERE field1 = ?1', 'params' => [$param], 'types' => $types, 'executionMS' => 1],
|
||||
];
|
||||
$c = $this->createCollector($queries);
|
||||
$c->collect(new Request(), new Response());
|
||||
$c = unserialize(serialize($c));
|
||||
@ -135,25 +135,25 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
|
||||
public function paramProvider()
|
||||
{
|
||||
$tests = array(
|
||||
array('some value', array(), 'some value', true),
|
||||
array(1, array(), 1, true),
|
||||
array(true, array(), true, true),
|
||||
array(null, array(), null, true),
|
||||
array(new \DateTime('2011-09-11'), array('date'), '2011-09-11', true),
|
||||
array(fopen(__FILE__, 'r'), array(), 'Resource(stream)', false),
|
||||
array(new \stdClass(), array(), 'Object(stdClass)', false),
|
||||
array(
|
||||
$tests = [
|
||||
['some value', [], 'some value', true],
|
||||
[1, [], 1, true],
|
||||
[true, [], true, true],
|
||||
[null, [], null, true],
|
||||
[new \DateTime('2011-09-11'), ['date'], '2011-09-11', true],
|
||||
[fopen(__FILE__, 'r'), [], 'Resource(stream)', false],
|
||||
[new \stdClass(), [], 'Object(stdClass)', false],
|
||||
[
|
||||
new StringRepresentableClass(),
|
||||
array(),
|
||||
[],
|
||||
'Object(Symfony\Bridge\Doctrine\Tests\DataCollector\StringRepresentableClass): "string representation"',
|
||||
false,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
if (version_compare(Version::VERSION, '2.6', '>=')) {
|
||||
$tests[] = array('this is not a date', array('date'), 'this is not a date', false);
|
||||
$tests[] = array(new \stdClass(), array('date'), 'Object(stdClass)', false);
|
||||
$tests[] = ['this is not a date', ['date'], 'this is not a date', false];
|
||||
$tests[] = [new \stdClass(), ['date'], 'Object(stdClass)', false];
|
||||
}
|
||||
|
||||
return $tests;
|
||||
@ -172,11 +172,11 @@ class DoctrineDataCollectorTest extends TestCase
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getConnectionNames')
|
||||
->will($this->returnValue(array('default' => 'doctrine.dbal.default_connection')));
|
||||
->will($this->returnValue(['default' => 'doctrine.dbal.default_connection']));
|
||||
$registry
|
||||
->expects($this->any())
|
||||
->method('getManagerNames')
|
||||
->will($this->returnValue(array('default' => 'doctrine.orm.default_entity_manager')));
|
||||
->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager']));
|
||||
$registry->expects($this->any())
|
||||
->method('getConnection')
|
||||
->will($this->returnValue($connection));
|
||||
|
@ -44,7 +44,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
|
||||
$abstractDefinition = new Definition('stdClass');
|
||||
$abstractDefinition->setAbstract(true);
|
||||
$abstractDefinition->addTag('doctrine.event_listener', array('event' => 'test'));
|
||||
$abstractDefinition->addTag('doctrine.event_listener', ['event' => 'test']);
|
||||
|
||||
$container->setDefinition('a', $abstractDefinition);
|
||||
|
||||
@ -58,44 +58,44 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
$container
|
||||
->register('a', 'stdClass')
|
||||
->setPublic(false)
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'bar',
|
||||
))
|
||||
->addTag('doctrine.event_listener', array(
|
||||
])
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo',
|
||||
'priority' => -5,
|
||||
))
|
||||
->addTag('doctrine.event_listener', array(
|
||||
])
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo_bar',
|
||||
'priority' => 3,
|
||||
'lazy' => true,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo',
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'foo_bar',
|
||||
'priority' => 4,
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
$methodCalls = $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls();
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('foo_bar'), new Reference('c'))),
|
||||
array('addEventListener', array(array('foo_bar'), new Reference('a'))),
|
||||
array('addEventListener', array(array('bar'), new Reference('a'))),
|
||||
array('addEventListener', array(array('foo'), new Reference('b'))),
|
||||
array('addEventListener', array(array('foo'), new Reference('a'))),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['foo_bar'], new Reference('c')]],
|
||||
['addEventListener', [['foo_bar'], new Reference('a')]],
|
||||
['addEventListener', [['bar'], new Reference('a')]],
|
||||
['addEventListener', [['foo'], new Reference('b')]],
|
||||
['addEventListener', [['foo'], new Reference('a')]],
|
||||
],
|
||||
$methodCalls
|
||||
);
|
||||
|
||||
@ -113,42 +113,42 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
|
||||
$container
|
||||
->register('a', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'default',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_listener', array(
|
||||
->addTag('doctrine.event_listener', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'second',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('onFlush'), new Reference('a'))),
|
||||
array('addEventListener', array(array('onFlush'), new Reference('b'))),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['onFlush'], new Reference('a')]],
|
||||
['addEventListener', [['onFlush'], new Reference('b')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventListener', array(array('onFlush'), new Reference('a'))),
|
||||
array('addEventListener', array(array('onFlush'), new Reference('c'))),
|
||||
),
|
||||
[
|
||||
['addEventListener', [['onFlush'], new Reference('a')]],
|
||||
['addEventListener', [['onFlush'], new Reference('c')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
@ -159,42 +159,42 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
|
||||
$container
|
||||
->register('a', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'default',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'event' => 'onFlush',
|
||||
'connection' => 'second',
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
array('addEventSubscriber', array(new Reference('b'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
['addEventSubscriber', [new Reference('b')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
array('addEventSubscriber', array(new Reference('c'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
['addEventSubscriber', [new Reference('c')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
@ -209,39 +209,39 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
;
|
||||
$container
|
||||
->register('b', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 5,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('c', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('d', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
$container
|
||||
->register('e', 'stdClass')
|
||||
->addTag('doctrine.event_subscriber', array(
|
||||
->addTag('doctrine.event_subscriber', [
|
||||
'priority' => 10,
|
||||
))
|
||||
])
|
||||
;
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
array('addEventSubscriber', array(new Reference('c'))),
|
||||
array('addEventSubscriber', array(new Reference('d'))),
|
||||
array('addEventSubscriber', array(new Reference('e'))),
|
||||
array('addEventSubscriber', array(new Reference('b'))),
|
||||
array('addEventSubscriber', array(new Reference('a'))),
|
||||
),
|
||||
[
|
||||
['addEventSubscriber', [new Reference('c')]],
|
||||
['addEventSubscriber', [new Reference('d')]],
|
||||
['addEventSubscriber', [new Reference('e')]],
|
||||
['addEventSubscriber', [new Reference('b')]],
|
||||
['addEventSubscriber', [new Reference('a')]],
|
||||
],
|
||||
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
@ -252,9 +252,9 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
|
||||
$this->process($container);
|
||||
|
||||
$this->assertEquals(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
|
||||
$this->assertEquals([], $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
|
||||
|
||||
$this->assertEquals(array(), $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls());
|
||||
$this->assertEquals([], $container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls());
|
||||
}
|
||||
|
||||
private function process(ContainerBuilder $container)
|
||||
@ -267,7 +267,7 @@ class RegisterEventListenersAndSubscribersPassTest extends TestCase
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
$connections = array('default' => 'doctrine.dbal.default_connection');
|
||||
$connections = ['default' => 'doctrine.dbal.default_connection'];
|
||||
|
||||
$container->register('doctrine.dbal.default_connection.event_manager', 'stdClass');
|
||||
$container->register('doctrine.dbal.default_connection', 'stdClass');
|
||||
|
@ -16,17 +16,17 @@ class RegisterMappingsPassTest extends TestCase
|
||||
public function testNoDriverParmeterException()
|
||||
{
|
||||
$container = $this->createBuilder();
|
||||
$this->process($container, array(
|
||||
$this->process($container, [
|
||||
'manager.param.one',
|
||||
'manager.param.two',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
private function process(ContainerBuilder $container, array $managerParamNames)
|
||||
{
|
||||
$pass = new ConcreteMappingsPass(
|
||||
new Definition('\stdClass'),
|
||||
array(),
|
||||
[],
|
||||
$managerParamNames,
|
||||
'some.%s.metadata_driver'
|
||||
);
|
||||
|
@ -32,13 +32,13 @@ class DoctrineExtensionTest extends TestCase
|
||||
|
||||
$this->extension = $this
|
||||
->getMockBuilder('Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension')
|
||||
->setMethods(array(
|
||||
->setMethods([
|
||||
'getMappingResourceConfigDirectory',
|
||||
'getObjectManagerElementName',
|
||||
'getMappingObjectDefaultName',
|
||||
'getMappingResourceExtension',
|
||||
'load',
|
||||
))
|
||||
])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
@ -54,19 +54,19 @@ class DoctrineExtensionTest extends TestCase
|
||||
*/
|
||||
public function testFixManagersAutoMappingsWithTwoAutomappings()
|
||||
{
|
||||
$emConfigs = array(
|
||||
'em1' => array(
|
||||
$emConfigs = [
|
||||
'em1' => [
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
'em2' => array(
|
||||
],
|
||||
'em2' => [
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$bundles = array(
|
||||
$bundles = [
|
||||
'FirstBundle' => 'My\FirstBundle',
|
||||
'SecondBundle' => 'My\SecondBundle',
|
||||
);
|
||||
];
|
||||
|
||||
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||
@ -77,69 +77,69 @@ class DoctrineExtensionTest extends TestCase
|
||||
|
||||
public function getAutomappingData()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array( // no auto mapping on em1
|
||||
return [
|
||||
[
|
||||
[ // no auto mapping on em1
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array( // no auto mapping on em2
|
||||
],
|
||||
[ // no auto mapping on em2
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
array( // no auto mapping on em1
|
||||
],
|
||||
[],
|
||||
[],
|
||||
],
|
||||
[
|
||||
[ // no auto mapping on em1
|
||||
'auto_mapping' => false,
|
||||
),
|
||||
array( // auto mapping enabled on em2
|
||||
],
|
||||
[ // auto mapping enabled on em2
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
array(),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'FirstBundle' => array(
|
||||
],
|
||||
[],
|
||||
[
|
||||
'mappings' => [
|
||||
'FirstBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
'SecondBundle' => array(
|
||||
],
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
array( // no auto mapping on em1, but it defines SecondBundle as own
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
[ // no auto mapping on em1, but it defines SecondBundle as own
|
||||
'auto_mapping' => false,
|
||||
'mappings' => array(
|
||||
'SecondBundle' => array(
|
||||
'mappings' => [
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
array( // auto mapping enabled on em2
|
||||
],
|
||||
],
|
||||
],
|
||||
[ // auto mapping enabled on em2
|
||||
'auto_mapping' => true,
|
||||
),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'SecondBundle' => array(
|
||||
],
|
||||
[
|
||||
'mappings' => [
|
||||
'SecondBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'mappings' => array(
|
||||
'FirstBundle' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'mappings' => [
|
||||
'FirstBundle' => [
|
||||
'mapping' => true,
|
||||
'is_bundle' => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,15 +147,15 @@ class DoctrineExtensionTest extends TestCase
|
||||
*/
|
||||
public function testFixManagersAutoMappings(array $originalEm1, array $originalEm2, array $expectedEm1, array $expectedEm2)
|
||||
{
|
||||
$emConfigs = array(
|
||||
$emConfigs = [
|
||||
'em1' => $originalEm1,
|
||||
'em2' => $originalEm2,
|
||||
);
|
||||
];
|
||||
|
||||
$bundles = array(
|
||||
$bundles = [
|
||||
'FirstBundle' => 'My\FirstBundle',
|
||||
'SecondBundle' => 'My\SecondBundle',
|
||||
);
|
||||
];
|
||||
|
||||
$reflection = new \ReflectionClass(\get_class($this->extension));
|
||||
$method = $reflection->getMethod('fixManagersAutoMappings');
|
||||
@ -163,27 +163,27 @@ class DoctrineExtensionTest extends TestCase
|
||||
|
||||
$newEmConfigs = $method->invoke($this->extension, $emConfigs, $bundles);
|
||||
|
||||
$this->assertEquals($newEmConfigs['em1'], array_merge(array(
|
||||
$this->assertEquals($newEmConfigs['em1'], array_merge([
|
||||
'auto_mapping' => false,
|
||||
), $expectedEm1));
|
||||
$this->assertEquals($newEmConfigs['em2'], array_merge(array(
|
||||
], $expectedEm1));
|
||||
$this->assertEquals($newEmConfigs['em2'], array_merge([
|
||||
'auto_mapping' => false,
|
||||
), $expectedEm2));
|
||||
], $expectedEm2));
|
||||
}
|
||||
|
||||
public function providerBasicDrivers()
|
||||
{
|
||||
return array(
|
||||
array('doctrine.orm.cache.apc.class', array('type' => 'apc')),
|
||||
array('doctrine.orm.cache.apcu.class', array('type' => 'apcu')),
|
||||
array('doctrine.orm.cache.array.class', array('type' => 'array')),
|
||||
array('doctrine.orm.cache.xcache.class', array('type' => 'xcache')),
|
||||
array('doctrine.orm.cache.wincache.class', array('type' => 'wincache')),
|
||||
array('doctrine.orm.cache.zenddata.class', array('type' => 'zenddata')),
|
||||
array('doctrine.orm.cache.redis.class', array('type' => 'redis'), array('setRedis')),
|
||||
array('doctrine.orm.cache.memcache.class', array('type' => 'memcache'), array('setMemcache')),
|
||||
array('doctrine.orm.cache.memcached.class', array('type' => 'memcached'), array('setMemcached')),
|
||||
);
|
||||
return [
|
||||
['doctrine.orm.cache.apc.class', ['type' => 'apc']],
|
||||
['doctrine.orm.cache.apcu.class', ['type' => 'apcu']],
|
||||
['doctrine.orm.cache.array.class', ['type' => 'array']],
|
||||
['doctrine.orm.cache.xcache.class', ['type' => 'xcache']],
|
||||
['doctrine.orm.cache.wincache.class', ['type' => 'wincache']],
|
||||
['doctrine.orm.cache.zenddata.class', ['type' => 'zenddata']],
|
||||
['doctrine.orm.cache.redis.class', ['type' => 'redis'], ['setRedis']],
|
||||
['doctrine.orm.cache.memcache.class', ['type' => 'memcache'], ['setMemcache']],
|
||||
['doctrine.orm.cache.memcached.class', ['type' => 'memcached'], ['setMemcached']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,14 +192,14 @@ class DoctrineExtensionTest extends TestCase
|
||||
*
|
||||
* @dataProvider providerBasicDrivers
|
||||
*/
|
||||
public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array())
|
||||
public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = [])
|
||||
{
|
||||
$container = $this->createContainer();
|
||||
$cacheName = 'metadata_cache';
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => $config,
|
||||
);
|
||||
];
|
||||
|
||||
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
|
||||
|
||||
@ -223,13 +223,13 @@ class DoctrineExtensionTest extends TestCase
|
||||
$cacheName = 'metadata_cache';
|
||||
$container = $this->createContainer();
|
||||
$definition = new Definition('%doctrine.orm.cache.apc.class%');
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => array(
|
||||
'metadata_cache_driver' => [
|
||||
'type' => 'service',
|
||||
'id' => 'service_driver',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$container->setDefinition('service_driver', $definition);
|
||||
|
||||
@ -246,12 +246,12 @@ class DoctrineExtensionTest extends TestCase
|
||||
{
|
||||
$cacheName = 'metadata_cache';
|
||||
$container = $this->createContainer();
|
||||
$objectManager = array(
|
||||
$objectManager = [
|
||||
'name' => 'default',
|
||||
'metadata_cache_driver' => array(
|
||||
'metadata_cache_driver' => [
|
||||
'type' => 'unrecognized_type',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->invokeLoadCacheDriver($objectManager, $container, $cacheName);
|
||||
}
|
||||
@ -262,21 +262,21 @@ class DoctrineExtensionTest extends TestCase
|
||||
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invokeArgs($this->extension, array($objectManager, $container, $cacheName));
|
||||
$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
|
||||
*/
|
||||
protected function createContainer(array $data = array())
|
||||
protected function createContainer(array $data = [])
|
||||
{
|
||||
return new ContainerBuilder(new ParameterBag(array_merge(array(
|
||||
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
|
||||
return new ContainerBuilder(new ParameterBag(array_merge([
|
||||
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
|
||||
'kernel.cache_dir' => __DIR__,
|
||||
'kernel.debug' => false,
|
||||
'kernel.environment' => 'test',
|
||||
'kernel.name' => 'kernel',
|
||||
'kernel.root_dir' => __DIR__,
|
||||
), $data)));
|
||||
], $data)));
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class SingleIntIdEntity
|
||||
public $name;
|
||||
|
||||
/** @Column(type="array", nullable=true) */
|
||||
public $phoneNumbers = array();
|
||||
public $phoneNumbers = [];
|
||||
|
||||
public function __construct($id, $name)
|
||||
{
|
||||
|
@ -81,9 +81,9 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->objectLoader = $this->getMockBuilder('Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface')->getMock();
|
||||
$this->obj1 = (object) array('name' => 'A');
|
||||
$this->obj2 = (object) array('name' => 'B');
|
||||
$this->obj3 = (object) array('name' => 'C');
|
||||
$this->obj1 = (object) ['name' => 'A'];
|
||||
$this->obj2 = (object) ['name' => 'B'];
|
||||
$this->obj3 = (object) ['name' => 'C'];
|
||||
|
||||
$this->om->expects($this->any())
|
||||
->method('getRepository')
|
||||
@ -104,7 +104,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
$value = function () {};
|
||||
$choiceList = new ArrayChoiceList($choices, $value);
|
||||
|
||||
@ -132,7 +132,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
$value = function () {};
|
||||
$choiceList = new ArrayChoiceList($choices, $value);
|
||||
|
||||
@ -159,7 +159,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->objectLoader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
$choiceList = new ArrayChoiceList($choices);
|
||||
|
||||
$this->repository->expects($this->never())
|
||||
@ -184,17 +184,17 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('findAll')
|
||||
->willReturn($choices);
|
||||
|
||||
$this->assertSame(array('1', '2'), $loader->loadValuesForChoices(array($this->obj2, $this->obj3)));
|
||||
$this->assertSame(['1', '2'], $loader->loadValuesForChoices([$this->obj2, $this->obj3]));
|
||||
|
||||
// no further loads on subsequent calls
|
||||
|
||||
$this->assertSame(array('1', '2'), $loader->loadValuesForChoices(array($this->obj2, $this->obj3)));
|
||||
$this->assertSame(['1', '2'], $loader->loadValuesForChoices([$this->obj2, $this->obj3]));
|
||||
}
|
||||
|
||||
public function testLoadValuesForChoicesDoesNotLoadIfEmptyChoices()
|
||||
@ -208,7 +208,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->repository->expects($this->never())
|
||||
->method('findAll');
|
||||
|
||||
$this->assertSame(array(), $loader->loadValuesForChoices(array()));
|
||||
$this->assertSame([], $loader->loadValuesForChoices([]));
|
||||
}
|
||||
|
||||
public function testLoadValuesForChoicesDoesNotLoadIfSingleIntId()
|
||||
@ -231,7 +231,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
->with($this->obj2)
|
||||
->willReturn('2');
|
||||
|
||||
$this->assertSame(array('2'), $loader->loadValuesForChoices(array($this->obj2)));
|
||||
$this->assertSame(['2'], $loader->loadValuesForChoices([$this->obj2]));
|
||||
}
|
||||
|
||||
public function testLoadValuesForChoicesLoadsIfSingleIntIdAndValueGiven()
|
||||
@ -242,7 +242,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
$value = function (\stdClass $object) { return $object->name; };
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
@ -253,8 +253,8 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
->method('findAll')
|
||||
->willReturn($choices);
|
||||
|
||||
$this->assertSame(array('B'), $loader->loadValuesForChoices(
|
||||
array($this->obj2),
|
||||
$this->assertSame(['B'], $loader->loadValuesForChoices(
|
||||
[$this->obj2],
|
||||
$value
|
||||
));
|
||||
}
|
||||
@ -267,7 +267,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$value = array($this->idReader, 'getIdValue');
|
||||
$value = [$this->idReader, 'getIdValue'];
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
->method('isSingleId')
|
||||
@ -281,8 +281,8 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
->with($this->obj2)
|
||||
->willReturn('2');
|
||||
|
||||
$this->assertSame(array('2'), $loader->loadValuesForChoices(
|
||||
array($this->obj2),
|
||||
$this->assertSame(['2'], $loader->loadValuesForChoices(
|
||||
[$this->obj2],
|
||||
$value
|
||||
));
|
||||
}
|
||||
@ -295,17 +295,17 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
|
||||
$this->repository->expects($this->once())
|
||||
->method('findAll')
|
||||
->willReturn($choices);
|
||||
|
||||
$this->assertSame(array($this->obj2, $this->obj3), $loader->loadChoicesForValues(array('1', '2')));
|
||||
$this->assertSame([$this->obj2, $this->obj3], $loader->loadChoicesForValues(['1', '2']));
|
||||
|
||||
// no further loads on subsequent calls
|
||||
|
||||
$this->assertSame(array($this->obj2, $this->obj3), $loader->loadChoicesForValues(array('1', '2')));
|
||||
$this->assertSame([$this->obj2, $this->obj3], $loader->loadChoicesForValues(['1', '2']));
|
||||
}
|
||||
|
||||
public function testLoadChoicesForValuesDoesNotLoadIfEmptyValues()
|
||||
@ -319,7 +319,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->repository->expects($this->never())
|
||||
->method('findAll');
|
||||
|
||||
$this->assertSame(array(), $loader->loadChoicesForValues(array()));
|
||||
$this->assertSame([], $loader->loadChoicesForValues([]));
|
||||
}
|
||||
|
||||
public function testLoadChoicesForValuesLoadsOnlyChoicesIfSingleIntId()
|
||||
@ -331,7 +331,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->objectLoader
|
||||
);
|
||||
|
||||
$choices = array($this->obj2, $this->obj3);
|
||||
$choices = [$this->obj2, $this->obj3];
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
->method('isSingleId')
|
||||
@ -346,19 +346,19 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
|
||||
$this->objectLoader->expects($this->once())
|
||||
->method('getEntitiesByIds')
|
||||
->with('idField', array(4 => '3', 7 => '2'))
|
||||
->with('idField', [4 => '3', 7 => '2'])
|
||||
->willReturn($choices);
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
->method('getIdValue')
|
||||
->willReturnMap(array(
|
||||
array($this->obj2, '2'),
|
||||
array($this->obj3, '3'),
|
||||
));
|
||||
->willReturnMap([
|
||||
[$this->obj2, '2'],
|
||||
[$this->obj3, '3'],
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
array(4 => $this->obj3, 7 => $this->obj2),
|
||||
$loader->loadChoicesForValues(array(4 => '3', 7 => '2')
|
||||
[4 => $this->obj3, 7 => $this->obj2],
|
||||
$loader->loadChoicesForValues([4 => '3', 7 => '2']
|
||||
));
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->idReader
|
||||
);
|
||||
|
||||
$choices = array($this->obj1, $this->obj2, $this->obj3);
|
||||
$choices = [$this->obj1, $this->obj2, $this->obj3];
|
||||
$value = function (\stdClass $object) { return $object->name; };
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
@ -381,8 +381,8 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
->method('findAll')
|
||||
->willReturn($choices);
|
||||
|
||||
$this->assertSame(array($this->obj2), $loader->loadChoicesForValues(
|
||||
array('B'),
|
||||
$this->assertSame([$this->obj2], $loader->loadChoicesForValues(
|
||||
['B'],
|
||||
$value
|
||||
));
|
||||
}
|
||||
@ -396,8 +396,8 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
$this->objectLoader
|
||||
);
|
||||
|
||||
$choices = array($this->obj2, $this->obj3);
|
||||
$value = array($this->idReader, 'getIdValue');
|
||||
$choices = [$this->obj2, $this->obj3];
|
||||
$value = [$this->idReader, 'getIdValue'];
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
->method('isSingleId')
|
||||
@ -412,16 +412,16 @@ class DoctrineChoiceLoaderTest extends TestCase
|
||||
|
||||
$this->objectLoader->expects($this->once())
|
||||
->method('getEntitiesByIds')
|
||||
->with('idField', array('2'))
|
||||
->with('idField', ['2'])
|
||||
->willReturn($choices);
|
||||
|
||||
$this->idReader->expects($this->any())
|
||||
->method('getIdValue')
|
||||
->willReturnMap(array(
|
||||
array($this->obj2, '2'),
|
||||
array($this->obj3, '3'),
|
||||
));
|
||||
->willReturnMap([
|
||||
[$this->obj2, '2'],
|
||||
[$this->obj3, '3'],
|
||||
]);
|
||||
|
||||
$this->assertSame(array($this->obj2), $loader->loadChoicesForValues(array('2'), $value));
|
||||
$this->assertSame([$this->obj2], $loader->loadChoicesForValues(['2'], $value));
|
||||
}
|
||||
}
|
||||
|
@ -34,17 +34,17 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$query = $this->getMockBuilder('QueryMock')
|
||||
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
|
||||
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
|
||||
->getMock();
|
||||
|
||||
$query->expects($this->once())
|
||||
->method('setParameter')
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2), $expectedType)
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2], $expectedType)
|
||||
->willReturn($query);
|
||||
|
||||
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
|
||||
->setConstructorArgs(array($em))
|
||||
->setMethods(array('getQuery'))
|
||||
->setConstructorArgs([$em])
|
||||
->setMethods(['getQuery'])
|
||||
->getMock();
|
||||
|
||||
$qb->expects($this->once())
|
||||
@ -55,7 +55,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
->from($classname, 'e');
|
||||
|
||||
$loader = new ORMQueryBuilderLoader($qb);
|
||||
$loader->getEntitiesByIds('id', array(1, 2));
|
||||
$loader->getEntitiesByIds('id', [1, 2]);
|
||||
}
|
||||
|
||||
public function testFilterNonIntegerValues()
|
||||
@ -63,17 +63,17 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$query = $this->getMockBuilder('QueryMock')
|
||||
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
|
||||
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
|
||||
->getMock();
|
||||
|
||||
$query->expects($this->once())
|
||||
->method('setParameter')
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array(1, 2, 3, '9223372036854775808'), Connection::PARAM_INT_ARRAY)
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY)
|
||||
->willReturn($query);
|
||||
|
||||
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
|
||||
->setConstructorArgs(array($em))
|
||||
->setMethods(array('getQuery'))
|
||||
->setConstructorArgs([$em])
|
||||
->setMethods(['getQuery'])
|
||||
->getMock();
|
||||
|
||||
$qb->expects($this->once())
|
||||
@ -84,7 +84,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
->from('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', 'e');
|
||||
|
||||
$loader = new ORMQueryBuilderLoader($qb);
|
||||
$loader->getEntitiesByIds('id', array(1, '', 2, 3, 'foo', '9223372036854775808'));
|
||||
$loader->getEntitiesByIds('id', [1, '', 2, 3, 'foo', '9223372036854775808']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,17 +95,17 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$query = $this->getMockBuilder('QueryMock')
|
||||
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
|
||||
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
|
||||
->getMock();
|
||||
|
||||
$query->expects($this->once())
|
||||
->method('setParameter')
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'), Connection::PARAM_STR_ARRAY)
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY)
|
||||
->willReturn($query);
|
||||
|
||||
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
|
||||
->setConstructorArgs(array($em))
|
||||
->setMethods(array('getQuery'))
|
||||
->setConstructorArgs([$em])
|
||||
->setMethods(['getQuery'])
|
||||
->getMock();
|
||||
|
||||
$qb->expects($this->once())
|
||||
@ -116,7 +116,7 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
->from($entityClass, 'e');
|
||||
|
||||
$loader = new ORMQueryBuilderLoader($qb);
|
||||
$loader->getEntitiesByIds('id', array('71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499'));
|
||||
$loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']);
|
||||
}
|
||||
|
||||
public function testEmbeddedIdentifierName()
|
||||
@ -130,17 +130,17 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
|
||||
$query = $this->getMockBuilder('QueryMock')
|
||||
->setMethods(array('setParameter', 'getResult', 'getSql', '_doExecute'))
|
||||
->setMethods(['setParameter', 'getResult', 'getSql', '_doExecute'])
|
||||
->getMock();
|
||||
|
||||
$query->expects($this->once())
|
||||
->method('setParameter')
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', array(1, 2, 3), Connection::PARAM_INT_ARRAY)
|
||||
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY)
|
||||
->willReturn($query);
|
||||
|
||||
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
|
||||
->setConstructorArgs(array($em))
|
||||
->setMethods(array('getQuery'))
|
||||
->setConstructorArgs([$em])
|
||||
->setMethods(['getQuery'])
|
||||
->getMock();
|
||||
$qb->expects($this->once())
|
||||
->method('getQuery')
|
||||
@ -150,14 +150,14 @@ class ORMQueryBuilderLoaderTest extends TestCase
|
||||
->from('Symfony\Bridge\Doctrine\Tests\Fixtures\EmbeddedIdentifierEntity', 'e');
|
||||
|
||||
$loader = new ORMQueryBuilderLoader($qb);
|
||||
$loader->getEntitiesByIds('id.value', array(1, '', 2, 3, 'foo'));
|
||||
$loader->getEntitiesByIds('id.value', [1, '', 2, 3, 'foo']);
|
||||
}
|
||||
|
||||
public function provideGuidEntityClasses()
|
||||
{
|
||||
return array(
|
||||
array('Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'),
|
||||
array('Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'),
|
||||
);
|
||||
return [
|
||||
['Symfony\Bridge\Doctrine\Tests\Fixtures\GuidIdEntity'],
|
||||
['Symfony\Bridge\Doctrine\Tests\Fixtures\UuidIdEntity'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ class CollectionToArrayTransformerTest extends TestCase
|
||||
|
||||
public function testTransform()
|
||||
{
|
||||
$array = array(
|
||||
$array = [
|
||||
2 => 'foo',
|
||||
3 => 'bar',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertSame($array, $this->transformer->transform(new ArrayCollection($array)));
|
||||
}
|
||||
@ -49,17 +49,17 @@ class CollectionToArrayTransformerTest extends TestCase
|
||||
*/
|
||||
public function testTransformArray()
|
||||
{
|
||||
$array = array(
|
||||
$array = [
|
||||
2 => 'foo',
|
||||
3 => 'bar',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertSame($array, $this->transformer->transform($array));
|
||||
}
|
||||
|
||||
public function testTransformNull()
|
||||
{
|
||||
$this->assertSame(array(), $this->transformer->transform(null));
|
||||
$this->assertSame([], $this->transformer->transform(null));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,10 +72,10 @@ class CollectionToArrayTransformerTest extends TestCase
|
||||
|
||||
public function testReverseTransform()
|
||||
{
|
||||
$array = array(
|
||||
$array = [
|
||||
2 => 'foo',
|
||||
3 => 'bar',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals(new ArrayCollection($array), $this->transformer->reverseTransform($array));
|
||||
}
|
||||
|
@ -29,54 +29,54 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
|
||||
public function requiredProvider()
|
||||
{
|
||||
$return = array();
|
||||
$return = [];
|
||||
|
||||
// Simple field, not nullable
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->fieldMappings['field'] = true;
|
||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false));
|
||||
|
||||
$return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE));
|
||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// Simple field, nullable
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->fieldMappings['field'] = true;
|
||||
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true));
|
||||
|
||||
$return[] = array($classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE));
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
|
||||
|
||||
// One-to-one, nullable (by default)
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
|
||||
|
||||
$mapping = array('joinColumns' => array(array()));
|
||||
$mapping = ['joinColumns' => [[]]];
|
||||
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
|
||||
|
||||
$return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE));
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-one, nullable (explicit)
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
|
||||
|
||||
$mapping = array('joinColumns' => array(array('nullable' => true)));
|
||||
$mapping = ['joinColumns' => [['nullable' => true]]];
|
||||
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
|
||||
|
||||
$return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE));
|
||||
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-one, not nullable
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
|
||||
|
||||
$mapping = array('joinColumns' => array(array('nullable' => false)));
|
||||
$mapping = ['joinColumns' => [['nullable' => false]]];
|
||||
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
|
||||
|
||||
$return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE));
|
||||
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
|
||||
|
||||
// One-to-many, no clue
|
||||
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
|
||||
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false));
|
||||
|
||||
$return[] = array($classMetadata, null);
|
||||
$return[] = [$classMetadata, null];
|
||||
|
||||
return $return;
|
||||
}
|
||||
@ -87,7 +87,7 @@ class DoctrineOrmTypeGuesserTest extends TestCase
|
||||
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
|
||||
|
||||
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||
$registry->expects($this->once())->method('getManagers')->will($this->returnValue(array($em)));
|
||||
$registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em]));
|
||||
|
||||
return new DoctrineOrmTypeGuesser($registry);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->collection = new ArrayCollection(array('test'));
|
||||
$this->collection = new ArrayCollection(['test']);
|
||||
$this->dispatcher = new EventDispatcher();
|
||||
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
|
||||
$this->form = $this->getBuilder()
|
||||
@ -60,7 +60,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
|
||||
public function testOnSubmitDoNothing()
|
||||
{
|
||||
$submittedData = array('test');
|
||||
$submittedData = ['test'];
|
||||
$event = new FormEvent($this->getForm(), $submittedData);
|
||||
|
||||
$this->dispatcher->dispatch(FormEvents::SUBMIT, $event);
|
||||
@ -71,7 +71,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
|
||||
public function testOnSubmitNullClearCollection()
|
||||
{
|
||||
$submittedData = array();
|
||||
$submittedData = [];
|
||||
$event = new FormEvent($this->getForm(), $submittedData);
|
||||
|
||||
$this->dispatcher->dispatch(FormEvents::SUBMIT, $event);
|
||||
@ -88,7 +88,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
|
||||
->setData($this->collection)
|
||||
->addEventSubscriber(new TestClassExtendingMergeDoctrineCollectionListener())
|
||||
->getForm();
|
||||
$submittedData = array();
|
||||
$submittedData = [];
|
||||
$event = new FormEvent($form, $submittedData);
|
||||
|
||||
$this->dispatcher->dispatch(FormEvents::SUBMIT, $event);
|
||||
|
@ -42,10 +42,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
->method('getManagerForClass')
|
||||
->will($this->returnValue($this->em));
|
||||
|
||||
return array(
|
||||
return [
|
||||
new CoreExtension(),
|
||||
new DoctrineOrmExtension($manager),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
@ -55,9 +55,9 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
parent::setUp();
|
||||
|
||||
$schemaTool = new SchemaTool($this->em);
|
||||
$classes = array(
|
||||
$classes = [
|
||||
$this->em->getClassMetadata(self::ENTITY_CLASS),
|
||||
);
|
||||
];
|
||||
|
||||
try {
|
||||
$schemaTool->dropSchema($classes);
|
||||
@ -90,9 +90,9 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
$this->setMaxRunningTime(1);
|
||||
|
||||
for ($i = 0; $i < 40; ++$i) {
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [
|
||||
'class' => self::ENTITY_CLASS,
|
||||
));
|
||||
]);
|
||||
|
||||
// force loading of the choice list
|
||||
$form->createView();
|
||||
@ -108,10 +108,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
$this->setMaxRunningTime(1);
|
||||
|
||||
for ($i = 0; $i < 40; ++$i) {
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [
|
||||
'class' => self::ENTITY_CLASS,
|
||||
'choices' => $choices,
|
||||
));
|
||||
]);
|
||||
|
||||
// force loading of the choice list
|
||||
$form->createView();
|
||||
@ -127,10 +127,10 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
|
||||
$this->setMaxRunningTime(1);
|
||||
|
||||
for ($i = 0; $i < 40; ++$i) {
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array(
|
||||
$form = $this->factory->create('Symfony\Bridge\Doctrine\Form\Type\EntityType', null, [
|
||||
'class' => self::ENTITY_CLASS,
|
||||
'preferred_choices' => $choices,
|
||||
));
|
||||
]);
|
||||
|
||||
// force loading of the choice list
|
||||
$form->createView();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,8 +25,8 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||
->setConstructorArgs(array($logger, null))
|
||||
->setMethods(array('log'))
|
||||
->setConstructorArgs([$logger, null])
|
||||
->setMethods(['log'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
@ -41,14 +41,14 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
public function getLogFixtures()
|
||||
{
|
||||
return array(
|
||||
array('SQL', null, array()),
|
||||
array('SQL', array(), array()),
|
||||
array('SQL', array('foo' => 'bar'), array('foo' => 'bar')),
|
||||
array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||
array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)),
|
||||
array('SQL', array('foo' => ''), array('foo' => '')),
|
||||
);
|
||||
return [
|
||||
['SQL', null, []],
|
||||
['SQL', [], []],
|
||||
['SQL', ['foo' => 'bar'], ['foo' => 'bar']],
|
||||
['SQL', ['foo' => "\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]],
|
||||
['SQL', ['foo' => "bar\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]],
|
||||
['SQL', ['foo' => ''], ['foo' => '']],
|
||||
];
|
||||
}
|
||||
|
||||
public function testLogNonUtf8()
|
||||
@ -57,21 +57,21 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||
->setConstructorArgs(array($logger, null))
|
||||
->setMethods(array('log'))
|
||||
->setConstructorArgs([$logger, null])
|
||||
->setMethods(['log'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$dbalLogger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with('SQL', array('utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE))
|
||||
->with('SQL', ['utf8' => 'foo', 'nonutf8' => DbalLogger::BINARY_DATA_VALUE])
|
||||
;
|
||||
|
||||
$dbalLogger->startQuery('SQL', array(
|
||||
$dbalLogger->startQuery('SQL', [
|
||||
'utf8' => 'foo',
|
||||
'nonutf8' => "\x7F\xFF",
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testLogNonUtf8Array()
|
||||
@ -80,29 +80,29 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||
->setConstructorArgs(array($logger, null))
|
||||
->setMethods(array('log'))
|
||||
->setConstructorArgs([$logger, null])
|
||||
->setMethods(['log'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$dbalLogger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with('SQL', array(
|
||||
->with('SQL', [
|
||||
'utf8' => 'foo',
|
||||
array(
|
||||
[
|
||||
'nonutf8' => DbalLogger::BINARY_DATA_VALUE,
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
)
|
||||
;
|
||||
|
||||
$dbalLogger->startQuery('SQL', array(
|
||||
$dbalLogger->startQuery('SQL', [
|
||||
'utf8' => 'foo',
|
||||
array(
|
||||
[
|
||||
'nonutf8' => "\x7F\xFF",
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function testLogLongString()
|
||||
@ -111,8 +111,8 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||
->setConstructorArgs(array($logger, null))
|
||||
->setMethods(array('log'))
|
||||
->setConstructorArgs([$logger, null])
|
||||
->setMethods(['log'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
@ -124,13 +124,13 @@ class DbalLoggerTest extends TestCase
|
||||
$dbalLogger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with('SQL', array('short' => $shortString, 'long' => substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6).' [...]'))
|
||||
->with('SQL', ['short' => $shortString, 'long' => substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6).' [...]'])
|
||||
;
|
||||
|
||||
$dbalLogger->startQuery('SQL', array(
|
||||
$dbalLogger->startQuery('SQL', [
|
||||
'short' => $shortString,
|
||||
'long' => $longString,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testLogUTF8LongString()
|
||||
@ -139,12 +139,12 @@ class DbalLoggerTest extends TestCase
|
||||
|
||||
$dbalLogger = $this
|
||||
->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger')
|
||||
->setConstructorArgs(array($logger, null))
|
||||
->setMethods(array('log'))
|
||||
->setConstructorArgs([$logger, null])
|
||||
->setMethods(['log'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í');
|
||||
$testStringArray = ['é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í'];
|
||||
$testStringCount = \count($testStringArray);
|
||||
|
||||
$shortString = '';
|
||||
@ -158,12 +158,12 @@ class DbalLoggerTest extends TestCase
|
||||
$dbalLogger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'))
|
||||
->with('SQL', ['short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'])
|
||||
;
|
||||
|
||||
$dbalLogger->startQuery('SQL', array(
|
||||
$dbalLogger->startQuery('SQL', [
|
||||
'short' => $shortString,
|
||||
'long' => $longString,
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ManagerRegistryTest extends TestCase
|
||||
{
|
||||
$container = new \LazyServiceProjectServiceContainer();
|
||||
|
||||
$registry = new TestManagerRegistry('name', array(), array('defaultManager' => 'foo'), 'defaultConnection', 'defaultManager', 'proxyInterfaceName');
|
||||
$registry = new TestManagerRegistry('name', [], ['defaultManager' => 'foo'], 'defaultConnection', 'defaultManager', 'proxyInterfaceName');
|
||||
$registry->setTestContainer($container);
|
||||
|
||||
$foo = $container->get('foo');
|
||||
|
@ -30,8 +30,8 @@ class DoctrineExtractorTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'), true);
|
||||
$entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config);
|
||||
$config = Setup::createAnnotationMetadataConfiguration([__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'], true);
|
||||
$entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config);
|
||||
|
||||
if (!DBALType::hasType('foo')) {
|
||||
DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType');
|
||||
@ -44,7 +44,7 @@ class DoctrineExtractorTest extends TestCase
|
||||
public function testGetProperties()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'id',
|
||||
'guid',
|
||||
'time',
|
||||
@ -62,7 +62,7 @@ class DoctrineExtractorTest extends TestCase
|
||||
'bar',
|
||||
'indexedBar',
|
||||
'indexedFoo',
|
||||
),
|
||||
],
|
||||
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
|
||||
);
|
||||
}
|
||||
@ -74,10 +74,10 @@ class DoctrineExtractorTest extends TestCase
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'id',
|
||||
'embedded',
|
||||
),
|
||||
],
|
||||
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded')
|
||||
);
|
||||
}
|
||||
@ -87,7 +87,7 @@ class DoctrineExtractorTest extends TestCase
|
||||
*/
|
||||
public function testExtract($property, array $type = null)
|
||||
{
|
||||
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
|
||||
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, []));
|
||||
}
|
||||
|
||||
public function testExtractWithEmbedded()
|
||||
@ -96,16 +96,16 @@ class DoctrineExtractorTest extends TestCase
|
||||
$this->markTestSkipped('@Embedded is not available in Doctrine ORM lower than 2.5.');
|
||||
}
|
||||
|
||||
$expectedTypes = array(new Type(
|
||||
$expectedTypes = [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineEmbeddable'
|
||||
));
|
||||
)];
|
||||
|
||||
$actualTypes = $this->extractor->getTypes(
|
||||
'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineWithEmbedded',
|
||||
'embedded',
|
||||
array()
|
||||
[]
|
||||
);
|
||||
|
||||
$this->assertEquals($expectedTypes, $actualTypes);
|
||||
@ -113,47 +113,47 @@ class DoctrineExtractorTest extends TestCase
|
||||
|
||||
public function typesProvider()
|
||||
{
|
||||
return array(
|
||||
array('id', array(new Type(Type::BUILTIN_TYPE_INT))),
|
||||
array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))),
|
||||
array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))),
|
||||
array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))),
|
||||
array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))),
|
||||
array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))),
|
||||
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
|
||||
array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))),
|
||||
array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))),
|
||||
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))),
|
||||
array('bar', array(new Type(
|
||||
return [
|
||||
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
|
||||
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['time', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
|
||||
['timeImmutable', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
|
||||
['dateInterval', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval')]],
|
||||
['float', [new Type(Type::BUILTIN_TYPE_FLOAT)]],
|
||||
['decimal', [new Type(Type::BUILTIN_TYPE_STRING)]],
|
||||
['bool', [new Type(Type::BUILTIN_TYPE_BOOL)]],
|
||||
['binary', [new Type(Type::BUILTIN_TYPE_RESOURCE)]],
|
||||
['json', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true)]],
|
||||
['foo', [new Type(Type::BUILTIN_TYPE_OBJECT, true, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')]],
|
||||
['bar', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_INT),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('indexedBar', array(new Type(
|
||||
)]],
|
||||
['indexedBar', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_STRING),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('indexedFoo', array(new Type(
|
||||
)]],
|
||||
['indexedFoo', [new Type(
|
||||
Type::BUILTIN_TYPE_OBJECT,
|
||||
false,
|
||||
'Doctrine\Common\Collections\Collection',
|
||||
true,
|
||||
new Type(Type::BUILTIN_TYPE_STRING),
|
||||
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
|
||||
))),
|
||||
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
|
||||
array('customFoo', null),
|
||||
array('notMapped', null),
|
||||
);
|
||||
)]],
|
||||
['simpleArray', [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING))]],
|
||||
['customFoo', null],
|
||||
['notMapped', null],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetPropertiesCatchException()
|
||||
|
@ -38,7 +38,7 @@ class DoctrineFooType extends Type
|
||||
*/
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
|
||||
{
|
||||
return $platform->getClobTypeDeclarationSQL(array());
|
||||
return $platform->getClobTypeDeclarationSQL([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,7 +145,7 @@ class EntityUserProviderTest extends TestCase
|
||||
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');
|
||||
|
||||
$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1));
|
||||
$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', ['id1' => 1, 'id2' => 1]);
|
||||
$this->assertTrue($provider->supportsClass(\get_class($user2)));
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ class EntityUserProviderTest extends TestCase
|
||||
private function getObjectManager($repository)
|
||||
{
|
||||
$em = $this->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager')
|
||||
->setMethods(array('getClassMetadata', 'getRepository'))
|
||||
->setMethods(['getClassMetadata', 'getRepository'])
|
||||
->getMockForAbstractClass();
|
||||
$em->expects($this->any())
|
||||
->method('getRepository')
|
||||
@ -208,8 +208,8 @@ class EntityUserProviderTest extends TestCase
|
||||
private function createSchema($em)
|
||||
{
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->createSchema(array(
|
||||
$schemaTool->createSchema([
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\User'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
protected function createRepositoryMock()
|
||||
{
|
||||
$repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')
|
||||
->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName'))
|
||||
->setMethods(['findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
@ -118,8 +118,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->getMock()
|
||||
;
|
||||
$refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty')
|
||||
->setConstructorArgs(array($reflParser, 'property-name'))
|
||||
->setMethods(array('getValue'))
|
||||
->setConstructorArgs([$reflParser, 'property-name'])
|
||||
->setMethods(['getValue'])
|
||||
->getMock()
|
||||
;
|
||||
$refl
|
||||
@ -127,7 +127,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->method('getValue')
|
||||
->will($this->returnValue(true))
|
||||
;
|
||||
$classMetadata->reflFields = array('name' => $refl);
|
||||
$classMetadata->reflFields = ['name' => $refl];
|
||||
$em->expects($this->any())
|
||||
->method('getClassMetadata')
|
||||
->will($this->returnValue($classMetadata))
|
||||
@ -144,7 +144,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
private function createSchema(ObjectManager $em)
|
||||
{
|
||||
$schemaTool = new SchemaTool($em);
|
||||
$schemaTool->createSchema(array(
|
||||
$schemaTool->createSchema([
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'),
|
||||
@ -156,7 +156,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'),
|
||||
$em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,11 +164,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testValidateUniqueness()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||
$entity2 = new SingleIntIdEntity(2, 'Foo');
|
||||
@ -190,19 +190,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name')
|
||||
->setParameter('{{ value }}', '"Foo"')
|
||||
->setInvalidValue($entity2)
|
||||
->setCause(array($entity1))
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateCustomErrorPath()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'errorPath' => 'bar',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||
$entity2 = new SingleIntIdEntity(2, 'Foo');
|
||||
@ -216,18 +216,18 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.bar')
|
||||
->setParameter('{{ value }}', '"Foo"')
|
||||
->setInvalidValue($entity2)
|
||||
->setCause(array($entity1))
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateUniquenessWithNull()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, null);
|
||||
$entity2 = new SingleIntIdEntity(2, null);
|
||||
@ -243,12 +243,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testValidateUniquenessWithIgnoreNullDisabled()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name', 'name2'),
|
||||
'fields' => ['name', 'name2'],
|
||||
'em' => self::EM_NAME,
|
||||
'ignoreNull' => false,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new DoubleNameEntity(1, 'Foo', null);
|
||||
$entity2 = new DoubleNameEntity(2, 'Foo', null);
|
||||
@ -270,7 +270,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name')
|
||||
->setParameter('{{ value }}', '"Foo"')
|
||||
->setInvalidValue('Foo')
|
||||
->setCause(array($entity1))
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
@ -280,12 +280,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgnoreNullEnabled()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name', 'name2'),
|
||||
'fields' => ['name', 'name2'],
|
||||
'em' => self::EM_NAME,
|
||||
'ignoreNull' => true,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, null);
|
||||
|
||||
@ -294,12 +294,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name', 'name2'),
|
||||
'fields' => ['name', 'name2'],
|
||||
'em' => self::EM_NAME,
|
||||
'ignoreNull' => true,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new DoubleNullableNameEntity(1, null, 'Foo');
|
||||
$entity2 = new DoubleNullableNameEntity(2, null, 'Foo');
|
||||
@ -322,12 +322,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testValidateUniquenessWithValidCustomErrorPath()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name', 'name2'),
|
||||
'fields' => ['name', 'name2'],
|
||||
'em' => self::EM_NAME,
|
||||
'errorPath' => 'name2',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new DoubleNameEntity(1, 'Foo', 'Bar');
|
||||
$entity2 = new DoubleNameEntity(2, 'Foo', 'Bar');
|
||||
@ -349,24 +349,24 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name2')
|
||||
->setParameter('{{ value }}', '"Bar"')
|
||||
->setInvalidValue('Bar')
|
||||
->setCause(array($entity1))
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateUniquenessUsingCustomRepositoryMethod()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'repositoryMethod' => 'findByCustom',
|
||||
));
|
||||
]);
|
||||
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will($this->returnValue(array()))
|
||||
->will($this->returnValue([]))
|
||||
;
|
||||
$this->em = $this->createEntityManagerMock($repository);
|
||||
$this->registry = $this->createRegistryMock($this->em);
|
||||
@ -382,12 +382,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testValidateUniquenessWithUnrewoundArray()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'repositoryMethod' => 'findByCustom',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity = new SingleIntIdEntity(1, 'foo');
|
||||
|
||||
@ -396,9 +396,9 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->method('findByCustom')
|
||||
->will(
|
||||
$this->returnCallback(function () use ($entity) {
|
||||
$returnValue = array(
|
||||
$returnValue = [
|
||||
$entity,
|
||||
);
|
||||
];
|
||||
next($returnValue);
|
||||
|
||||
return $returnValue;
|
||||
@ -420,12 +420,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testValidateResultTypes($entity1, $result)
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'repositoryMethod' => 'findByCustom',
|
||||
));
|
||||
]);
|
||||
|
||||
$repository = $this->createRepositoryMock();
|
||||
$repository->expects($this->once())
|
||||
@ -446,20 +446,20 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$entity = new SingleIntIdEntity(1, 'foo');
|
||||
|
||||
return array(
|
||||
array($entity, array($entity)),
|
||||
array($entity, new \ArrayIterator(array($entity))),
|
||||
array($entity, new ArrayCollection(array($entity))),
|
||||
);
|
||||
return [
|
||||
[$entity, [$entity]],
|
||||
[$entity, new \ArrayIterator([$entity])],
|
||||
[$entity, new ArrayCollection([$entity])],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAssociatedEntity()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('single'),
|
||||
'fields' => ['single'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, 'foo');
|
||||
$associated = new AssociationEntity();
|
||||
@ -485,17 +485,17 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->setParameter('{{ value }}', 'foo')
|
||||
->setInvalidValue($entity1)
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->setCause(array($associated, $associated2))
|
||||
->setCause([$associated, $associated2])
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateUniquenessNotToStringEntityWithAssociatedEntity()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('single'),
|
||||
'fields' => ['single'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdNoToStringEntity(1, 'foo');
|
||||
$associated = new AssociationEntity2();
|
||||
@ -522,19 +522,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.single')
|
||||
->setParameter('{{ value }}', $expectedValue)
|
||||
->setInvalidValue($entity1)
|
||||
->setCause(array($associated, $associated2))
|
||||
->setCause([$associated, $associated2])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testAssociatedEntityWithNull()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('single'),
|
||||
'fields' => ['single'],
|
||||
'em' => self::EM_NAME,
|
||||
'ignoreNull' => false,
|
||||
));
|
||||
]);
|
||||
|
||||
$associated = new AssociationEntity();
|
||||
$associated->single = null;
|
||||
@ -552,19 +552,19 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$repository = $this->createRepositoryMock();
|
||||
$this->repositoryFactory->setRepository($this->em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', $repository);
|
||||
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('phoneNumbers'),
|
||||
'fields' => ['phoneNumbers'],
|
||||
'em' => self::EM_NAME,
|
||||
'repositoryMethod' => 'findByCustom',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, 'foo');
|
||||
$entity1->phoneNumbers[] = 123;
|
||||
|
||||
$repository->expects($this->once())
|
||||
->method('findByCustom')
|
||||
->will($this->returnValue(array($entity1)))
|
||||
->will($this->returnValue([$entity1]))
|
||||
;
|
||||
|
||||
$this->em->persist($entity1);
|
||||
@ -580,8 +580,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->buildViolation('myMessage')
|
||||
->atPath('property.path.phoneNumbers')
|
||||
->setParameter('{{ value }}', 'array')
|
||||
->setInvalidValue(array(123))
|
||||
->setCause(array($entity1))
|
||||
->setInvalidValue([123])
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
@ -592,11 +592,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testDedicatedEntityManagerNullObject()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$this->em = null;
|
||||
$this->registry = $this->createRegistryMock($this->em);
|
||||
@ -614,11 +614,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testEntityManagerNullObject()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
// no "em" option set
|
||||
));
|
||||
]);
|
||||
|
||||
$this->em = null;
|
||||
$this->registry = $this->createRegistryMock($this->em);
|
||||
@ -643,11 +643,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->validator = $this->createValidator();
|
||||
$this->validator->initialize($this->context);
|
||||
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity = new SingleIntIdEntity(1, null);
|
||||
|
||||
@ -660,12 +660,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testValidateInheritanceUniqueness()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\Person',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new Person(1, 'Foo');
|
||||
$entity2 = new Employee(2, 'Foo');
|
||||
@ -687,8 +687,8 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name')
|
||||
->setInvalidValue('Foo')
|
||||
->setCode('23bd9dbf-6b9b-41cd-a99e-4844bcf3077f')
|
||||
->setCause(array($entity1))
|
||||
->setParameters(array('{{ value }}' => '"Foo"'))
|
||||
->setCause([$entity1])
|
||||
->setParameters(['{{ value }}' => '"Foo"'])
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
@ -698,12 +698,12 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testInvalidateRepositoryForInheritance()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity',
|
||||
));
|
||||
]);
|
||||
|
||||
$entity = new Person(1, 'Foo');
|
||||
$this->validator->validate($entity, $constraint);
|
||||
@ -711,11 +711,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
public function testValidateUniquenessWithCompositeObjectNoToStringIdEntity()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('objectOne', 'objectTwo'),
|
||||
'fields' => ['objectOne', 'objectTwo'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$objectOne = new SingleIntIdNoToStringEntity(1, 'foo');
|
||||
$objectTwo = new SingleIntIdNoToStringEntity(2, 'bar');
|
||||
@ -739,18 +739,18 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.objectOne')
|
||||
->setParameter('{{ value }}', $expectedValue)
|
||||
->setInvalidValue($objectOne)
|
||||
->setCause(array($entity))
|
||||
->setCause([$entity])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateUniquenessWithCustomDoctrineTypeValue()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$existingEntity = new SingleIntIdStringWrapperNameEntity(1, new StringWrapper('foo'));
|
||||
|
||||
@ -767,7 +767,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name')
|
||||
->setParameter('{{ value }}', $expectedValue)
|
||||
->setInvalidValue($existingEntity->name)
|
||||
->setCause(array($existingEntity))
|
||||
->setCause([$existingEntity])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
@ -777,11 +777,11 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
*/
|
||||
public function testValidateUniquenessCause()
|
||||
{
|
||||
$constraint = new UniqueEntity(array(
|
||||
$constraint = new UniqueEntity([
|
||||
'message' => 'myMessage',
|
||||
'fields' => array('name'),
|
||||
'fields' => ['name'],
|
||||
'em' => self::EM_NAME,
|
||||
));
|
||||
]);
|
||||
|
||||
$entity1 = new SingleIntIdEntity(1, 'Foo');
|
||||
$entity2 = new SingleIntIdEntity(2, 'Foo');
|
||||
@ -803,7 +803,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
|
||||
->atPath('property.path.name')
|
||||
->setParameter('{{ value }}', '"Foo"')
|
||||
->setInvalidValue($entity2)
|
||||
->setCause(array($entity1))
|
||||
->setCause([$entity1])
|
||||
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
@ -30,17 +30,17 @@ class UniqueEntity extends Constraint
|
||||
public $em = null;
|
||||
public $entityClass = null;
|
||||
public $repositoryMethod = 'findBy';
|
||||
public $fields = array();
|
||||
public $fields = [];
|
||||
public $errorPath = null;
|
||||
public $ignoreNull = true;
|
||||
|
||||
protected static $errorNames = array(
|
||||
protected static $errorNames = [
|
||||
self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR',
|
||||
);
|
||||
];
|
||||
|
||||
public function getRequiredOptions()
|
||||
{
|
||||
return array('fields');
|
||||
return ['fields'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
$class = $em->getClassMetadata(\get_class($entity));
|
||||
/* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */
|
||||
|
||||
$criteria = array();
|
||||
$criteria = [];
|
||||
$hasNullValue = false;
|
||||
|
||||
foreach ($fields as $fieldName) {
|
||||
@ -149,15 +149,15 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
if ($result instanceof \Iterator) {
|
||||
$result->rewind();
|
||||
if ($result instanceof \Countable && 1 < \count($result)) {
|
||||
$result = array($result->current(), $result->current());
|
||||
$result = [$result->current(), $result->current()];
|
||||
} else {
|
||||
$result = $result->current();
|
||||
$result = null === $result ? array() : array($result);
|
||||
$result = null === $result ? [] : [$result];
|
||||
}
|
||||
} elseif (\is_array($result)) {
|
||||
reset($result);
|
||||
} else {
|
||||
$result = null === $result ? array() : array($result);
|
||||
$result = null === $result ? [] : [$result];
|
||||
}
|
||||
|
||||
/* If no entity matched the query criteria or a single entity matched,
|
||||
@ -197,7 +197,7 @@ class UniqueEntityValidator extends ConstraintValidator
|
||||
} else {
|
||||
// this case might happen if the non unique column has a custom doctrine type and its value is an object
|
||||
// in which case we cannot get any identifiers for it
|
||||
$identifiers = array();
|
||||
$identifiers = [];
|
||||
}
|
||||
} else {
|
||||
$identifiers = $class->getIdentifierValues($value);
|
||||
|
@ -30,7 +30,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
const SIMPLE_FORMAT = "%datetime% %start_tag%%level_name%%end_tag% <comment>[%channel%]</> %message%%context%%extra%\n";
|
||||
const SIMPLE_DATE = 'H:i:s';
|
||||
|
||||
private static $levelColorMap = array(
|
||||
private static $levelColorMap = [
|
||||
Logger::DEBUG => 'fg=white',
|
||||
Logger::INFO => 'fg=green',
|
||||
Logger::NOTICE => 'fg=blue',
|
||||
@ -39,7 +39,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
Logger::CRITICAL => 'fg=red',
|
||||
Logger::ALERT => 'fg=red',
|
||||
Logger::EMERGENCY => 'fg=white;bg=red',
|
||||
);
|
||||
];
|
||||
|
||||
private $options;
|
||||
private $cloner;
|
||||
@ -53,13 +53,13 @@ class ConsoleFormatter implements FormatterInterface
|
||||
* * colors: If true, the log string contains ANSI code to add color;
|
||||
* * multiline: If false, "context" and "extra" are dumped on one line.
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
public function __construct($options = [])
|
||||
{
|
||||
// BC Layer
|
||||
if (!\is_array($options)) {
|
||||
@trigger_error(sprintf('The constructor arguments $format, $dateFormat, $allowInlineLineBreaks, $ignoreEmptyContextAndExtra of "%s" are deprecated since Symfony 3.3 and will be removed in 4.0. Use $options instead.', self::class), E_USER_DEPRECATED);
|
||||
$args = \func_get_args();
|
||||
$options = array();
|
||||
$options = [];
|
||||
if (isset($args[0])) {
|
||||
$options['format'] = $args[0];
|
||||
}
|
||||
@ -74,25 +74,25 @@ class ConsoleFormatter implements FormatterInterface
|
||||
}
|
||||
}
|
||||
|
||||
$this->options = array_replace(array(
|
||||
$this->options = array_replace([
|
||||
'format' => self::SIMPLE_FORMAT,
|
||||
'date_format' => self::SIMPLE_DATE,
|
||||
'colors' => true,
|
||||
'multiline' => false,
|
||||
'ignore_empty_context_and_extra' => true,
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
if (class_exists(VarCloner::class)) {
|
||||
$this->cloner = new VarCloner();
|
||||
$this->cloner->addCasters(array(
|
||||
'*' => array($this, 'castObject'),
|
||||
));
|
||||
$this->cloner->addCasters([
|
||||
'*' => [$this, 'castObject'],
|
||||
]);
|
||||
|
||||
$this->outputBuffer = fopen('php://memory', 'r+b');
|
||||
if ($this->options['multiline']) {
|
||||
$output = $this->outputBuffer;
|
||||
} else {
|
||||
$output = array($this, 'echoLine');
|
||||
$output = [$this, 'echoLine'];
|
||||
}
|
||||
|
||||
$this->dumper = new CliDumper($output, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
|
||||
@ -132,7 +132,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
$extra = '';
|
||||
}
|
||||
|
||||
$formatted = strtr($this->options['format'], array(
|
||||
$formatted = strtr($this->options['format'], [
|
||||
'%datetime%' => $record['datetime']->format($this->options['date_format']),
|
||||
'%start_tag%' => sprintf('<%s>', $levelColor),
|
||||
'%level_name%' => sprintf('%-9s', $record['level_name']),
|
||||
@ -141,7 +141,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
'%message%' => $this->replacePlaceHolder($record)['message'],
|
||||
'%context%' => $context,
|
||||
'%extra%' => $extra,
|
||||
));
|
||||
]);
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
@ -167,7 +167,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
|
||||
if ($isNested && !$v instanceof \DateTimeInterface) {
|
||||
$s->cut = -1;
|
||||
$a = array();
|
||||
$a = [];
|
||||
}
|
||||
|
||||
return $a;
|
||||
@ -183,7 +183,7 @@ class ConsoleFormatter implements FormatterInterface
|
||||
|
||||
$context = $record['context'];
|
||||
|
||||
$replacements = array();
|
||||
$replacements = [];
|
||||
foreach ($context as $k => $v) {
|
||||
// Remove quotes added by the dumper around string.
|
||||
$v = trim($this->dumpData($v, false), '"');
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
*/
|
||||
class ChromePhpHandler extends BaseChromePhpHandler
|
||||
{
|
||||
private $headers = array();
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
@ -40,7 +40,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
|
||||
|
||||
if (!preg_match(static::USER_AGENT_REGEX, $event->getRequest()->headers->get('User-Agent'))) {
|
||||
$this->sendHeaders = false;
|
||||
$this->headers = array();
|
||||
$this->headers = [];
|
||||
|
||||
return;
|
||||
}
|
||||
@ -49,7 +49,7 @@ class ChromePhpHandler extends BaseChromePhpHandler
|
||||
foreach ($this->headers as $header => $content) {
|
||||
$this->response->headers->set($header, $content);
|
||||
}
|
||||
$this->headers = array();
|
||||
$this->headers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,13 +43,13 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
class ConsoleHandler extends AbstractProcessingHandler implements EventSubscriberInterface
|
||||
{
|
||||
private $output;
|
||||
private $verbosityLevelMap = array(
|
||||
private $verbosityLevelMap = [
|
||||
OutputInterface::VERBOSITY_QUIET => Logger::ERROR,
|
||||
OutputInterface::VERBOSITY_NORMAL => Logger::WARNING,
|
||||
OutputInterface::VERBOSITY_VERBOSE => Logger::NOTICE,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO,
|
||||
OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param OutputInterface|null $output The console output to use (the handler remains disabled when passing null
|
||||
@ -58,7 +58,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
|
||||
* @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging
|
||||
* level (leave empty to use the default mapping)
|
||||
*/
|
||||
public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = array())
|
||||
public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = [])
|
||||
{
|
||||
parent::__construct(Logger::DEBUG, $bubble);
|
||||
$this->output = $output;
|
||||
@ -131,10 +131,10 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
ConsoleEvents::COMMAND => array('onCommand', 255),
|
||||
ConsoleEvents::TERMINATE => array('onTerminate', -255),
|
||||
);
|
||||
return [
|
||||
ConsoleEvents::COMMAND => ['onCommand', 255],
|
||||
ConsoleEvents::TERMINATE => ['onTerminate', -255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,10 +158,10 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
|
||||
return new ConsoleFormatter();
|
||||
}
|
||||
|
||||
return new ConsoleFormatter(array(
|
||||
return new ConsoleFormatter([
|
||||
'colors' => $this->output->isDecorated(),
|
||||
'multiline' => OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,16 +31,16 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
|
||||
*/
|
||||
public function getLogs()
|
||||
{
|
||||
$records = array();
|
||||
$records = [];
|
||||
foreach ($this->records as $record) {
|
||||
$records[] = array(
|
||||
$records[] = [
|
||||
'timestamp' => $record['datetime']->getTimestamp(),
|
||||
'message' => $record['message'],
|
||||
'priority' => $record['level'],
|
||||
'priorityName' => $record['level_name'],
|
||||
'context' => $record['context'],
|
||||
'channel' => isset($record['channel']) ? $record['channel'] : '',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $records;
|
||||
@ -52,7 +52,7 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface
|
||||
public function countErrors()
|
||||
{
|
||||
$cnt = 0;
|
||||
$levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
|
||||
$levels = [Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY];
|
||||
foreach ($levels as $level) {
|
||||
if (isset($this->recordsByLevel[$level])) {
|
||||
$cnt += \count($this->recordsByLevel[$level]);
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
*/
|
||||
class FirePHPHandler extends BaseFirePHPHandler
|
||||
{
|
||||
private $headers = array();
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
@ -42,7 +42,7 @@ class FirePHPHandler extends BaseFirePHPHandler
|
||||
if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent'))
|
||||
&& !$request->headers->has('X-FirePHP-Version')) {
|
||||
self::$sendHeaders = false;
|
||||
$this->headers = array();
|
||||
$this->headers = [];
|
||||
|
||||
return;
|
||||
}
|
||||
@ -51,7 +51,7 @@ class FirePHPHandler extends BaseFirePHPHandler
|
||||
foreach ($this->headers as $header => $content) {
|
||||
$this->response->headers->set($header, $content);
|
||||
}
|
||||
$this->headers = array();
|
||||
$this->headers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ class ServerLogHandler extends AbstractHandler
|
||||
private $context;
|
||||
private $socket;
|
||||
|
||||
public function __construct($host, $level = Logger::DEBUG, $bubble = true, $context = array())
|
||||
public function __construct($host, $level = Logger::DEBUG, $bubble = true, $context = [])
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
|
||||
@ -108,7 +108,7 @@ class ServerLogHandler extends AbstractHandler
|
||||
|
||||
$recordFormatted = $this->getFormatter()->format($record);
|
||||
|
||||
foreach (array('log_uuid', 'uuid', 'uid') as $key) {
|
||||
foreach (['log_uuid', 'uuid', 'uid'] as $key) {
|
||||
if (isset($record['extra'][$key])) {
|
||||
$recordFormatted['log_id'] = $record['extra'][$key];
|
||||
break;
|
||||
|
@ -30,7 +30,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface
|
||||
return $logger->getLogs();
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,19 +16,19 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
|
||||
class DebugProcessor implements DebugLoggerInterface
|
||||
{
|
||||
private $records = array();
|
||||
private $records = [];
|
||||
private $errorCount = 0;
|
||||
|
||||
public function __invoke(array $record)
|
||||
{
|
||||
$this->records[] = array(
|
||||
$this->records[] = [
|
||||
'timestamp' => $record['datetime']->getTimestamp(),
|
||||
'message' => $record['message'],
|
||||
'priority' => $record['level'],
|
||||
'priorityName' => $record['level_name'],
|
||||
'context' => $record['context'],
|
||||
'channel' => isset($record['channel']) ? $record['channel'] : '',
|
||||
);
|
||||
];
|
||||
switch ($record['level']) {
|
||||
case Logger::ERROR:
|
||||
case Logger::CRITICAL:
|
||||
@ -61,7 +61,7 @@ class DebugProcessor implements DebugLoggerInterface
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->records = array();
|
||||
$this->records = [];
|
||||
$this->errorCount = 0;
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ class TokenProcessor
|
||||
{
|
||||
$records['extra']['token'] = null;
|
||||
if (null !== $token = $this->tokenStorage->getToken()) {
|
||||
$records['extra']['token'] = array(
|
||||
$records['extra']['token'] = [
|
||||
'username' => $token->getUsername(),
|
||||
'authenticated' => $token->isAuthenticated(),
|
||||
'roles' => array_map(function ($role) { return $role->getRole(); }, $token->getRoles()),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $records;
|
||||
|
@ -24,7 +24,7 @@ class WebProcessor extends BaseWebProcessor
|
||||
public function __construct(array $extraFields = null)
|
||||
{
|
||||
// Pass an empty array as the default null value would access $_SERVER
|
||||
parent::__construct(array(), $extraFields);
|
||||
parent::__construct([], $extraFields);
|
||||
}
|
||||
|
||||
public function onKernelRequest(GetResponseEvent $event)
|
||||
|
@ -38,13 +38,13 @@ class ConsoleHandlerTest extends TestCase
|
||||
public function testIsHandling()
|
||||
{
|
||||
$handler = new ConsoleHandler();
|
||||
$this->assertFalse($handler->isHandling(array()), '->isHandling returns false when no output is set');
|
||||
$this->assertFalse($handler->isHandling([]), '->isHandling returns false when no output is set');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideVerbosityMappingTests
|
||||
*/
|
||||
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = array())
|
||||
public function testVerbosityMapping($verbosity, $level, $isHandling, array $map = [])
|
||||
{
|
||||
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
|
||||
$output
|
||||
@ -53,7 +53,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
->will($this->returnValue($verbosity))
|
||||
;
|
||||
$handler = new ConsoleHandler($output, true, $map);
|
||||
$this->assertSame($isHandling, $handler->isHandling(array('level' => $level)),
|
||||
$this->assertSame($isHandling, $handler->isHandling(['level' => $level]),
|
||||
'->isHandling returns correct value depending on console verbosity and log level'
|
||||
);
|
||||
|
||||
@ -61,7 +61,7 @@ class ConsoleHandlerTest extends TestCase
|
||||
$levelName = Logger::getLevelName($level);
|
||||
$levelName = sprintf('%-9s', $levelName);
|
||||
|
||||
$realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock();
|
||||
$realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(['doWrite'])->getMock();
|
||||
$realOutput->setVerbosity($verbosity);
|
||||
if ($realOutput->isDebug()) {
|
||||
$log = "16:21:54 $levelName [app] My info message\n";
|
||||
@ -74,38 +74,38 @@ class ConsoleHandlerTest extends TestCase
|
||||
->with($log, false);
|
||||
$handler = new ConsoleHandler($realOutput, true, $map);
|
||||
|
||||
$infoRecord = array(
|
||||
$infoRecord = [
|
||||
'message' => 'My info message',
|
||||
'context' => array(),
|
||||
'context' => [],
|
||||
'level' => $level,
|
||||
'level_name' => Logger::getLevelName($level),
|
||||
'channel' => 'app',
|
||||
'datetime' => new \DateTime('2013-05-29 16:21:54'),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
$this->assertFalse($handler->handle($infoRecord), 'The handler finished handling the log.');
|
||||
}
|
||||
|
||||
public function provideVerbosityMappingTests()
|
||||
{
|
||||
return array(
|
||||
array(OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true),
|
||||
array(OutputInterface::VERBOSITY_QUIET, Logger::WARNING, false),
|
||||
array(OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true),
|
||||
array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false),
|
||||
array(OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true),
|
||||
array(OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false),
|
||||
array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true),
|
||||
array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false),
|
||||
array(OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true),
|
||||
array(OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true),
|
||||
array(OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, array(
|
||||
return [
|
||||
[OutputInterface::VERBOSITY_QUIET, Logger::ERROR, true],
|
||||
[OutputInterface::VERBOSITY_QUIET, Logger::WARNING, false],
|
||||
[OutputInterface::VERBOSITY_NORMAL, Logger::WARNING, true],
|
||||
[OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, false],
|
||||
[OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE, true],
|
||||
[OutputInterface::VERBOSITY_VERBOSE, Logger::INFO, false],
|
||||
[OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO, true],
|
||||
[OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::DEBUG, false],
|
||||
[OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG, true],
|
||||
[OutputInterface::VERBOSITY_DEBUG, Logger::EMERGENCY, true],
|
||||
[OutputInterface::VERBOSITY_NORMAL, Logger::NOTICE, true, [
|
||||
OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE,
|
||||
)),
|
||||
array(OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, array(
|
||||
]],
|
||||
[OutputInterface::VERBOSITY_DEBUG, Logger::NOTICE, true, [
|
||||
OutputInterface::VERBOSITY_NORMAL => Logger::NOTICE,
|
||||
)),
|
||||
);
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
public function testVerbosityChanged()
|
||||
@ -122,10 +122,10 @@ class ConsoleHandlerTest extends TestCase
|
||||
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
|
||||
;
|
||||
$handler = new ConsoleHandler($output);
|
||||
$this->assertFalse($handler->isHandling(array('level' => Logger::NOTICE)),
|
||||
$this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]),
|
||||
'when verbosity is set to quiet, the handler does not handle the log'
|
||||
);
|
||||
$this->assertTrue($handler->isHandling(array('level' => Logger::NOTICE)),
|
||||
$this->assertTrue($handler->isHandling(['level' => Logger::NOTICE]),
|
||||
'since the verbosity of the output increased externally, the handler is now handling the log'
|
||||
);
|
||||
}
|
||||
@ -155,15 +155,15 @@ class ConsoleHandlerTest extends TestCase
|
||||
$handler = new ConsoleHandler(null, false);
|
||||
$handler->setOutput($output);
|
||||
|
||||
$infoRecord = array(
|
||||
$infoRecord = [
|
||||
'message' => 'My info message',
|
||||
'context' => array(),
|
||||
'context' => [],
|
||||
'level' => Logger::INFO,
|
||||
'level_name' => Logger::getLevelName(Logger::INFO),
|
||||
'channel' => 'app',
|
||||
'datetime' => new \DateTime('2013-05-29 16:21:54'),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
|
||||
$this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.');
|
||||
}
|
||||
|
@ -28,28 +28,28 @@ class NotFoundActivationStrategyTest extends TestCase
|
||||
$requestStack = new RequestStack();
|
||||
$requestStack->push(Request::create($url));
|
||||
|
||||
$strategy = new NotFoundActivationStrategy($requestStack, array('^/foo', 'bar'), Logger::WARNING);
|
||||
$strategy = new NotFoundActivationStrategy($requestStack, ['^/foo', 'bar'], Logger::WARNING);
|
||||
|
||||
$this->assertEquals($expected, $strategy->isHandlerActivated($record));
|
||||
}
|
||||
|
||||
public function isActivatedProvider()
|
||||
{
|
||||
return array(
|
||||
array('/test', array('level' => Logger::DEBUG), false),
|
||||
array('/foo', array('level' => Logger::DEBUG, 'context' => $this->getContextException(404)), false),
|
||||
array('/baz/bar', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false),
|
||||
array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), false),
|
||||
array('/foo', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true),
|
||||
return [
|
||||
['/test', ['level' => Logger::DEBUG], false],
|
||||
['/foo', ['level' => Logger::DEBUG, 'context' => $this->getContextException(404)], false],
|
||||
['/baz/bar', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
|
||||
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], false],
|
||||
['/foo', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
|
||||
|
||||
array('/test', array('level' => Logger::ERROR), true),
|
||||
array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(404)), true),
|
||||
array('/baz', array('level' => Logger::ERROR, 'context' => $this->getContextException(500)), true),
|
||||
);
|
||||
['/test', ['level' => Logger::ERROR], true],
|
||||
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(404)], true],
|
||||
['/baz', ['level' => Logger::ERROR, 'context' => $this->getContextException(500)], true],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getContextException($code)
|
||||
{
|
||||
return array('exception' => new HttpException($code));
|
||||
return ['exception' => new HttpException($code)];
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class LoggerTest extends TestCase
|
||||
public function testGetLogsWithDebugHandler()
|
||||
{
|
||||
$handler = new DebugHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$this->assertTrue($logger->error('error message'));
|
||||
$this->assertCount(1, $logger->getLogs());
|
||||
@ -34,10 +34,10 @@ class LoggerTest extends TestCase
|
||||
public function testGetLogsWithoutDebugProcessor()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$this->assertTrue($logger->error('error message'));
|
||||
$this->assertSame(array(), $logger->getLogs());
|
||||
$this->assertSame([], $logger->getLogs());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ class LoggerTest extends TestCase
|
||||
public function testCountErrorsWithDebugHandler()
|
||||
{
|
||||
$handler = new DebugHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$this->assertTrue($logger->debug('test message'));
|
||||
$this->assertTrue($logger->info('test message'));
|
||||
@ -80,7 +80,7 @@ class LoggerTest extends TestCase
|
||||
public function testCountErrorsWithoutDebugProcessor()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger(__METHOD__, array($handler));
|
||||
$logger = new Logger(__METHOD__, [$handler]);
|
||||
|
||||
$this->assertTrue($logger->error('error message'));
|
||||
$this->assertSame(0, $logger->countErrors());
|
||||
@ -90,7 +90,7 @@ class LoggerTest extends TestCase
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$processor = new DebugProcessor();
|
||||
$logger = new Logger(__METHOD__, array($handler), array($processor));
|
||||
$logger = new Logger(__METHOD__, [$handler], [$processor]);
|
||||
|
||||
$this->assertTrue($logger->error('error message'));
|
||||
$this->assertCount(1, $logger->getLogs());
|
||||
@ -100,7 +100,7 @@ class LoggerTest extends TestCase
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$processor = new DebugProcessor();
|
||||
$logger = new Logger(__METHOD__, array($handler), array($processor));
|
||||
$logger = new Logger(__METHOD__, [$handler], [$processor]);
|
||||
|
||||
$this->assertTrue($logger->debug('test message'));
|
||||
$this->assertTrue($logger->info('test message'));
|
||||
@ -118,7 +118,7 @@ class LoggerTest extends TestCase
|
||||
public function testGetLogsWithDebugProcessor2()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger('test', array($handler));
|
||||
$logger = new Logger('test', [$handler]);
|
||||
$logger->pushProcessor(new DebugProcessor());
|
||||
|
||||
$logger->addInfo('test');
|
||||
@ -132,7 +132,7 @@ class LoggerTest extends TestCase
|
||||
public function testClear()
|
||||
{
|
||||
$handler = new TestHandler();
|
||||
$logger = new Logger('test', array($handler));
|
||||
$logger = new Logger('test', [$handler]);
|
||||
$logger->pushProcessor(new DebugProcessor());
|
||||
|
||||
$logger->addInfo('test');
|
||||
|
@ -25,12 +25,12 @@ class TokenProcessorTest extends TestCase
|
||||
{
|
||||
public function testProcessor()
|
||||
{
|
||||
$token = new UsernamePasswordToken('user', 'password', 'provider', array('ROLE_USER'));
|
||||
$token = new UsernamePasswordToken('user', 'password', 'provider', ['ROLE_USER']);
|
||||
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
|
||||
$tokenStorage->method('getToken')->willReturn($token);
|
||||
|
||||
$processor = new TokenProcessor($tokenStorage);
|
||||
$record = array('extra' => array());
|
||||
$record = ['extra' => []];
|
||||
$record = $processor($record);
|
||||
|
||||
$this->assertArrayHasKey('token', $record['extra']);
|
||||
|
@ -36,8 +36,8 @@ class WebProcessorTest extends TestCase
|
||||
|
||||
public function testUseRequestClientIp()
|
||||
{
|
||||
Request::setTrustedProxies(array('192.168.0.1'), Request::HEADER_X_FORWARDED_ALL);
|
||||
list($event, $server) = $this->createRequestEvent(array('X_FORWARDED_FOR' => '192.168.0.2'));
|
||||
Request::setTrustedProxies(['192.168.0.1'], Request::HEADER_X_FORWARDED_ALL);
|
||||
list($event, $server) = $this->createRequestEvent(['X_FORWARDED_FOR' => '192.168.0.2']);
|
||||
|
||||
$processor = new WebProcessor();
|
||||
$processor->onKernelRequest($event);
|
||||
@ -50,7 +50,7 @@ class WebProcessorTest extends TestCase
|
||||
$this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
|
||||
$this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
|
||||
|
||||
Request::setTrustedProxies(array(), -1);
|
||||
Request::setTrustedProxies([], -1);
|
||||
}
|
||||
|
||||
public function testCanBeConstructedWithExtraFields()
|
||||
@ -61,7 +61,7 @@ class WebProcessorTest extends TestCase
|
||||
|
||||
list($event, $server) = $this->createRequestEvent();
|
||||
|
||||
$processor = new WebProcessor(array('url', 'referrer'));
|
||||
$processor = new WebProcessor(['url', 'referrer']);
|
||||
$processor->onKernelRequest($event);
|
||||
$record = $processor($this->getRecord());
|
||||
|
||||
@ -73,16 +73,16 @@ class WebProcessorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function createRequestEvent($additionalServerParameters = array())
|
||||
private function createRequestEvent($additionalServerParameters = [])
|
||||
{
|
||||
$server = array_merge(
|
||||
array(
|
||||
[
|
||||
'REQUEST_URI' => 'A',
|
||||
'REMOTE_ADDR' => '192.168.0.1',
|
||||
'REQUEST_METHOD' => 'C',
|
||||
'SERVER_NAME' => 'D',
|
||||
'HTTP_REFERER' => 'E',
|
||||
),
|
||||
],
|
||||
$additionalServerParameters
|
||||
);
|
||||
|
||||
@ -100,7 +100,7 @@ class WebProcessorTest extends TestCase
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request));
|
||||
|
||||
return array($event, $server);
|
||||
return [$event, $server];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,15 +111,15 @@ class WebProcessorTest extends TestCase
|
||||
*/
|
||||
private function getRecord($level = Logger::WARNING, $message = 'test')
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'message' => $message,
|
||||
'context' => array(),
|
||||
'context' => [],
|
||||
'level' => $level,
|
||||
'level_name' => Logger::getLevelName($level),
|
||||
'channel' => 'test',
|
||||
'datetime' => new \DateTime(),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
}
|
||||
|
||||
private function isExtraFieldsSupported()
|
||||
|
@ -73,7 +73,7 @@ class ClockMock
|
||||
{
|
||||
$self = \get_called_class();
|
||||
|
||||
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
|
||||
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
|
||||
if (0 < strpos($class, '\\Tests\\')) {
|
||||
$ns = str_replace('\\Tests\\', '\\', $class);
|
||||
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
||||
|
@ -54,9 +54,9 @@ class DeprecationErrorHandler
|
||||
if (false === $mode) {
|
||||
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
|
||||
}
|
||||
if (DeprecationErrorHandler::MODE_DISABLED !== $mode
|
||||
&& DeprecationErrorHandler::MODE_WEAK !== $mode
|
||||
&& DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode
|
||||
if (self::MODE_DISABLED !== $mode
|
||||
&& self::MODE_WEAK !== $mode
|
||||
&& self::MODE_WEAK_VENDORS !== $mode
|
||||
&& (!isset($mode[0]) || '/' !== $mode[0])
|
||||
) {
|
||||
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
|
||||
@ -92,21 +92,21 @@ class DeprecationErrorHandler
|
||||
return false;
|
||||
};
|
||||
|
||||
$deprecations = array(
|
||||
$deprecations = [
|
||||
'unsilencedCount' => 0,
|
||||
'remainingCount' => 0,
|
||||
'legacyCount' => 0,
|
||||
'otherCount' => 0,
|
||||
'remaining vendorCount' => 0,
|
||||
'unsilenced' => array(),
|
||||
'remaining' => array(),
|
||||
'legacy' => array(),
|
||||
'other' => array(),
|
||||
'remaining vendor' => array(),
|
||||
);
|
||||
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
|
||||
'unsilenced' => [],
|
||||
'remaining' => [],
|
||||
'legacy' => [],
|
||||
'other' => [],
|
||||
'remaining vendor' => [],
|
||||
];
|
||||
$deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
|
||||
$mode = $getMode();
|
||||
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) {
|
||||
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
|
||||
$ErrorHandler = $UtilPrefix.'ErrorHandler';
|
||||
|
||||
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
||||
@ -114,7 +114,7 @@ class DeprecationErrorHandler
|
||||
|
||||
$trace = debug_backtrace();
|
||||
$group = 'other';
|
||||
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
|
||||
$isVendor = self::MODE_WEAK_VENDORS === $mode && $inVendors($file);
|
||||
|
||||
$i = \count($trace);
|
||||
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
|
||||
@ -131,7 +131,7 @@ class DeprecationErrorHandler
|
||||
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
|
||||
// then we need to use the serialized information to determine
|
||||
// if the error has been triggered from vendor code.
|
||||
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
|
||||
$isVendor = self::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
|
||||
} else {
|
||||
$class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class'];
|
||||
$method = $trace[$i]['function'];
|
||||
@ -168,13 +168,13 @@ class DeprecationErrorHandler
|
||||
|
||||
exit(1);
|
||||
}
|
||||
if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
|
||||
if ('legacy' !== $group && self::MODE_WEAK !== $mode) {
|
||||
$ref = &$deprecations[$group][$msg]['count'];
|
||||
++$ref;
|
||||
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
|
||||
++$ref;
|
||||
}
|
||||
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
|
||||
} elseif (self::MODE_WEAK !== $mode) {
|
||||
$ref = &$deprecations[$group][$msg]['count'];
|
||||
++$ref;
|
||||
}
|
||||
@ -184,7 +184,7 @@ class DeprecationErrorHandler
|
||||
|
||||
if (null !== $oldErrorHandler) {
|
||||
restore_error_handler();
|
||||
if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) {
|
||||
if ([$UtilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) {
|
||||
restore_error_handler();
|
||||
self::register($mode);
|
||||
}
|
||||
@ -207,7 +207,7 @@ class DeprecationErrorHandler
|
||||
$currErrorHandler = set_error_handler('var_dump');
|
||||
restore_error_handler();
|
||||
|
||||
if (DeprecationErrorHandler::MODE_WEAK === $mode) {
|
||||
if (self::MODE_WEAK === $mode) {
|
||||
$colorize = function ($str) { return $str; };
|
||||
}
|
||||
if ($currErrorHandler !== $deprecationHandler) {
|
||||
@ -218,8 +218,8 @@ class DeprecationErrorHandler
|
||||
return $b['count'] - $a['count'];
|
||||
};
|
||||
|
||||
$groups = array('unsilenced', 'remaining');
|
||||
if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
|
||||
$groups = ['unsilenced', 'remaining'];
|
||||
if (self::MODE_WEAK_VENDORS === $mode) {
|
||||
$groups[] = 'remaining vendor';
|
||||
}
|
||||
array_push($groups, 'legacy', 'other');
|
||||
@ -255,11 +255,11 @@ class DeprecationErrorHandler
|
||||
$displayDeprecations($deprecations);
|
||||
|
||||
// store failing status
|
||||
$isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
|
||||
$isFailing = self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
|
||||
|
||||
// reset deprecations array
|
||||
foreach ($deprecations as $group => $arrayOrInt) {
|
||||
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
|
||||
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : [];
|
||||
}
|
||||
|
||||
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
|
||||
@ -270,7 +270,7 @@ class DeprecationErrorHandler
|
||||
}
|
||||
}
|
||||
$displayDeprecations($deprecations);
|
||||
if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
|
||||
if ($isFailing || self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
@ -280,8 +280,8 @@ class DeprecationErrorHandler
|
||||
|
||||
public static function collectDeprecations($outputFile)
|
||||
{
|
||||
$deprecations = array();
|
||||
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) {
|
||||
$deprecations = [];
|
||||
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
if ($previousErrorHandler) {
|
||||
return $previousErrorHandler($type, $msg, $file, $line, $context);
|
||||
@ -293,7 +293,7 @@ class DeprecationErrorHandler
|
||||
|
||||
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
||||
}
|
||||
$deprecations[] = array(error_reporting(), $msg, $file);
|
||||
$deprecations[] = [error_reporting(), $msg, $file];
|
||||
});
|
||||
|
||||
register_shutdown_function(function () use ($outputFile, &$deprecations) {
|
||||
|
@ -16,8 +16,8 @@ namespace Symfony\Bridge\PhpUnit;
|
||||
*/
|
||||
class DnsMock
|
||||
{
|
||||
private static $hosts = array();
|
||||
private static $dnsTypes = array(
|
||||
private static $hosts = [];
|
||||
private static $dnsTypes = [
|
||||
'A' => DNS_A,
|
||||
'MX' => DNS_MX,
|
||||
'NS' => DNS_NS,
|
||||
@ -30,7 +30,7 @@ class DnsMock
|
||||
'NAPTR' => DNS_NAPTR,
|
||||
'TXT' => DNS_TXT,
|
||||
'HINFO' => DNS_HINFO,
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Configures the mock values for DNS queries.
|
||||
@ -68,7 +68,7 @@ class DnsMock
|
||||
if (!self::$hosts) {
|
||||
return \getmxrr($hostname, $mxhosts, $weight);
|
||||
}
|
||||
$mxhosts = $weight = array();
|
||||
$mxhosts = $weight = [];
|
||||
|
||||
if (isset(self::$hosts[$hostname])) {
|
||||
foreach (self::$hosts[$hostname] as $record) {
|
||||
@ -125,7 +125,7 @@ class DnsMock
|
||||
$ips = false;
|
||||
|
||||
if (isset(self::$hosts[$hostname])) {
|
||||
$ips = array();
|
||||
$ips = [];
|
||||
|
||||
foreach (self::$hosts[$hostname] as $record) {
|
||||
if ('A' === $record['type']) {
|
||||
@ -149,11 +149,11 @@ class DnsMock
|
||||
if (DNS_ANY === $type) {
|
||||
$type = DNS_ALL;
|
||||
}
|
||||
$records = array();
|
||||
$records = [];
|
||||
|
||||
foreach (self::$hosts[$hostname] as $record) {
|
||||
if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) {
|
||||
$records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record);
|
||||
$records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ class DnsMock
|
||||
{
|
||||
$self = \get_called_class();
|
||||
|
||||
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
|
||||
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
|
||||
if (0 < strpos($class, '\\Tests\\')) {
|
||||
$ns = str_replace('\\Tests\\', '\\', $class);
|
||||
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
|
||||
|
@ -31,7 +31,7 @@ class CoverageListenerTrait
|
||||
{
|
||||
$this->sutFqcnResolver = $sutFqcnResolver;
|
||||
$this->warningOnSutNotFound = $warningOnSutNotFound;
|
||||
$this->warnings = array();
|
||||
$this->warnings = [];
|
||||
}
|
||||
|
||||
public function startTest($test)
|
||||
@ -42,7 +42,7 @@ class CoverageListenerTrait
|
||||
|
||||
$annotations = $test->getAnnotations();
|
||||
|
||||
$ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing');
|
||||
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];
|
||||
|
||||
foreach ($ignoredAnnotations as $annotation) {
|
||||
if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
|
||||
@ -74,11 +74,11 @@ class CoverageListenerTrait
|
||||
$r->setAccessible(true);
|
||||
|
||||
$cache = $r->getValue();
|
||||
$cache = array_replace_recursive($cache, array(
|
||||
\get_class($test) => array(
|
||||
'covers' => array($sutFqcn),
|
||||
),
|
||||
));
|
||||
$cache = array_replace_recursive($cache, [
|
||||
\get_class($test) => [
|
||||
'covers' => [$sutFqcn],
|
||||
],
|
||||
]);
|
||||
$r->setValue($testClass, $cache);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
|
||||
{
|
||||
private $trait;
|
||||
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
public function __construct(array $mockedNamespaces = [])
|
||||
{
|
||||
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener
|
||||
{
|
||||
private $trait;
|
||||
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
public function __construct(array $mockedNamespaces = [])
|
||||
{
|
||||
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class SymfonyTestsListenerForV7 implements TestListener
|
||||
|
||||
private $trait;
|
||||
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
public function __construct(array $mockedNamespaces = [])
|
||||
{
|
||||
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ class SymfonyTestsListenerTrait
|
||||
private static $globallyEnabled = false;
|
||||
private $state = -1;
|
||||
private $skippedFile = false;
|
||||
private $wasSkipped = array();
|
||||
private $isSkipped = array();
|
||||
private $expectedDeprecations = array();
|
||||
private $gatheredDeprecations = array();
|
||||
private $wasSkipped = [];
|
||||
private $isSkipped = [];
|
||||
private $expectedDeprecations = [];
|
||||
private $gatheredDeprecations = [];
|
||||
private $previousErrorHandler;
|
||||
private $testsWithWarnings;
|
||||
private $reportUselessTests;
|
||||
@ -44,7 +44,7 @@ class SymfonyTestsListenerTrait
|
||||
/**
|
||||
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
|
||||
*/
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
public function __construct(array $mockedNamespaces = [])
|
||||
{
|
||||
if (class_exists('PHPUnit_Util_Blacklist')) {
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
|
||||
@ -55,7 +55,7 @@ class SymfonyTestsListenerTrait
|
||||
$warn = false;
|
||||
foreach ($mockedNamespaces as $type => $namespaces) {
|
||||
if (!\is_array($namespaces)) {
|
||||
$namespaces = array($namespaces);
|
||||
$namespaces = [$namespaces];
|
||||
}
|
||||
if (\is_int($type)) {
|
||||
// @deprecated BC with v2.8 to v3.0
|
||||
@ -104,7 +104,7 @@ class SymfonyTestsListenerTrait
|
||||
$Test = 'PHPUnit\Util\Test';
|
||||
}
|
||||
$suiteName = $suite->getName();
|
||||
$this->testsWithWarnings = array();
|
||||
$this->testsWithWarnings = [];
|
||||
|
||||
foreach ($suite->tests() as $test) {
|
||||
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
|
||||
@ -135,11 +135,11 @@ class SymfonyTestsListenerTrait
|
||||
|
||||
if (!$this->wasSkipped = require $this->skippedFile) {
|
||||
echo "All tests already ran successfully.\n";
|
||||
$suite->setTests(array());
|
||||
$suite->setTests([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$testSuites = array($suite);
|
||||
$testSuites = [$suite];
|
||||
for ($i = 0; isset($testSuites[$i]); ++$i) {
|
||||
foreach ($testSuites[$i]->tests() as $test) {
|
||||
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
|
||||
@ -158,7 +158,7 @@ class SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
} elseif (2 === $this->state) {
|
||||
$skipped = array();
|
||||
$skipped = [];
|
||||
foreach ($suite->tests() as $test) {
|
||||
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
|
||||
|| isset($this->wasSkipped[$suiteName]['*'])
|
||||
@ -230,7 +230,7 @@ class SymfonyTestsListenerTrait
|
||||
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
|
||||
|
||||
$this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
|
||||
$this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
|
||||
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,8 +271,8 @@ class SymfonyTestsListenerTrait
|
||||
$deprecations = file_get_contents($this->runsInSeparateProcess);
|
||||
unlink($this->runsInSeparateProcess);
|
||||
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
|
||||
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
|
||||
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
|
||||
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
|
||||
$error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]);
|
||||
if ($deprecation[0]) {
|
||||
@trigger_error($error, E_USER_DEPRECATED);
|
||||
} else {
|
||||
@ -283,13 +283,13 @@ class SymfonyTestsListenerTrait
|
||||
}
|
||||
|
||||
if ($this->expectedDeprecations) {
|
||||
if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) {
|
||||
if (!\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE], true)) {
|
||||
$test->addToAssertionCount(\count($this->expectedDeprecations));
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) {
|
||||
if (!$errored && !\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR], true)) {
|
||||
try {
|
||||
$prefix = "@expectedDeprecation:\n";
|
||||
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
|
||||
@ -300,7 +300,7 @@ class SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
$this->expectedDeprecations = $this->gatheredDeprecations = array();
|
||||
$this->expectedDeprecations = $this->gatheredDeprecations = [];
|
||||
$this->previousErrorHandler = null;
|
||||
}
|
||||
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
|
||||
@ -308,7 +308,7 @@ class SymfonyTestsListenerTrait
|
||||
ClockMock::withClockMock(false);
|
||||
}
|
||||
if (\in_array('dns-sensitive', $groups, true)) {
|
||||
DnsMock::withMockedHosts(array());
|
||||
DnsMock::withMockedHosts([]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ class SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
public function handleError($type, $msg, $file, $line, $context = array())
|
||||
public function handleError($type, $msg, $file, $line, $context = [])
|
||||
{
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
$h = $this->previousErrorHandler;
|
||||
|
@ -27,7 +27,7 @@ class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
|
||||
|
||||
$result = parent::handleConfiguration($arguments);
|
||||
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
|
||||
|
||||
$registeredLocally = false;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class TestRunnerForV6 extends BaseRunner
|
||||
|
||||
parent::handleConfiguration($arguments);
|
||||
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
|
||||
|
||||
$registeredLocally = false;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class TestRunnerForV7 extends BaseRunner
|
||||
|
||||
parent::handleConfiguration($arguments);
|
||||
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
|
||||
|
||||
$registeredLocally = false;
|
||||
|
||||
|
@ -18,15 +18,15 @@ class DnsMockTest extends TestCase
|
||||
{
|
||||
protected function tearDown()
|
||||
{
|
||||
DnsMock::withMockedHosts(array());
|
||||
DnsMock::withMockedHosts([]);
|
||||
}
|
||||
|
||||
public function testCheckdnsrr()
|
||||
{
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'MX'))));
|
||||
DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]);
|
||||
$this->assertTrue(DnsMock::checkdnsrr('example.com'));
|
||||
|
||||
DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A'))));
|
||||
DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]);
|
||||
$this->assertFalse(DnsMock::checkdnsrr('example.com'));
|
||||
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'a'));
|
||||
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'any'));
|
||||
@ -35,34 +35,34 @@ class DnsMockTest extends TestCase
|
||||
|
||||
public function testGetmxrr()
|
||||
{
|
||||
DnsMock::withMockedHosts(array(
|
||||
'example.com' => array(array(
|
||||
DnsMock::withMockedHosts([
|
||||
'example.com' => [[
|
||||
'type' => 'MX',
|
||||
'host' => 'mx.example.com',
|
||||
'pri' => 10,
|
||||
)),
|
||||
));
|
||||
]],
|
||||
]);
|
||||
|
||||
$this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight));
|
||||
$this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight));
|
||||
$this->assertSame(array('mx.example.com'), $mxhosts);
|
||||
$this->assertSame(array(10), $weight);
|
||||
$this->assertSame(['mx.example.com'], $mxhosts);
|
||||
$this->assertSame([10], $weight);
|
||||
}
|
||||
|
||||
public function testGethostbyaddr()
|
||||
{
|
||||
DnsMock::withMockedHosts(array(
|
||||
'example.com' => array(
|
||||
array(
|
||||
DnsMock::withMockedHosts([
|
||||
'example.com' => [
|
||||
[
|
||||
'type' => 'A',
|
||||
'ip' => '1.2.3.4',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'type' => 'AAAA',
|
||||
'ipv6' => '::12',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame('::21', DnsMock::gethostbyaddr('::21'));
|
||||
$this->assertSame('example.com', DnsMock::gethostbyaddr('::12'));
|
||||
@ -71,18 +71,18 @@ class DnsMockTest extends TestCase
|
||||
|
||||
public function testGethostbyname()
|
||||
{
|
||||
DnsMock::withMockedHosts(array(
|
||||
'example.com' => array(
|
||||
array(
|
||||
DnsMock::withMockedHosts([
|
||||
'example.com' => [
|
||||
[
|
||||
'type' => 'AAAA',
|
||||
'ipv6' => '::12',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'type' => 'A',
|
||||
'ip' => '1.2.3.4',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com'));
|
||||
$this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com'));
|
||||
@ -90,59 +90,59 @@ class DnsMockTest extends TestCase
|
||||
|
||||
public function testGethostbynamel()
|
||||
{
|
||||
DnsMock::withMockedHosts(array(
|
||||
'example.com' => array(
|
||||
array(
|
||||
DnsMock::withMockedHosts([
|
||||
'example.com' => [
|
||||
[
|
||||
'type' => 'A',
|
||||
'ip' => '1.2.3.4',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'type' => 'A',
|
||||
'ip' => '2.3.4.5',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertFalse(DnsMock::gethostbynamel('foobar.com'));
|
||||
$this->assertSame(array('1.2.3.4', '2.3.4.5'), DnsMock::gethostbynamel('example.com'));
|
||||
$this->assertSame(['1.2.3.4', '2.3.4.5'], DnsMock::gethostbynamel('example.com'));
|
||||
}
|
||||
|
||||
public function testDnsGetRecord()
|
||||
{
|
||||
DnsMock::withMockedHosts(array(
|
||||
'example.com' => array(
|
||||
array(
|
||||
DnsMock::withMockedHosts([
|
||||
'example.com' => [
|
||||
[
|
||||
'type' => 'A',
|
||||
'ip' => '1.2.3.4',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'type' => 'PTR',
|
||||
'ip' => '2.3.4.5',
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$records = array(
|
||||
array(
|
||||
$records = [
|
||||
[
|
||||
'host' => 'example.com',
|
||||
'class' => 'IN',
|
||||
'ttl' => 1,
|
||||
'type' => 'A',
|
||||
'ip' => '1.2.3.4',
|
||||
),
|
||||
$ptr = array(
|
||||
],
|
||||
$ptr = [
|
||||
'host' => 'example.com',
|
||||
'class' => 'IN',
|
||||
'ttl' => 1,
|
||||
'type' => 'PTR',
|
||||
'ip' => '2.3.4.5',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertFalse(DnsMock::dns_get_record('foobar.com'));
|
||||
$this->assertSame($records, DnsMock::dns_get_record('example.com'));
|
||||
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL));
|
||||
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR));
|
||||
$this->assertSame(array($ptr), DnsMock::dns_get_record('example.com', DNS_PTR));
|
||||
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR));
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,6 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dumper->setProxyDumper(new ProxyDumper());
|
||||
|
||||
return $dumper->dump(array('class' => 'LazyServiceProjectServiceContainer'));
|
||||
return $dumper->dump(['class' => 'LazyServiceProjectServiceContainer']);
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ class ProxyManagerBridgeFooClass
|
||||
public $initialized = false;
|
||||
public $configured = false;
|
||||
public $called = false;
|
||||
public $arguments = array();
|
||||
public $arguments = [];
|
||||
|
||||
public function __construct($arguments = array())
|
||||
public function __construct($arguments = [])
|
||||
{
|
||||
$this->arguments = $arguments;
|
||||
}
|
||||
|
||||
public static function getInstance($arguments = array())
|
||||
public static function getInstance($arguments = [])
|
||||
{
|
||||
$obj = new self($arguments);
|
||||
$obj->called = true;
|
||||
|
@ -98,18 +98,18 @@ class ProxyDumperTest extends TestCase
|
||||
|
||||
public function getPrivatePublicDefinitions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(false),
|
||||
\method_exists(ContainerBuilder::class, 'addClassResource') ? 'services' : 'privates',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
(new Definition(__CLASS__))
|
||||
->setPublic(true),
|
||||
'services',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,12 +134,12 @@ class ProxyDumperTest extends TestCase
|
||||
*/
|
||||
public function getProxyCandidates()
|
||||
{
|
||||
$definitions = array(
|
||||
array(new Definition(__CLASS__), true),
|
||||
array(new Definition('stdClass'), true),
|
||||
array(new Definition(uniqid('foo', true)), false),
|
||||
array(new Definition(), false),
|
||||
);
|
||||
$definitions = [
|
||||
[new Definition(__CLASS__), true],
|
||||
[new Definition('stdClass'), true],
|
||||
[new Definition(uniqid('foo', true)), false],
|
||||
[new Definition(), false],
|
||||
];
|
||||
|
||||
array_map(
|
||||
function ($definition) {
|
||||
|
@ -159,13 +159,13 @@ class AppVariable
|
||||
try {
|
||||
$session = $this->getSession();
|
||||
if (null === $session) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (null === $types || '' === $types || array() === $types) {
|
||||
if (null === $types || '' === $types || [] === $types) {
|
||||
return $session->getFlashBag()->all();
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ class AppVariable
|
||||
return $session->getFlashBag()->get($types);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($types as $type) {
|
||||
$result[$type] = $session->getFlashBag()->get($type);
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ class DebugCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setDefinition(array(
|
||||
->setDefinition([
|
||||
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'),
|
||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
|
||||
))
|
||||
])
|
||||
->setDescription('Shows a list of twig functions, filters, globals and tests')
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command outputs a list of twig functions,
|
||||
@ -114,10 +114,10 @@ EOF
|
||||
throw new \RuntimeException('The Twig environment needs to be set.');
|
||||
}
|
||||
|
||||
$types = array('functions', 'filters', 'tests', 'globals');
|
||||
$types = ['functions', 'filters', 'tests', 'globals'];
|
||||
|
||||
if ('json' === $input->getOption('format')) {
|
||||
$data = array();
|
||||
$data = [];
|
||||
foreach ($types as $type) {
|
||||
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
|
||||
$data[$type][$name] = $this->getMetadata($type, $entity);
|
||||
@ -133,7 +133,7 @@ EOF
|
||||
$filter = $input->getArgument('filter');
|
||||
|
||||
foreach ($types as $index => $type) {
|
||||
$items = array();
|
||||
$items = [];
|
||||
foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) {
|
||||
if (!$filter || false !== strpos($name, $filter)) {
|
||||
$items[$name] = $name.$this->getPrettyMetadata($type, $entity);
|
||||
@ -150,20 +150,20 @@ EOF
|
||||
$io->listing($items);
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
$firstNamespace = true;
|
||||
$prevHasSeparator = false;
|
||||
foreach ($this->getLoaderPaths() as $namespace => $paths) {
|
||||
if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) {
|
||||
$rows[] = array('', '');
|
||||
$rows[] = ['', ''];
|
||||
}
|
||||
$firstNamespace = false;
|
||||
foreach ($paths as $path) {
|
||||
$rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR);
|
||||
$rows[] = [$namespace, $path.\DIRECTORY_SEPARATOR];
|
||||
$namespace = '';
|
||||
}
|
||||
if (\count($paths) > 1) {
|
||||
$rows[] = array('', '');
|
||||
$rows[] = ['', ''];
|
||||
$prevHasSeparator = true;
|
||||
} else {
|
||||
$prevHasSeparator = false;
|
||||
@ -173,7 +173,7 @@ EOF
|
||||
array_pop($rows);
|
||||
}
|
||||
$io->section('Loader Paths');
|
||||
$io->table(array('Namespace', 'Paths'), $rows);
|
||||
$io->table(['Namespace', 'Paths'], $rows);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -181,10 +181,10 @@ EOF
|
||||
private function getLoaderPaths()
|
||||
{
|
||||
if (!($loader = $this->twig->getLoader()) instanceof FilesystemLoader) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$loaderPaths = array();
|
||||
$loaderPaths = [];
|
||||
foreach ($loader->getNamespaces() as $namespace) {
|
||||
$paths = array_map(function ($path) {
|
||||
if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) {
|
||||
|
@ -129,7 +129,7 @@ EOF
|
||||
$template .= fread(STDIN, 1024);
|
||||
}
|
||||
|
||||
return $this->display($input, $output, $io, array($this->validate($template, uniqid('sf_', true))));
|
||||
return $this->display($input, $output, $io, [$this->validate($template, uniqid('sf_', true))]);
|
||||
}
|
||||
|
||||
$filesInfo = $this->getFilesInfo($filenames);
|
||||
@ -139,7 +139,7 @@ EOF
|
||||
|
||||
private function getFilesInfo(array $filenames)
|
||||
{
|
||||
$filesInfo = array();
|
||||
$filesInfo = [];
|
||||
foreach ($filenames as $filename) {
|
||||
foreach ($this->findFiles($filename) as $file) {
|
||||
$filesInfo[] = $this->validate(file_get_contents($file), $file);
|
||||
@ -152,7 +152,7 @@ EOF
|
||||
protected function findFiles($filename)
|
||||
{
|
||||
if (is_file($filename)) {
|
||||
return array($filename);
|
||||
return [$filename];
|
||||
} elseif (is_dir($filename)) {
|
||||
return Finder::create()->files()->in($filename)->name('*.twig');
|
||||
}
|
||||
@ -164,7 +164,7 @@ EOF
|
||||
{
|
||||
$realLoader = $this->twig->getLoader();
|
||||
try {
|
||||
$temporaryLoader = new ArrayLoader(array((string) $file => $template));
|
||||
$temporaryLoader = new ArrayLoader([(string) $file => $template]);
|
||||
$this->twig->setLoader($temporaryLoader);
|
||||
$nodeTree = $this->twig->parse($this->twig->tokenize(new Source($template, (string) $file)));
|
||||
$this->twig->compile($nodeTree);
|
||||
@ -172,10 +172,10 @@ EOF
|
||||
} catch (Error $e) {
|
||||
$this->twig->setLoader($realLoader);
|
||||
|
||||
return array('template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e);
|
||||
return ['template' => $template, 'file' => $file, 'line' => $e->getTemplateLine(), 'valid' => false, 'exception' => $e];
|
||||
}
|
||||
|
||||
return array('template' => $template, 'file' => $file, 'valid' => true);
|
||||
return ['template' => $template, 'file' => $file, 'valid' => true];
|
||||
}
|
||||
|
||||
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, $files)
|
||||
@ -261,7 +261,7 @@ EOF
|
||||
$position = max(0, $line - $context);
|
||||
$max = min(\count($lines), $line - 1 + $context);
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
while ($position < $max) {
|
||||
$result[$position + 1] = $lines[$position];
|
||||
++$position;
|
||||
|
@ -51,7 +51,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
{
|
||||
$this->profile->reset();
|
||||
$this->computed = null;
|
||||
$this->data = array();
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +60,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
public function lateCollect()
|
||||
{
|
||||
$this->data['profile'] = serialize($this->profile);
|
||||
$this->data['template_paths'] = array();
|
||||
$this->data['template_paths'] = [];
|
||||
|
||||
if (null === $this->twig) {
|
||||
return;
|
||||
@ -122,15 +122,15 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
$dump = $dumper->dump($this->getProfile());
|
||||
|
||||
// needed to remove the hardcoded CSS styles
|
||||
$dump = str_replace(array(
|
||||
$dump = str_replace([
|
||||
'<span style="background-color: #ffd">',
|
||||
'<span style="color: #d44">',
|
||||
'<span style="background-color: #dfd">',
|
||||
), array(
|
||||
], [
|
||||
'<span class="status-warning">',
|
||||
'<span class="status-error">',
|
||||
'<span class="status-success">',
|
||||
), $dump);
|
||||
], $dump);
|
||||
|
||||
return new Markup($dump, 'UTF-8');
|
||||
}
|
||||
@ -139,7 +139,7 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
{
|
||||
if (null === $this->profile) {
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
$this->profile = unserialize($this->data['profile'], array('allowed_classes' => array('Twig_Profiler_Profile', 'Twig\Profiler\Profile')));
|
||||
$this->profile = unserialize($this->data['profile'], ['allowed_classes' => ['Twig_Profiler_Profile', 'Twig\Profiler\Profile']]);
|
||||
} else {
|
||||
$this->profile = unserialize($this->data['profile']);
|
||||
}
|
||||
@ -159,13 +159,13 @@ class TwigDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
|
||||
private function computeData(Profile $profile)
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'template_count' => 0,
|
||||
'block_count' => 0,
|
||||
'macro_count' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
$templates = array();
|
||||
$templates = [];
|
||||
foreach ($profile as $p) {
|
||||
$d = $this->computeData($p);
|
||||
|
||||
|
@ -34,10 +34,10 @@ class AssetExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('asset', array($this, 'getAssetUrl')),
|
||||
new TwigFunction('asset_version', array($this, 'getAssetVersion')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('asset', [$this, 'getAssetUrl']),
|
||||
new TwigFunction('asset_version', [$this, 'getAssetVersion']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,17 +43,17 @@ class CodeExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('abbr_class', array($this, 'abbrClass'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('abbr_method', array($this, 'abbrMethod'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_args', array($this, 'formatArgs'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_args_as_text', array($this, 'formatArgsAsText')),
|
||||
new TwigFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('format_log_message', array($this, 'formatLogMessage'), array('is_safe' => array('html'))),
|
||||
new TwigFilter('file_link', array($this, 'getFileLink')),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('abbr_class', [$this, 'abbrClass'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('abbr_method', [$this, 'abbrMethod'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_args', [$this, 'formatArgs'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_args_as_text', [$this, 'formatArgsAsText']),
|
||||
new TwigFilter('file_excerpt', [$this, 'fileExcerpt'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_file', [$this, 'formatFile'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_file_from_text', [$this, 'formatFileFromText'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('format_log_message', [$this, 'formatLogMessage'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('file_link', [$this, 'getFileLink']),
|
||||
];
|
||||
}
|
||||
|
||||
public function abbrClass($class)
|
||||
@ -87,7 +87,7 @@ class CodeExtension extends AbstractExtension
|
||||
*/
|
||||
public function formatArgs($args)
|
||||
{
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($args as $key => $item) {
|
||||
if ('object' === $item[0]) {
|
||||
$parts = explode('\\', $item[1]);
|
||||
@ -146,7 +146,7 @@ class CodeExtension extends AbstractExtension
|
||||
}, $code);
|
||||
$content = explode('<br />', $code);
|
||||
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
if (0 > $srcContext) {
|
||||
$srcContext = \count($content);
|
||||
}
|
||||
@ -205,7 +205,7 @@ class CodeExtension extends AbstractExtension
|
||||
public function getFileLink($file, $line)
|
||||
{
|
||||
if ($fmt = $this->fileLinkFormat) {
|
||||
return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line);
|
||||
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -224,7 +224,7 @@ class CodeExtension extends AbstractExtension
|
||||
public function formatLogMessage($message, array $context)
|
||||
{
|
||||
if ($context && false !== strpos($message, '{')) {
|
||||
$replacements = array();
|
||||
$replacements = [];
|
||||
foreach ($context as $key => $val) {
|
||||
if (is_scalar($val)) {
|
||||
$replacements['{'.$key.'}'] = $val;
|
||||
|
@ -37,14 +37,14 @@ class DumpExtension extends AbstractExtension
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('dump', array($this, 'dump'), array('is_safe' => array('html'), 'needs_context' => true, 'needs_environment' => true)),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new DumpTokenParser());
|
||||
return [new DumpTokenParser()];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -59,14 +59,14 @@ class DumpExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
if (2 === \func_num_args()) {
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
foreach ($context as $key => $value) {
|
||||
if (!$value instanceof Template) {
|
||||
$vars[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$vars = array($vars);
|
||||
$vars = [$vars];
|
||||
} else {
|
||||
$vars = \func_get_args();
|
||||
unset($vars[0], $vars[1]);
|
||||
|
@ -27,9 +27,9 @@ class ExpressionExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('expression', array($this, 'createExpression')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('expression', [$this, 'createExpression']),
|
||||
];
|
||||
}
|
||||
|
||||
public function createExpression($expression)
|
||||
|
@ -65,10 +65,10 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
// {% form_theme form "SomeBundle::widgets.twig" %}
|
||||
new FormThemeTokenParser(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,17 +76,17 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('form_widget', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_errors', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_label', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_row', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_rest', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_start', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('form_end', null, array('node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => array('html'))),
|
||||
new TwigFunction('csrf_token', array('Symfony\Component\Form\FormRenderer', 'renderCsrfToken')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('form_widget', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_errors', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_label', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_row', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_rest', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
|
||||
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +94,10 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('humanize', array('Symfony\Component\Form\FormRenderer', 'humanize')),
|
||||
new TwigFilter('form_encode_currency', array('Symfony\Component\Form\FormRenderer', 'encodeCurrency'), array('is_safe' => array('html'), 'needs_environment' => true)),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('humanize', ['Symfony\Component\Form\FormRenderer', 'humanize']),
|
||||
new TwigFilter('form_encode_currency', ['Symfony\Component\Form\FormRenderer', 'encodeCurrency'], ['is_safe' => ['html'], 'needs_environment' => true]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,10 +105,10 @@ class FormExtension extends AbstractExtension implements InitRuntimeInterface
|
||||
*/
|
||||
public function getTests()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new TwigTest('selectedchoice', 'Symfony\Bridge\Twig\Extension\twig_is_selected_choice'),
|
||||
new TwigTest('rootform', 'Symfony\Bridge\Twig\Extension\twig_is_root_form'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,10 +38,10 @@ class HttpFoundationExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('absolute_url', array($this, 'generateAbsoluteUrl')),
|
||||
new TwigFunction('relative_path', array($this, 'generateRelativePath')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('absolute_url', [$this, 'generateAbsoluteUrl']),
|
||||
new TwigFunction('relative_path', [$this, 'generateRelativePath']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,14 +24,14 @@ class HttpKernelExtension extends AbstractExtension
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('render', array(HttpKernelRuntime::class, 'renderFragment'), array('is_safe' => array('html'))),
|
||||
new TwigFunction('render_*', array(HttpKernelRuntime::class, 'renderFragmentStrategy'), array('is_safe' => array('html'))),
|
||||
return [
|
||||
new TwigFunction('render', [HttpKernelRuntime::class, 'renderFragment'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('render_*', [HttpKernelRuntime::class, 'renderFragmentStrategy'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('controller', static::class.'::controller'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public static function controller($controller, $attributes = array(), $query = array())
|
||||
public static function controller($controller, $attributes = [], $query = [])
|
||||
{
|
||||
return new ControllerReference($controller, $attributes, $query);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class HttpKernelRuntime
|
||||
*
|
||||
* @see FragmentHandler::render()
|
||||
*/
|
||||
public function renderFragment($uri, $options = array())
|
||||
public function renderFragment($uri, $options = [])
|
||||
{
|
||||
$strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
|
||||
unset($options['strategy']);
|
||||
@ -57,7 +57,7 @@ class HttpKernelRuntime
|
||||
*
|
||||
* @see FragmentHandler::render()
|
||||
*/
|
||||
public function renderFragmentStrategy($strategy, $uri, $options = array())
|
||||
public function renderFragmentStrategy($strategy, $uri, $options = [])
|
||||
{
|
||||
return $this->handler->render($uri, $strategy, $options);
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ class LogoutUrlExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('logout_url', array($this, 'getLogoutUrl')),
|
||||
new TwigFunction('logout_path', array($this, 'getLogoutPath')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('logout_url', [$this, 'getLogoutUrl']),
|
||||
new TwigFunction('logout_path', [$this, 'getLogoutPath']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,10 +39,10 @@ class RoutingExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('url', array($this, 'getUrl'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
|
||||
new TwigFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
|
||||
new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ class RoutingExtension extends AbstractExtension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath($name, $parameters = array(), $relative = false)
|
||||
public function getPath($name, $parameters = [], $relative = false)
|
||||
{
|
||||
return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
@ -64,7 +64,7 @@ class RoutingExtension extends AbstractExtension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl($name, $parameters = array(), $schemeRelative = false)
|
||||
public function getUrl($name, $parameters = [], $schemeRelative = false)
|
||||
{
|
||||
return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
@ -103,10 +103,10 @@ class RoutingExtension extends AbstractExtension
|
||||
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 &&
|
||||
(!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression)
|
||||
) {
|
||||
return array('html');
|
||||
return ['html'];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,9 +53,9 @@ class SecurityExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('is_granted', array($this, 'isGranted')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('is_granted', [$this, 'isGranted']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,14 +38,14 @@ class StopwatchExtension extends AbstractExtension
|
||||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
/*
|
||||
* {% stopwatch foo %}
|
||||
* Some stuff which will be recorded on the timeline
|
||||
* {% endstopwatch %}
|
||||
*/
|
||||
new StopwatchTokenParser(null !== $this->stopwatch && $this->enabled),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -48,10 +48,10 @@ class TranslationExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('trans', array($this, 'trans')),
|
||||
new TwigFilter('transchoice', array($this, 'transchoice')),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('trans', [$this, 'trans']),
|
||||
new TwigFilter('transchoice', [$this, 'transchoice']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ class TranslationExtension extends AbstractExtension
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
// {% trans %}Symfony is great!{% endtrans %}
|
||||
new TransTokenParser(),
|
||||
|
||||
@ -72,7 +72,7 @@ class TranslationExtension extends AbstractExtension
|
||||
|
||||
// {% trans_default_domain "foobar" %}
|
||||
new TransDefaultDomainTokenParser(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +80,7 @@ class TranslationExtension extends AbstractExtension
|
||||
*/
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array($this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor());
|
||||
return [$this->getTranslationNodeVisitor(), new TranslationDefaultDomainNodeVisitor()];
|
||||
}
|
||||
|
||||
public function getTranslationNodeVisitor()
|
||||
@ -88,7 +88,7 @@ class TranslationExtension extends AbstractExtension
|
||||
return $this->translationNodeVisitor ?: $this->translationNodeVisitor = new TranslationNodeVisitor();
|
||||
}
|
||||
|
||||
public function trans($message, array $arguments = array(), $domain = null, $locale = null)
|
||||
public function trans($message, array $arguments = [], $domain = null, $locale = null)
|
||||
{
|
||||
if (null === $this->translator) {
|
||||
return strtr($message, $arguments);
|
||||
@ -97,13 +97,13 @@ class TranslationExtension extends AbstractExtension
|
||||
return $this->translator->trans($message, $arguments, $domain, $locale);
|
||||
}
|
||||
|
||||
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
|
||||
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
|
||||
{
|
||||
if (null === $this->translator) {
|
||||
return strtr($message, $arguments);
|
||||
}
|
||||
|
||||
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
|
||||
return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,14 +36,14 @@ class WebLinkExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('link', array($this, 'link')),
|
||||
new TwigFunction('preload', array($this, 'preload')),
|
||||
new TwigFunction('dns_prefetch', array($this, 'dnsPrefetch')),
|
||||
new TwigFunction('preconnect', array($this, 'preconnect')),
|
||||
new TwigFunction('prefetch', array($this, 'prefetch')),
|
||||
new TwigFunction('prerender', array($this, 'prerender')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('link', [$this, 'link']),
|
||||
new TwigFunction('preload', [$this, 'preload']),
|
||||
new TwigFunction('dns_prefetch', [$this, 'dnsPrefetch']),
|
||||
new TwigFunction('preconnect', [$this, 'preconnect']),
|
||||
new TwigFunction('prefetch', [$this, 'prefetch']),
|
||||
new TwigFunction('prerender', [$this, 'prerender']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,7 +55,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The relation URI
|
||||
*/
|
||||
public function link($uri, $rel, array $attributes = array())
|
||||
public function link($uri, $rel, array $attributes = [])
|
||||
{
|
||||
if (!$request = $this->requestStack->getMasterRequest()) {
|
||||
return $uri;
|
||||
@ -80,7 +80,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function preload($uri, array $attributes = array())
|
||||
public function preload($uri, array $attributes = [])
|
||||
{
|
||||
return $this->link($uri, 'preload', $attributes);
|
||||
}
|
||||
@ -93,7 +93,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function dnsPrefetch($uri, array $attributes = array())
|
||||
public function dnsPrefetch($uri, array $attributes = [])
|
||||
{
|
||||
return $this->link($uri, 'dns-prefetch', $attributes);
|
||||
}
|
||||
@ -106,7 +106,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function preconnect($uri, array $attributes = array())
|
||||
public function preconnect($uri, array $attributes = [])
|
||||
{
|
||||
return $this->link($uri, 'preconnect', $attributes);
|
||||
}
|
||||
@ -119,7 +119,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function prefetch($uri, array $attributes = array())
|
||||
public function prefetch($uri, array $attributes = [])
|
||||
{
|
||||
return $this->link($uri, 'prefetch', $attributes);
|
||||
}
|
||||
@ -132,7 +132,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function prerender($uri, array $attributes = array())
|
||||
public function prerender($uri, array $attributes = [])
|
||||
{
|
||||
return $this->link($uri, 'prerender', $attributes);
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ class WorkflowExtension extends AbstractExtension
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new TwigFunction('workflow_can', array($this, 'canTransition')),
|
||||
new TwigFunction('workflow_transitions', array($this, 'getEnabledTransitions')),
|
||||
new TwigFunction('workflow_has_marked_place', array($this, 'hasMarkedPlace')),
|
||||
new TwigFunction('workflow_marked_places', array($this, 'getMarkedPlaces')),
|
||||
);
|
||||
return [
|
||||
new TwigFunction('workflow_can', [$this, 'canTransition']),
|
||||
new TwigFunction('workflow_transitions', [$this, 'getEnabledTransitions']),
|
||||
new TwigFunction('workflow_has_marked_place', [$this, 'hasMarkedPlace']),
|
||||
new TwigFunction('workflow_marked_places', [$this, 'getMarkedPlaces']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,10 +28,10 @@ class YamlExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new TwigFilter('yaml_encode', array($this, 'encode')),
|
||||
new TwigFilter('yaml_dump', array($this, 'dump')),
|
||||
);
|
||||
return [
|
||||
new TwigFilter('yaml_encode', [$this, 'encode']),
|
||||
new TwigFilter('yaml_dump', [$this, 'dump']),
|
||||
];
|
||||
}
|
||||
|
||||
public function encode($input, $inline = 0, $dumpObjects = 0)
|
||||
|
@ -31,7 +31,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
||||
*/
|
||||
private $template;
|
||||
|
||||
public function __construct(array $defaultThemes = array(), Environment $environment = null)
|
||||
public function __construct(array $defaultThemes = [], Environment $environment = null)
|
||||
{
|
||||
if (null === $environment) {
|
||||
@trigger_error(sprintf('Not passing a Twig Environment as the second argument for "%s" constructor is deprecated since Symfony 3.2 and won\'t be possible in 4.0.', static::class), E_USER_DEPRECATED);
|
||||
@ -58,7 +58,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderBlock(FormView $view, $resource, $blockName, array $variables = array())
|
||||
public function renderBlock(FormView $view, $resource, $blockName, array $variables = [])
|
||||
{
|
||||
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
|
||||
|
||||
@ -187,7 +187,7 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
|
||||
// theme is a reference and we don't want to change it.
|
||||
$currentTheme = $theme;
|
||||
|
||||
$context = $this->environment->mergeGlobals(array());
|
||||
$context = $this->environment->mergeGlobals([]);
|
||||
|
||||
// The do loop takes care of template inheritance.
|
||||
// Add blocks from all templates in the inheritance tree, but avoid
|
||||
|
@ -23,12 +23,12 @@ class DumpNode extends Node
|
||||
|
||||
public function __construct($varPrefix, Node $values = null, $lineno, $tag = null)
|
||||
{
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
if (null !== $values) {
|
||||
$nodes['values'] = $values;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array(), $lineno, $tag);
|
||||
parent::__construct($nodes, [], $lineno, $tag);
|
||||
$this->varPrefix = $varPrefix;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ class FormThemeNode extends Node
|
||||
{
|
||||
public function __construct(Node $form, Node $resources, $lineno, $tag = null, $only = false)
|
||||
{
|
||||
parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => (bool) $only), $lineno, $tag);
|
||||
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => (bool) $only], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
|
@ -53,7 +53,7 @@ class SearchAndRenderBlockNode extends FunctionExpression
|
||||
// Only insert the label into the array if it is not empty
|
||||
if (!twig_test_empty($label->getAttribute('value'))) {
|
||||
$originalVariables = $variables;
|
||||
$variables = new ArrayExpression(array(), $lineno);
|
||||
$variables = new ArrayExpression([], $lineno);
|
||||
$labelKey = new ConstantExpression('label', $lineno);
|
||||
|
||||
if (null !== $originalVariables) {
|
||||
|
@ -24,7 +24,7 @@ class StopwatchNode extends Node
|
||||
{
|
||||
public function __construct(Node $name, Node $body, AssignNameExpression $var, $lineno = 0, $tag = null)
|
||||
{
|
||||
parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag);
|
||||
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
|
@ -22,7 +22,7 @@ class TransDefaultDomainNode extends Node
|
||||
{
|
||||
public function __construct(AbstractExpression $expr, $lineno = 0, $tag = null)
|
||||
{
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
parent::__construct(['expr' => $expr], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
|
@ -29,7 +29,7 @@ class TransNode extends Node
|
||||
{
|
||||
public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null)
|
||||
{
|
||||
$nodes = array('body' => $body);
|
||||
$nodes = ['body' => $body];
|
||||
if (null !== $domain) {
|
||||
$nodes['domain'] = $domain;
|
||||
}
|
||||
@ -43,14 +43,14 @@ class TransNode extends Node
|
||||
$nodes['locale'] = $locale;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array(), $lineno, $tag);
|
||||
parent::__construct($nodes, [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$defaults = new ArrayExpression(array(), -1);
|
||||
$defaults = new ArrayExpression([], -1);
|
||||
if ($this->hasNode('vars') && ($vars = $this->getNode('vars')) instanceof ArrayExpression) {
|
||||
$defaults = $this->getNode('vars');
|
||||
$vars = null;
|
||||
@ -109,7 +109,7 @@ class TransNode extends Node
|
||||
} elseif ($body instanceof TextNode) {
|
||||
$msg = $body->getAttribute('data');
|
||||
} else {
|
||||
return array($body, $vars);
|
||||
return [$body, $vars];
|
||||
}
|
||||
|
||||
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
|
||||
@ -127,6 +127,6 @@ class TransNode extends Node
|
||||
}
|
||||
}
|
||||
|
||||
return array(new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars);
|
||||
return [new ConstantExpression(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars];
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user