fixed short array CS in comments

This commit is contained in:
Fabien Potencier 2019-01-16 14:03:22 +01:00
parent 25240831e2
commit 1429267f9c
73 changed files with 264 additions and 264 deletions

View File

@ -50,7 +50,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
/**
* List of potential container parameters that hold the object manager name
* to register the mappings with the correct metadata driver, for example
* array('acme.manager', 'doctrine.default_entity_manager').
* ['acme.manager', 'doctrine.default_entity_manager'].
*
* @var string[]
*/

View File

@ -25,7 +25,7 @@ class Test
{
public static function getGroups()
{
return array();
return [];
}
}
EOPHP

View File

@ -7,7 +7,7 @@ class Test
{
public static function getGroups()
{
return array();
return [];
}
}
EOPHP

View File

@ -25,7 +25,7 @@ class Test
{
public static function getGroups()
{
return array();
return [];
}
}
EOPHP

View File

@ -25,7 +25,7 @@ class Test
{
public static function getGroups()
{
return array();
return [];
}
}
EOPHP

View File

@ -83,7 +83,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true)));
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", [], $p, getcwd(), null, ['bypass_shell' => true]));
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($exit) {
exit($exit);
@ -116,9 +116,9 @@ EOPHP
}
global $argv, $argc;
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : [];
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
$components = array();
$components = [];
$cmd = array_map('escapeshellarg', $argv);
$exit = 0;
@ -153,7 +153,7 @@ if ('\\' === DIRECTORY_SEPARATOR) {
if ($components) {
$skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false;
$runningProcs = array();
$runningProcs = [];
foreach ($components as $component) {
// Run phpunit tests in parallel
@ -164,7 +164,7 @@ if ($components) {
$c = escapeshellarg($component);
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), [], $pipes)) {
$runningProcs[$component] = $proc;
} else {
$exit = 1;
@ -174,7 +174,7 @@ if ($components) {
while ($runningProcs) {
usleep(300000);
$terminatedProcs = array();
$terminatedProcs = [];
foreach ($runningProcs as $component => $proc) {
$procStatus = proc_get_status($proc);
if (!$procStatus['running']) {
@ -185,7 +185,7 @@ if ($components) {
}
foreach ($terminatedProcs as $component => $procStatus) {
foreach (array('out', 'err') as $file) {
foreach (['out', 'err'] as $file) {
$file = "$component/phpunit.std$file";
readfile($file);
unlink($file);
@ -195,7 +195,7 @@ if ($components) {
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) {
$exit = $procStatus;
echo "\033[41mKO\033[0m $component\n\n";
} else {
@ -207,7 +207,7 @@ if ($components) {
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
class SymfonyBlacklistSimplePhpunit {}
}
array_splice($argv, 1, 0, array('--colors=always'));
array_splice($argv, 1, 0, ['--colors=always']);
$_SERVER['argv'] = $argv;
$_SERVER['argc'] = ++$argc;
include "$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit";

View File

@ -150,7 +150,7 @@ class AppVariable
* Returns some or all the existing flash messages:
* * getFlashes() returns all the flash messages
* * getFlashes('notice') returns a simple array with flash messages of that type
* * getFlashes(array('notice', 'error')) returns a nested array of type => messages.
* * getFlashes(['notice', 'error']) returns a nested array of type => messages.
*
* @return array
*/

View File

@ -33,7 +33,7 @@ CHANGELOG
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig']);
$rendererEngine->setEnvironment($twig);
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
```
@ -42,13 +42,13 @@ CHANGELOG
```php
// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig);
// require Twig 1.30+
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader(array(
$twig->addRuntimeLoader(new \Twig\RuntimeLoader\FactoryRuntimeLoader([
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},
)));
]));
$twig->addExtension(new FormExtension());
```
* Deprecated the `TwigRendererEngineInterface` interface.

View File

@ -51,7 +51,7 @@ class WebLinkExtension extends AbstractExtension
*
* @param string $uri The relation URI
* @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch")
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
*
* @return string The relation URI
*/
@ -76,7 +76,7 @@ class WebLinkExtension extends AbstractExtension
* Preloads a resource.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('crossorigin' => 'use-credentials')")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']")
*
* @return string The path of the asset
*/
@ -89,7 +89,7 @@ class WebLinkExtension extends AbstractExtension
* Resolves a resource origin as early as possible.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
*
* @return string The path of the asset
*/
@ -102,7 +102,7 @@ class WebLinkExtension extends AbstractExtension
* Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation).
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
*
* @return string The path of the asset
*/
@ -115,7 +115,7 @@ class WebLinkExtension extends AbstractExtension
* Indicates to the client that it should prefetch this resource.
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
*
* @return string The path of the asset
*/
@ -128,7 +128,7 @@ class WebLinkExtension extends AbstractExtension
* Indicates to the client that it should prerender this resource .
*
* @param string $uri A public path
* @param array $attributes The attributes of this link (e.g. "array('as' => true)", "array('pr' => 0.5)")
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
*
* @return string The path of the asset
*/

View File

@ -338,7 +338,7 @@ namespace $namespace
// filter container's resources, removing reference to temp kernel file
\$resources = \$container->getResources();
\$filteredResources = array();
\$filteredResources = [];
foreach (\$resources as \$resource) {
if ((string) \$resource !== __FILE__) {
\$filteredResources[] = \$resource;

View File

@ -39,9 +39,9 @@ trait MicroKernelTrait
*
* You can register extensions:
*
* $c->loadFromExtension('framework', array(
* $c->loadFromExtension('framework', [
* 'secret' => '%secret%'
* ));
* ]);
*
* Or services:
*

View File

@ -61,9 +61,9 @@ class FormHelper extends Helper
*
* You can pass options during the call:
*
* <?php echo view['form']->form($form, array('attr' => array('class' => 'foo'))) ?>
* <?php echo view['form']->form($form, ['attr' => ['class' => 'foo']]) ?>
*
* <?php echo view['form']->form($form, array('separator' => '+++++')) ?>
* <?php echo view['form']->form($form, ['separator' => '+++++']) ?>
*
* This method is mainly intended for prototyping purposes. If you want to
* control the layout of a form in a more fine-grained manner, you are
@ -124,9 +124,9 @@ class FormHelper extends Helper
*
* You can pass options during the call:
*
* <?php echo $view['form']->widget($form, array('attr' => array('class' => 'foo'))) ?>
* <?php echo $view['form']->widget($form, ['attr' => ['class' => 'foo']]) ?>
*
* <?php echo $view['form']->widget($form, array('separator' => '+++++')) ?>
* <?php echo $view['form']->widget($form, ['separator' => '+++++']) ?>
*
* @param FormView $view The view for which to render the widget
* @param array $variables Additional variables passed to the template

View File

@ -29,21 +29,21 @@ EOF
<?php echo $view['translator']->transChoice(
'{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
10,
array('%count%' => 10)
['%count%' => 10]
) ?>
<?php echo $view['translator']->trans('other-domain-test-no-params-short-array', array(), 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-no-params-short-array', [], 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-no-params-long-array', array(), 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-no-params-long-array', [], 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-params-short-array', array('foo' => 'bar'), 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-params-short-array', ['foo' => 'bar'], 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-params-long-array', array('foo' => 'bar'), 'not_messages'); ?>
<?php echo $view['translator']->trans('other-domain-test-params-long-array', ['foo' => 'bar'], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-short-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?>
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-short-array-%count%', 10, ['%count%' => 10], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-long-array-%count%', 10, array('%count%' => 10), 'not_messages'); ?>
<?php echo $view['translator']->transChoice('other-domain-test-trans-choice-long-array-%count%', 10, ['%count%' => 10], 'not_messages'); ?>
<?php echo $view['translator']->trans('typecast', array('a' => (int) '123'), 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg1', 10 + 1, array(), 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), array(), 'not_messages'); ?>
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), [], 'not_messages'); ?>

View File

@ -1,2 +1,2 @@
<?php if (!$label) { $label = $view['form']->humanize($name); } ?>
<label>Custom name label: <?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
<label>Custom name label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>

View File

@ -1,4 +1,4 @@
<?php if (!$label) {
$label = $view['form']->humanize($name);
} ?>
<label>Custom label: <?php echo $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?></label>
<label>Custom label: <?php echo $view->escape($view['translator']->trans($label, [], $translation_domain)) ?></label>

View File

@ -35,7 +35,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
* * db_time_col: The column where to store the timestamp [default: item_time]
* * db_username: The username when lazy-connect [default: '']
* * db_password: The password when lazy-connect [default: '']
* * db_connection_options: An array of driver-specific connection options [default: array()]
* * db_connection_options: An array of driver-specific connection options [default: []]
*
* @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null
* @param string $namespace

View File

@ -33,7 +33,7 @@ class PdoCache extends AbstractCache implements PruneableInterface
* * db_time_col: The column where to store the timestamp [default: item_time]
* * db_username: The username when lazy-connect [default: '']
* * db_password: The password when lazy-connect [default: '']
* * db_connection_options: An array of driver-specific connection options [default: array()]
* * db_connection_options: An array of driver-specific connection options [default: []]
*
* @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null
* @param string $namespace

View File

@ -64,7 +64,7 @@ trait MemcachedTrait
*
* Examples for servers:
* - 'memcached://user:pass@localhost?weight=33'
* - array(array('localhost', 11211, 33))
* - [['localhost', 11211, 33]]
*
* @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs
* @param array $options An array of options

View File

@ -60,7 +60,7 @@ trait PhpArrayTrait
// This file has been auto-generated by the Symfony Cache Component.
return array(
return [
EOF;
@ -97,7 +97,7 @@ EOF;
$dump .= var_export($key, true).' => '.var_export($value, true).",\n";
}
$dump .= "\n);\n";
$dump .= "\n];\n";
$dump = str_replace("' . \"\\0\" . '", "\0", $dump);
$tmpFile = uniqid($this->file, true);

View File

@ -34,7 +34,7 @@ The edge case of defining just one value for nodes of type Enum is now allowed:
$rootNode
->children()
->enumNode('variable')
->values(array('value'))
->values(['value'])
->end()
->end()
;

View File

@ -82,7 +82,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
/**
* Sets the xml remappings that should be performed.
*
* @param array $remappings An array of the form array(array(string, string))
* @param array $remappings An array of the form [[string, string]]
*/
public function setXmlRemappings(array $remappings)
{
@ -92,7 +92,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
/**
* Gets the xml remappings that should be performed.
*
* @return array an array of the form array(array(string, string))
* @return array an array of the form [[string, string]]
*/
public function getXmlRemappings()
{

View File

@ -214,15 +214,15 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
* to be the key of the particular item. For example, if "id" is the
* "key", then:
*
* array(
* array('id' => 'my_name', 'foo' => 'bar'),
* );
* [
* ['id' => 'my_name', 'foo' => 'bar'],
* ];
*
* becomes
*
* array(
* 'my_name' => array('foo' => 'bar'),
* );
* [
* 'my_name' => ['foo' => 'bar'],
* ];
*
* If you'd like "'id' => 'my_name'" to still be present in the resulting
* array, then you can set the second argument of this method to false.

View File

@ -53,15 +53,15 @@ class PrototypedArrayNode extends ArrayNode
* to be the key of the particular item. For example, if "id" is the
* "key", then:
*
* array(
* array('id' => 'my_name', 'foo' => 'bar'),
* );
* [
* ['id' => 'my_name', 'foo' => 'bar'],
* ];
*
* becomes
*
* array(
* 'my_name' => array('foo' => 'bar'),
* );
* [
* 'my_name' => ['foo' => 'bar'],
* ];
*
* If you'd like "'id' => 'my_name'" to still be present in the resulting
* array, then you can set the second argument of this method to false.
@ -335,30 +335,30 @@ class PrototypedArrayNode extends ArrayNode
*
* For example, assume $this->keyAttribute is 'name' and the value array is as follows:
*
* array(
* array(
* [
* [
* 'name' => 'name001',
* 'value' => 'value001'
* )
* )
* ]
* ]
*
* Now, the key is 0 and the child node is:
*
* array(
* [
* 'name' => 'name001',
* 'value' => 'value001'
* )
* ]
*
* When normalizing the value array, the 'name' element will removed from the child node
* and its value becomes the new key of the child node:
*
* array(
* 'name001' => array('value' => 'value001')
* )
* [
* 'name001' => ['value' => 'value001']
* ]
*
* Now only 'value' element is left in the child node which can be further simplified into a string:
*
* array('name001' => 'value001')
* ['name001' => 'value001']
*
* Now, the key becomes 'name001' and the child node becomes 'value001' and
* the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance.

View File

@ -227,7 +227,7 @@ class ExprBuilderTest extends TestCase
*
* @param TreeBuilder $testBuilder The tree builder to finalize
* @param array $config The config you want to use for the finalization, if nothing provided
* a simple array('key'=>'value') will be used
* a simple ['key'=>'value'] will be used
*
* @return array The finalized config values
*/

View File

@ -66,12 +66,12 @@ class PrototypedArrayNodeTest extends TestCase
* The above should finally be mapped to an array that looks like this
* (because "id" is the key attribute).
*
* array(
* 'things' => array(
* [
* 'things' => [
* 'option1' => 'foo',
* 'option2' => 'bar',
* )
* )
* ]
* ]
*/
public function testMappedAttributeKeyIsRemoved()
{
@ -191,11 +191,11 @@ class PrototypedArrayNodeTest extends TestCase
* The above should finally be mapped to an array that looks like this
* (because "id" is the key attribute).
*
* array(
* 'things' => array(
* [
* 'things' => [
* 'option1' => 'value1'
* )
* )
* ]
* ]
*
* It's also possible to mix 'value-only' and 'non-value-only' elements in the array.
*
@ -206,15 +206,15 @@ class PrototypedArrayNodeTest extends TestCase
*
* The above should finally be mapped to an array as follows
*
* array(
* 'things' => array(
* [
* 'things' => [
* 'option1' => 'value1',
* 'option2' => array(
* 'option2' => [
* 'value' => 'value2',
* 'foo' => 'foo2'
* )
* )
* )
* ]
* ]
* ]
*
* The 'value' element can also be ArrayNode:
*
@ -229,14 +229,14 @@ class PrototypedArrayNodeTest extends TestCase
*
* The above should be finally be mapped to an array as follows
*
* array(
* 'things' => array(
* 'option1' => array(
* [
* 'things' => [
* 'option1' => [
* 'foo' => 'foo1',
* 'bar' => 'bar1'
* )
* )
* )
* ]
* ]
* ]
*
* If using VariableNode for value node, it's also possible to mix different types of value nodes:
*
@ -252,15 +252,15 @@ class PrototypedArrayNodeTest extends TestCase
*
* The above should be finally mapped to an array as follows
*
* array(
* 'things' => array(
* 'option1' => array(
* [
* 'things' => [
* 'option1' => [
* 'foo' => 'foo1',
* 'bar' => 'bar1'
* ),
* ],
* 'option2' => 'value2'
* )
* )
* ]
* ]
*
*
* @dataProvider getDataForKeyRemovedLeftValueOnly

View File

@ -71,7 +71,7 @@ class ReflectionClassResourceTest extends TestCase
/* 2*/ {
/* 3*/ const FOO = 123;
/* 4*/
/* 5*/ public $pub = array();
/* 5*/ public $pub = [];
/* 6*/
/* 7*/ protected $prot;
/* 8*/
@ -79,7 +79,7 @@ class ReflectionClassResourceTest extends TestCase
/*10*/
/*11*/ public function pub($arg = null) {}
/*12*/
/*13*/ protected function prot($a = array()) {}
/*13*/ protected function prot($a = []) {}
/*14*/
/*15*/ private function priv() {}
/*16*/ }
@ -119,8 +119,8 @@ EOPHP;
yield [1, 3, 'const FOO = 456;'];
yield [1, 3, 'const BAR = 123;'];
yield [1, 4, '/** pub docblock */'];
yield [1, 5, 'protected $pub = array();'];
yield [1, 5, 'public $pub = array(123);'];
yield [1, 5, 'protected $pub = [];'];
yield [1, 5, 'public $pub = [123];'];
yield [1, 6, '/** prot docblock */'];
yield [1, 7, 'private $prot;'];
yield [0, 8, '/** priv docblock */'];
@ -134,7 +134,7 @@ EOPHP;
}
yield [0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"];
yield [1, 12, '/** prot docblock */'];
yield [1, 13, 'protected function prot($a = array(123)) {}'];
yield [1, 13, 'protected function prot($a = [123]) {}'];
yield [0, 14, '/** priv docblock */'];
yield [0, 15, ''];
}

View File

@ -19,7 +19,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException;
*
* Usage:
*
* $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar'));
* $input = new ArrayInput(['name' => 'foo', '--bar' => 'foobar']);
*
* @author Fabien Potencier <fabien@symfony.com>
*/

View File

@ -19,10 +19,10 @@ use Symfony\Component\Console\Exception\LogicException;
*
* Usage:
*
* $definition = new InputDefinition(array(
* $definition = new InputDefinition([
* new InputArgument('name', InputArgument::REQUIRED),
* new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
* ));
* ]);
*
* @author Fabien Potencier <fabien@symfony.com>
*/

View File

@ -186,7 +186,7 @@ class InputDefinitionTest extends TestCase
new InputArgument('foo1', InputArgument::OPTIONAL),
new InputArgument('foo2', InputArgument::OPTIONAL, '', 'default'),
new InputArgument('foo3', InputArgument::OPTIONAL | InputArgument::IS_ARRAY),
// new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)),
// new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', [1, 2]),
]);
$this->assertEquals(['foo1' => null, 'foo2' => 'default', 'foo3' => []], $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument');

View File

@ -25,41 +25,41 @@ function symfony_zval_info($key, $array, $options = 0)
return null;
}
$info = array(
$info = [
'type' => gettype($array[$key]),
'zval_hash' => /* hashed memory address of $array[$key] */,
'zval_refcount' => /* internal zval refcount of $array[$key] */,
'zval_isref' => /* is_ref status of $array[$key] */,
);
];
switch ($info['type']) {
case 'object':
$info += array(
$info += [
'object_class' => get_class($array[$key]),
'object_refcount' => /* internal object refcount of $array[$key] */,
'object_hash' => spl_object_hash($array[$key]),
'object_handle' => /* internal object handle $array[$key] */,
);
];
break;
case 'resource':
$info += array(
$info += [
'resource_handle' => (int) $array[$key],
'resource_type' => get_resource_type($array[$key]),
'resource_refcount' => /* internal resource refcount of $array[$key] */,
);
];
break;
case 'array':
$info += array(
$info += [
'array_count' => count($array[$key]),
);
];
break;
case 'string':
$info += array(
$info += [
'strlen' => strlen($array[$key]),
);
];
break;
}

View File

@ -28,14 +28,14 @@ class DebugClassLoaderTest extends TestCase
{
$this->errorReporting = error_reporting(E_ALL);
$this->loader = new ClassLoader();
spl_autoload_register(array($this->loader, 'loadClass'), true, true);
spl_autoload_register([$this->loader, 'loadClass'], true, true);
DebugClassLoader::enable();
}
protected function tearDown()
{
DebugClassLoader::disable();
spl_autoload_unregister(array($this->loader, 'loadClass'));
spl_autoload_unregister([$this->loader, 'loadClass']);
error_reporting($this->errorReporting);
}
@ -45,7 +45,7 @@ class DebugClassLoaderTest extends TestCase
$functions = spl_autoload_functions();
foreach ($functions as $function) {
if (is_array($function) && $function[0] instanceof DebugClassLoader) {
if (\is_array($function) && $function[0] instanceof DebugClassLoader) {
$reflClass = new \ReflectionClass($function[0]);
$reflProp = $reflClass->getProperty('classLoader');
$reflProp->setAccessible(true);
@ -81,7 +81,7 @@ class DebugClassLoaderTest extends TestCase
if (\PHP_VERSION_ID >= 70000) {
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
}
if (defined('HHVM_VERSION')) {
if (\defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM is not handled in this test case.');
}
@ -106,7 +106,7 @@ class DebugClassLoaderTest extends TestCase
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
$this->markTestSkipped('The ContextErrorException class is already loaded.');
}
if (defined('HHVM_VERSION')) {
if (\defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM is not handled in this test case.');
}
@ -192,7 +192,7 @@ class DebugClassLoaderTest extends TestCase
{
set_error_handler(function () { return false; });
$e = error_reporting(0);
trigger_error('', E_USER_DEPRECATED);
@trigger_error('', E_USER_DEPRECATED);
class_exists('Test\\'.__NAMESPACE__.'\\'.$class, true);
@ -202,20 +202,20 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$xError = array(
$xError = [
'type' => E_USER_DEPRECATED,
'message' => 'The "Test\Symfony\Component\Debug\Tests\\'.$class.'" class '.$type.' "Symfony\Component\Debug\Tests\Fixtures\\'.$super.'" that is deprecated but this is a test deprecation notice.',
);
];
$this->assertSame($xError, $lastError);
}
public function provideDeprecatedSuper()
{
return array(
array('DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'),
array('DeprecatedParentClass', 'DeprecatedClass', 'extends'),
);
return [
['DeprecatedInterfaceClass', 'DeprecatedInterface', 'implements'],
['DeprecatedParentClass', 'DeprecatedClass', 'extends'],
];
}
public function testInterfaceExtendsDeprecatedInterface()
@ -232,10 +232,10 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$xError = array(
$xError = [
'type' => E_USER_NOTICE,
'message' => '',
);
];
$this->assertSame($xError, $lastError);
}
@ -254,10 +254,10 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$xError = array(
$xError = [
'type' => E_USER_NOTICE,
'message' => '',
);
];
$this->assertSame($xError, $lastError);
}
@ -280,10 +280,10 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$xError = array(
$xError = [
'type' => E_USER_DEPRECATED,
'message' => 'The "Test\Symfony\Component\Debug\Tests\Float" class uses the reserved name "Float", it will break on PHP 7 and higher',
);
];
$this->assertSame($xError, $lastError);
}
@ -302,17 +302,17 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$xError = array(
$xError = [
'type' => E_USER_DEPRECATED,
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".',
);
];
$this->assertSame($xError, $lastError);
}
public function testExtendedFinalMethod()
{
$deprecations = array();
$deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@ -321,10 +321,10 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
$xError = array(
$xError = [
'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod2()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
);
];
$this->assertSame($xError, $deprecations);
}
@ -343,12 +343,12 @@ class DebugClassLoaderTest extends TestCase
$lastError = error_get_last();
unset($lastError['file'], $lastError['line']);
$this->assertSame(array('type' => E_USER_NOTICE, 'message' => ''), $lastError);
$this->assertSame(['type' => E_USER_NOTICE, 'message' => ''], $lastError);
}
public function testInternalsUse()
{
$deprecations = array();
$deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@ -357,17 +357,17 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
$this->assertSame($deprecations, array(
$this->assertSame($deprecations, [
'The "Symfony\Component\Debug\Tests\Fixtures\InternalInterface" interface is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".',
'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal since version 3.4. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".',
'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait" trait is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass::internalMethod()" method is considered internal since version 3.4. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
));
]);
}
public function testUseTraitWithInternalMethod()
{
$deprecations = array();
$deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; });
$e = error_reporting(E_USER_DEPRECATED);
@ -376,7 +376,7 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
$this->assertSame(array(), $deprecations);
$this->assertSame([], $deprecations);
}
}
@ -388,12 +388,12 @@ class ClassLoader
public function getClassMap()
{
return array(__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php');
return [__NAMESPACE__.'\Fixtures\NotPSR0bis' => __DIR__.'/Fixtures/notPsr0Bis.php'];
}
public function findFile($class)
{
$fixtureDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR;
$fixtureDir = __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR;
if (__NAMESPACE__.'\TestingUnsilencing' === $class) {
eval('-- parse error --');
@ -402,7 +402,7 @@ class ClassLoader
} elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) {
eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}');
} elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) {
return $fixtureDir.'psr4'.DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php';
return $fixtureDir.'psr4'.\DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php';
} elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) {
return $fixtureDir.'reallyNotPsr0.php';
} elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) {

View File

@ -647,7 +647,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
* the parameters passed to the container constructor to have precedence
* over the loaded ones.
*
* $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
* $container = new ContainerBuilder(new ParameterBag(['foo' => 'bar']));
* $loader = new LoaderXXX($container);
* $loader->load('resource_name');
* $container->register('foo', 'stdClass');
@ -1288,7 +1288,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*
* Example:
*
* $container->register('foo')->addTag('my.tag', array('hello' => 'world'));
* $container->register('foo')->addTag('my.tag', ['hello' => 'world']);
*
* $serviceIds = $container->findTaggedServiceIds('my.tag');
* foreach ($serviceIds as $serviceId => $tags) {

View File

@ -33,16 +33,16 @@ interface ServiceSubscriberInterface
*
* For mandatory dependencies:
*
* * array('logger' => 'Psr\Log\LoggerInterface') means the objects use the "logger" name
* * ['logger' => 'Psr\Log\LoggerInterface'] means the objects use the "logger" name
* internally to fetch a service which must implement Psr\Log\LoggerInterface.
* * array('Psr\Log\LoggerInterface') is a shortcut for
* * array('Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface')
* * ['Psr\Log\LoggerInterface'] is a shortcut for
* * ['Psr\Log\LoggerInterface' => 'Psr\Log\LoggerInterface']
*
* otherwise:
*
* * array('logger' => '?Psr\Log\LoggerInterface') denotes an optional dependency
* * array('?Psr\Log\LoggerInterface') is a shortcut for
* * array('Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface')
* * ['logger' => '?Psr\Log\LoggerInterface'] denotes an optional dependency
* * ['?Psr\Log\LoggerInterface'] is a shortcut for
* * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
*
* @return array The required service types, optionally keyed by service names
*/

View File

@ -626,7 +626,7 @@ class Crawler implements \Countable, \IteratorAggregate
*
* Example:
*
* $crawler->filter('h1 a')->extract(array('_text', 'href'));
* $crawler->filter('h1 a')->extract(['_text', 'href']);
*
* @param array $attributes An array of attributes
*

View File

@ -133,7 +133,7 @@ class FormFieldRegistry
/**
* Returns the list of field with their value.
*
* @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value)
* @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value)
*/
public function all()
{
@ -167,7 +167,7 @@ class FormFieldRegistry
* @param string $base The name of the base field
* @param array $output The initial values
*
* @return array The list of fields as array((string) Fully qualified name => (mixed) value)
* @return array The list of fields as [string] Fully qualified name => (mixed) value)
*/
private function walk(array $array, $base = '', array &$output = [])
{
@ -186,7 +186,7 @@ class FormFieldRegistry
/**
* Splits a field name into segments as a web browser would do.
*
* getSegments('base[foo][3][]') = array('base', 'foo, '3', '');
* getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
*
* @param string $name The name of the field
*

View File

@ -67,7 +67,7 @@ class ContainerAwareEventDispatcher extends EventDispatcher
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use EventDispatcher with closure factories instead.', __CLASS__), E_USER_DEPRECATED);
if (!\is_array($callback) || 2 !== \count($callback)) {
throw new \InvalidArgumentException('Expected an array("service", "method") argument');
throw new \InvalidArgumentException('Expected an ["service", "method"] argument');
}
$this->listenerIds[$eventName][] = [$callback[0], $callback[1], $priority];

View File

@ -36,9 +36,9 @@ interface EventSubscriberInterface
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2')))
* * ['eventName' => 'methodName']
* * ['eventName' => ['methodName', $priority]]
* * ['eventName' => [['methodName1', $priority], ['methodName2']]]
*
* @return array The event names to listen to
*/

View File

@ -730,7 +730,7 @@ class Filesystem
}
/**
* Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
* Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> [file, tmp]).
*
* @param string $filename The filename to be parsed
*

View File

@ -18,7 +18,7 @@ namespace Symfony\Component\Finder;
*
* // prints foo.bar and foo.baz
* $regex = glob_to_regex("foo.*");
* for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
* for (['foo.bar', 'foo.baz', 'foo', 'bar'] as $t)
* {
* if (/$regex/) echo "matched: $car\n";
* }

View File

@ -48,19 +48,19 @@ interface ChoiceListInterface
* keys of the choices. If the original array contained nested arrays, these
* nested arrays are represented here as well:
*
* $form->add('field', 'choice', array(
* 'choices' => array(
* 'Decided' => array('Yes' => true, 'No' => false),
* 'Undecided' => array('Maybe' => null),
* ),
* ));
* $form->add('field', 'choice', [
* 'choices' => [
* 'Decided' => ['Yes' => true, 'No' => false],
* 'Undecided' => ['Maybe' => null],
* ],
* ]);
*
* In this example, the result of this method is:
*
* array(
* 'Decided' => array('Yes' => '0', 'No' => '1'),
* 'Undecided' => array('Maybe' => '2'),
* )
* [
* 'Decided' => ['Yes' => '0', 'No' => '1'],
* 'Undecided' => ['Maybe' => '2'],
* ]
*
* @return string[] The choice values
*/
@ -73,12 +73,12 @@ interface ChoiceListInterface
* "choice" option of the choice type. Note that this array may contain
* duplicates if the "choice" option contained choice groups:
*
* $form->add('field', 'choice', array(
* 'choices' => array(
* 'Decided' => array(true, false),
* 'Undecided' => array(null),
* ),
* ));
* $form->add('field', 'choice', [
* 'choices' => [
* 'Decided' => [true, false],
* 'Undecided' => [null],
* ],
* ]);
*
* In this example, the original key 0 appears twice, once for `true` and
* once for `null`.

View File

@ -26,9 +26,9 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
* ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType')
* ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType')
* ->add('color', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array(
* 'choices' => array('Red' => 'r', 'Blue' => 'b'),
* ))
* ->add('color', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [
* 'choices' => ['Red' => 'r', 'Blue' => 'b'],
* ])
* ->getForm();
*
* You can also add custom extensions to the form factory:
@ -68,9 +68,9 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new TemplatingExtension($engine, null, array(
* ->addExtension(new TemplatingExtension($engine, null, [
* 'FrameworkBundle:Form',
* )))
* ]))
* ->getFormFactory();
*
* The next example shows how to include the "<table>" layout:
@ -78,10 +78,10 @@ use Symfony\Component\Form\Extension\Core\CoreExtension;
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
*
* $formFactory = Forms::createFormFactoryBuilder()
* ->addExtension(new TemplatingExtension($engine, null, array(
* ->addExtension(new TemplatingExtension($engine, null, [
* 'FrameworkBundle:Form',
* 'FrameworkBundle:FormTable',
* )))
* ]))
* ->getFormFactory();
*
* @author Bernhard Schussek <bschussek@gmail.com>

View File

@ -41,8 +41,8 @@ class DateTimeToStringTransformerTest extends TestCase
// this will not work as PHP will use actual date to replace missing info
// and after change of date will lookup for closest Wednesday
// i.e. value: 2010-02, PHP value: 2010-02-(today i.e. 20), parsed date: 2010-02-24
//array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'),
//array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'),
//['Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'],
//['Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'],
// different month representations
['Y-n-d', '2010-2-03', '2010-02-03 00:00:00 UTC'],

View File

@ -47,7 +47,7 @@ class StringUtilTest extends TestCase
['0020'],
['00A0'],
['1680'],
// array('180E'),
// ['180E'],
['2000'],
['2001'],
['2002'],
@ -72,7 +72,7 @@ class StringUtilTest extends TestCase
['000D'],
['0085'],
// zero width space
// array('200B'),
// ['200B'],
];
}

View File

@ -36,7 +36,7 @@ class FormUtil
*/
public static function isEmpty($data)
{
// Should not do a check for array() === $data!!!
// Should not do a check for [] === $data!!!
// This method is used in occurrences where arrays are
// not considered to be empty, ever.
return null === $data || '' === $data;

View File

@ -161,7 +161,7 @@ class PdoSessionHandler extends AbstractSessionHandler
* * db_time_col: The column where to store the timestamp [default: sess_time]
* * db_username: The username when lazy-connect [default: '']
* * db_password: The password when lazy-connect [default: '']
* * db_connection_options: An array of driver-specific connection options [default: array()]
* * db_connection_options: An array of driver-specific connection options [default: []]
* * lock_mode: The strategy for locking, see constants [default: LOCK_TRANSACTIONAL]
*
* @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or URL string or null

View File

@ -331,7 +331,7 @@ class NativeSessionStorage implements SessionStorageInterface
* For convenience we omit 'session.' from the beginning of the keys.
* Explicitly ignores other ini keys.
*
* @param array $options Session ini directives array(key => value)
* @param array $options Session ini directives [key => value]
*
* @see http://php.net/session.configuration
*/

View File

@ -576,7 +576,7 @@ class ResponseTest extends ResponseTestCase
public function testSetCache()
{
$response = new Response();
//array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public')
// ['etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public']
try {
$response->setCache(['wrong option' => 'value']);
$this->fail('->setCache() throws an InvalidArgumentException if an option is not supported');

View File

@ -216,7 +216,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
}
if (2 !== \count($callable)) {
return 'Invalid format for controller, expected array(controller, method) or controller::method.';
return 'Invalid format for controller, expected [controller, method] or controller::method.';
}
list($controller, $method) = $callable;

View File

@ -149,9 +149,9 @@ class InflectorTest extends TestCase
['SubTrees', ['SubTre', 'SubTree']],
// Known issues
//array('insignia', 'insigne'),
//array('insignias', 'insigne'),
//array('rattles', 'rattle'),
//['insignia', 'insigne'],
//['insignias', 'insigne'],
//['rattles', 'rattle'],
];
}

View File

@ -35,7 +35,7 @@ interface BundleEntryReaderInterface extends BundleReaderInterface
*
* Then the value can be read by calling:
*
* $reader->readEntry('...', 'en', array('TopLevel', 'NestedLevel', 'Entry'));
* $reader->readEntry('...', 'en', ['TopLevel', 'NestedLevel', 'Entry']);
*
* @param string $path The path to the resource bundle
* @param string $locale The locale to read

View File

@ -439,7 +439,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
return [
[1.121, '1.12'],
[1.123, '1.12'],
// array(1.125, '1.13'),
// [1.125, '1.13'],
[1.127, '1.13'],
[1.129, '1.13'],
[1020 / 100, '10.20'],

View File

@ -64,7 +64,7 @@ class PhpProcess extends Process
/**
* {@inheritdoc}
*/
public function start(callable $callback = null/*, array $env = array()*/)
public function start(callable $callback = null/*, array $env = []*/)
{
if (null === $this->getCommandLine()) {
throw new RuntimeException('Unable to find the PHP executable.');

View File

@ -204,7 +204,7 @@ class Process implements \IteratorAggregate
*
* @final since version 3.3
*/
public function run($callback = null/*, array $env = array()*/)
public function run($callback = null/*, array $env = []*/)
{
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
$this->start($callback, $env);
@ -228,7 +228,7 @@ class Process implements \IteratorAggregate
*
* @final since version 3.3
*/
public function mustRun(callable $callback = null/*, array $env = array()*/)
public function mustRun(callable $callback = null/*, array $env = []*/)
{
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
@ -262,7 +262,7 @@ class Process implements \IteratorAggregate
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
*/
public function start(callable $callback = null/*, array $env = array()*/)
public function start(callable $callback = null/*, array $env = [*/)
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running');
@ -378,7 +378,7 @@ class Process implements \IteratorAggregate
*
* @final since version 3.3
*/
public function restart(callable $callback = null/*, array $env = array()*/)
public function restart(callable $callback = null/*, array $env = []*/)
{
if ($this->isRunning()) {
throw new RuntimeException('Process is already running');

View File

@ -1164,8 +1164,8 @@ class ProcessTest extends TestCase
{
return [
//expected output / getter / code to execute
//array(1,'getExitCode','exit(1);'),
//array(true,'isSuccessful','exit();'),
//[1,'getExitCode','exit(1);'],
//[true,'isSuccessful','exit();'],
['output', 'getOutput', 'echo \'output\';'],
];
}

View File

@ -41,7 +41,7 @@ CHANGELOG
Before:
```php
$router->generate('blog_show', array('slug' => 'my-blog-post'), true);
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
```
After:
@ -49,7 +49,7 @@ CHANGELOG
```php
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
$router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
$router->generate('blog_show', ['slug' => 'my-blog-post'], UrlGeneratorInterface::ABSOLUTE_URL);
```
2.5.0
@ -114,7 +114,7 @@ CHANGELOG
```php
$route = new Route();
$route->setPath('/article/{id}');
$route->setMethods(array('POST', 'PUT'));
$route->setMethods(['POST', 'PUT']);
$route->setSchemes('https');
```
@ -169,10 +169,10 @@ CHANGELOG
used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
will still work, but have been deprecated. The `addPrefix` method should be used for this
use-case instead.
Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
Before: `$parentCollection->addCollection($collection, '/prefix', [...], [...])`
After:
```php
$collection->addPrefix('/prefix', array(...), array(...));
$collection->addPrefix('/prefix', [...], [...]);
$parentCollection->addCollection($collection);
```
* added support for the method default argument values when defining a @Route
@ -197,7 +197,7 @@ CHANGELOG
(only relevant if you implemented your own RouteCompiler).
* Added possibility to generate relative paths and network paths in the UrlGenerator, e.g.
"../parent-file" and "//example.com/dir/file". The third parameter in
`UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)`
`UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)`
now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for
claritiy. The old method calls with a Boolean parameter will continue to work because they
equal the signature using the constants.

View File

@ -76,7 +76,7 @@ EOF;
*/
private function generateDeclaredRoutes()
{
$routes = "array(\n";
$routes = "[\n";
foreach ($this->getRoutes()->all() as $name => $route) {
$compiledRoute = $route->compile();
@ -90,7 +90,7 @@ EOF;
$routes .= sprintf(" '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
}
$routes .= ' )';
$routes .= ' ]';
return $routes;
}
@ -103,7 +103,7 @@ EOF;
private function generateGenerateMethod()
{
return <<<'EOF'
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
if (!isset(self::$declaredRoutes[$name])) {
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));

View File

@ -154,7 +154,7 @@ class RouteCompiler implements RouteCompilerInterface
// Find the next static character after the variable that functions as a separator. By default, this separator and '/'
// are disallowed for the variable. This default requirement makes sure that optional variables can be matched at all
// and that the generating-matching-combination of URLs unambiguous, i.e. the params used for generating the URL are
// the same that will be matched. Example: new Route('/{page}.{_format}', array('_format' => 'html'))
// the same that will be matched. Example: new Route('/{page}.{_format}', ['_format' => 'html'])
// If {page} would also match the separating dot, {_format} would never match as {page} will eagerly consume everything.
// Also even if {_format} was not optional the requirement prevents that {page} matches something that was originally
// part of {_format} when generating the URL, e.g. _format = 'mobile.html'.

View File

@ -153,7 +153,7 @@ class RouteTest extends TestCase
public function testScheme()
{
$route = new Route('/');
$this->assertEquals([], $route->getSchemes(), 'schemes is initialized with array()');
$this->assertEquals([], $route->getSchemes(), 'schemes is initialized with []');
$this->assertFalse($route->hasScheme('http'));
$route->setSchemes('hTTp');
$this->assertEquals(['http'], $route->getSchemes(), '->setSchemes() accepts a single scheme string and lowercases it');
@ -168,7 +168,7 @@ class RouteTest extends TestCase
public function testMethod()
{
$route = new Route('/');
$this->assertEquals([], $route->getMethods(), 'methods is initialized with array()');
$this->assertEquals([], $route->getMethods(), 'methods is initialized with []');
$route->setMethods('gEt');
$this->assertEquals(['GET'], $route->getMethods(), '->setMethods() accepts a single method string and uppercases it');
$route->setMethods(['gEt', 'PosT']);

View File

@ -38,7 +38,7 @@ interface UserInterface
*
* public function getRoles()
* {
* return array('ROLE_USER');
* return ['ROLE_USER'];
* }
*
* Alternatively, the roles might be stored on a ``roles`` property,

View File

@ -44,14 +44,14 @@ interface AuthenticatorInterface extends GuardAuthenticatorInterface
*
* For example, for a form login, you might:
*
* return array(
* return [
* 'username' => $request->request->get('_username'),
* 'password' => $request->request->get('_password'),
* );
* ];
*
* Or for an API token that's on a header, you might use:
*
* return array('api_key' => $request->headers->get('X-API-TOKEN'));
* return ['api_key' => $request->headers->get('X-API-TOKEN')];
*
* @param Request $request
*

View File

@ -43,17 +43,17 @@ interface GuardAuthenticatorInterface extends AuthenticationEntryPointInterface
* For example, for a form login, you might:
*
* if ($request->request->has('_username')) {
* return array(
* return [
* 'username' => $request->request->get('_username'),
* 'password' => $request->request->get('_password'),
* );
* ];
* } else {
* return;
* }
*
* Or for an API token that's on a header, you might use:
*
* return array('api_key' => $request->headers->get('X-API-TOKEN'));
* return ['api_key' => $request->headers->get('X-API-TOKEN')];
*
* @param Request $request
*

View File

@ -30,7 +30,7 @@ interface FirewallMapInterface
* If there is no exception listener, the second element of the outer array
* must be null.
*
* @return array of the format array(array(AuthenticationListener), ExceptionListener)
* @return array of the format [[AuthenticationListener], ExceptionListener]
*/
public function getListeners(Request $request);
}

View File

@ -43,7 +43,7 @@ class ChainDecoder implements DecoderInterface /*, ContextAwareDecoderInterface*
/**
* {@inheritdoc}
*/
public function supportsDecoding($format/*, array $context = array()*/)
public function supportsDecoding($format/*, array $context = []*/)
{
$context = \func_num_args() > 1 ? func_get_arg(1) : [];

View File

@ -43,7 +43,7 @@ class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*
/**
* {@inheritdoc}
*/
public function supportsEncoding($format/*, array $context = array()*/)
public function supportsEncoding($format/*, array $context = []*/)
{
$context = \func_num_args() > 1 ? func_get_arg(1) : [];
@ -64,7 +64,7 @@ class ChainEncoder implements EncoderInterface /*, ContextAwareEncoderInterface*
*
* @return bool
*/
public function needsNormalization($format/*, array $context = array()*/)
public function needsNormalization($format/*, array $context = []*/)
{
$context = \func_num_args() > 1 ? func_get_arg(1) : [];
$encoder = $this->getEncoder($format, $context);

View File

@ -396,7 +396,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
/*
* Create nodes to append to $parentNode based on the $key of this array
* Produces <xml><item>0</item><item>1</item></xml>
* From array("item" => array(0,1));.
* From ["item" => [0,1]];.
*/
foreach ($data as $subData) {
$append = $this->appendNode($parentNode, $subData, $key);

View File

@ -66,7 +66,7 @@ class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterfa
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
public function supportsDenormalization($data, $type, $format = null/*, array $context = []*/)
{
$context = \func_num_args() > 3 ? func_get_arg(3) : [];

View File

@ -188,7 +188,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null/*, array $context = array()*/)
public function supportsNormalization($data, $format = null/*, array $context = []*/)
{
if (\func_num_args() > 2) {
$context = \func_get_arg(2);
@ -196,7 +196,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
if (__CLASS__ !== \get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s()" method will have a third `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have a third `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}
@ -209,7 +209,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null/*, array $context = array()*/)
public function supportsDenormalization($data, $type, $format = null/*, array $context = []*/)
{
if (\func_num_args() > 3) {
$context = \func_get_arg(3);
@ -217,7 +217,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
if (__CLASS__ !== \get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s()" method will have a fourth `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have a fourth `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}
@ -283,7 +283,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
/**
* {@inheritdoc}
*/
public function supportsEncoding($format/*, array $context = array()*/)
public function supportsEncoding($format/*, array $context = []*/)
{
if (\func_num_args() > 1) {
$context = \func_get_arg(1);
@ -291,7 +291,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
if (__CLASS__ !== \get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s()" method will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}
@ -304,7 +304,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
/**
* {@inheritdoc}
*/
public function supportsDecoding($format/*, array $context = array()*/)
public function supportsDecoding($format/*, array $context = []*/)
{
if (\func_num_args() > 1) {
$context = \func_get_arg(1);
@ -312,7 +312,7 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz
if (__CLASS__ !== \get_class($this)) {
$r = new \ReflectionMethod($this, __FUNCTION__);
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('The "%s()" method will have a second `$context = array()` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
}
}

View File

@ -40,19 +40,19 @@ abstract class AbstractOperation implements OperationInterface
*
* The data structure of this array is as follows:
*
* array(
* 'domain 1' => array(
* 'all' => array(...),
* 'new' => array(...),
* 'obsolete' => array(...)
* ),
* 'domain 2' => array(
* 'all' => array(...),
* 'new' => array(...),
* 'obsolete' => array(...)
* ),
* [
* 'domain 1' => [
* 'all' => [...],
* 'new' => [...],
* 'obsolete' => [...]
* ],
* 'domain 2' => [
* 'all' => [...],
* 'new' => [...],
* 'obsolete' => [...]
* ],
* ...
* )
* ]
*
* @var array The array that stores 'all', 'new' and 'obsolete' messages
*/

View File

@ -36,7 +36,7 @@ class ArrayLoader implements LoaderInterface
* Flattens an nested array of translations.
*
* The scheme used is:
* 'key' => array('key2' => array('key3' => 'value'))
* 'key' => ['key2' => ['key3' => 'value']]
* Becomes:
* 'key.key2.key3' => 'value'
*

View File

@ -27,7 +27,7 @@ class ArrayConverter
{
/**
* Converts linear messages array to tree-like array.
* For example this rray('foo.bar' => 'value') will be converted to array('foo' => array('bar' => 'value')).
* For example this rray('foo.bar' => 'value') will be converted to ['foo' => ['bar' => 'value']].
*
* @param array $messages Linear messages array
*

View File

@ -17,7 +17,7 @@ namespace Symfony\Component\Validator\Constraints;
* When validating a group sequence, each group will only be validated if all
* of the previous groups in the sequence succeeded. For example:
*
* $validator->validate($address, null, new GroupSequence(array('Basic', 'Strict')));
* $validator->validate($address, null, new GroupSequence(['Basic', 'Strict']));
*
* In the first step, all constraints that belong to the group "Basic" will be
* validated. If none of the constraints fail, the validator will then validate

View File

@ -97,7 +97,7 @@ interface ExecutionContextInterface
* {
* $validator = $this->context->getValidator();
*
* $violations = $validator->validate($value, new Length(array('min' => 3)));
* $violations = $validator->validate($value, new Length(['min' => 3]));
*
* if (count($violations) > 0) {
* // ...

View File

@ -372,7 +372,7 @@ EOTXT
$cloner->addCasters([
':stream' => eval('return function () use ($twig) {
try {
$twig->render(array());
$twig->render([]);
} catch (\Twig\Error\RuntimeError $e) {
throw $e->getPrevious();
}