This commit is contained in:
Fabien Potencier 2019-01-16 19:56:49 +01:00
parent d58b5c3b76
commit 44056b002a
27 changed files with 257 additions and 256 deletions

View File

@ -92,7 +92,7 @@ Console
```php
$commandTester = new CommandTester($command);
$commandTester->setInputs(array('AppBundle', 'Yes'));
$commandTester->setInputs(['AppBundle', 'Yes']);
$commandTester->execute();
```
@ -343,23 +343,23 @@ Form
Before:
```php
$builder->add('custom_locales', LocaleType::class, array(
$builder->add('custom_locales', LocaleType::class, [
'choices' => $availableLocales,
));
]);
```
After:
```php
$builder->add('custom_locales', LocaleType::class, array(
$builder->add('custom_locales', LocaleType::class, [
'choices' => $availableLocales,
'choice_loader' => null,
));
]);
// or
$builder->add('custom_locales', LocaleType::class, array(
$builder->add('custom_locales', LocaleType::class, [
'choice_loader' => new CallbackChoiceLoader(function () {
return $this->getAvailableLocales();
}),
));
]);
```
* Removed `ChoiceLoaderInterface` implementation in `TimezoneType`. Use the "choice_loader" option instead.
@ -844,7 +844,7 @@ TwigBridge
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)));
```
@ -852,12 +852,12 @@ TwigBridge
After:
```php
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
$rendererEngine = new TwigRendererEngine(['form_div_layout.html.twig'], $twig);
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader([
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},
)));
]));
$twig->addExtension(new FormExtension());
```
@ -1092,13 +1092,13 @@ Yaml
Before:
```php
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, true);
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, true);
```
After:
```php
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
```
* Removed support for passing `true`/`false` as the fifth argument to the
@ -1107,13 +1107,13 @@ Yaml
Before:
```php
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, false, true);
```
After:
```php
Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, Yaml::DUMP_OBJECT);
Yaml::dump(['foo' => new A(), 'bar' => 1], 0, 0, false, Yaml::DUMP_OBJECT);
```
* The `!!php/object` tag to indicate dumped PHP objects was removed in favor of

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

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

View File

@ -290,7 +290,7 @@ abstract class Client
*
* @return Crawler
*/
public function submit(Form $form, array $values = []/*, array $serverParameters = array()*/)
public function submit(Form $form, array $values = []/*, array $serverParameters = []*/)
{
$form->setValues($values);
$serverParameters = 2 < \func_num_args() ? func_get_arg(2) : [];

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
*

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
*

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 */'];
@ -130,7 +130,7 @@ EOPHP;
yield [1, 11, 'public function pub($arg = null): Foo {}'];
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

@ -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

@ -27,14 +27,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);
}
@ -136,20 +136,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()
@ -166,10 +166,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);
}
@ -188,10 +188,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);
}
@ -210,17 +210,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. 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);
@ -229,10 +229,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. 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);
}
@ -251,12 +251,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);
@ -265,17 +265,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. 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. 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);
@ -284,7 +284,7 @@ class DebugClassLoaderTest extends TestCase
error_reporting($e);
restore_error_handler();
$this->assertSame(array(), $deprecations);
$this->assertSame([], $deprecations);
}
}
@ -296,7 +296,7 @@ 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)

View File

@ -616,7 +616,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');
@ -1243,7 +1243,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

@ -223,11 +223,11 @@ EOF;
}
if ($ids = array_keys($ids)) {
sort($ids);
$c = "<?php\n\nreturn array(\n";
$c = "<?php\n\nreturn [\n";
foreach ($ids as $id) {
$c .= ' '.$this->doExport($id)." => true,\n";
}
$files['removed-ids.php'] = $c .= ");\n";
$files['removed-ids.php'] = $c .= "];\n";
}
foreach ($this->generateServiceFiles() as $file => $c) {
@ -266,11 +266,11 @@ if (!\\class_exists({$options['class']}::class, false)) {
\\class_alias(\\Container{$hash}\\{$options['class']}::class, {$options['class']}::class, false);
}
return new \\Container{$hash}\\{$options['class']}(array(
return new \\Container{$hash}\\{$options['class']}([
'container.build_hash' => '$hash',
'container.build_id' => '$id',
'container.build_time' => $time,
), __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
], __DIR__.\\DIRECTORY_SEPARATOR.'Container{$hash}');
EOF;
} else {
@ -913,12 +913,12 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
class $class extends $baseClass
{
private \$parameters;
private \$targetDirs = array();
private \$targetDirs = [];
/*{$this->docStar}
* @internal but protected for BC on cache:clear
*/
protected \$privates = array();
protected \$privates = [];
public function __construct()
{
@ -936,7 +936,7 @@ EOF;
}
if ($this->asFiles) {
$code = str_replace('$parameters', "\$buildParameters;\n private \$containerDir;\n private \$parameters", $code);
$code = str_replace('__construct()', '__construct(array $buildParameters = array(), $containerDir = __DIR__)', $code);
$code = str_replace('__construct()', '__construct(array $buildParameters = [], $containerDir = __DIR__)', $code);
$code .= " \$this->buildParameters = \$buildParameters;\n";
$code .= " \$this->containerDir = \$containerDir;\n";
}
@ -956,7 +956,7 @@ EOF;
if ($this->container->getParameterBag()->all()) {
$code .= " \$this->parameters = \$this->getDefaultParameters();\n\n";
}
$code .= " \$this->services = \$this->privates = array();\n";
$code .= " \$this->services = \$this->privates = [];\n";
$code .= $this->addSyntheticIds();
$code .= $this->addMethodMap();
@ -968,7 +968,7 @@ EOF;
public function reset()
{
\$this->privates = array();
\$this->privates = [];
parent::reset();
}
@ -1036,7 +1036,7 @@ EOF;
}
}
return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : '';
return $code ? " \$this->syntheticIds = [\n{$code} ];\n" : '';
}
private function addRemovedIds(): string
@ -1063,7 +1063,7 @@ EOF;
$code .= ' '.$this->doExport($id)." => true,\n";
}
$code = "array(\n{$code} )";
$code = "[\n{$code} ]";
}
return <<<EOF
@ -1087,7 +1087,7 @@ EOF;
}
}
return $code ? " \$this->methodMap = array(\n{$code} );\n" : '';
return $code ? " \$this->methodMap = [\n{$code} ];\n" : '';
}
private function addFileMap(): string
@ -1101,16 +1101,16 @@ EOF;
}
}
return $code ? " \$this->fileMap = array(\n{$code} );\n" : '';
return $code ? " \$this->fileMap = [\n{$code} ];\n" : '';
}
private function addAliases(): string
{
if (!$aliases = $this->container->getAliases()) {
return "\n \$this->aliases = array();\n";
return "\n \$this->aliases = [];\n";
}
$code = " \$this->aliases = array(\n";
$code = " \$this->aliases = [\n";
ksort($aliases);
foreach ($aliases as $alias => $id) {
$id = (string) $id;
@ -1120,7 +1120,7 @@ EOF;
$code .= ' '.$this->doExport($alias).' => '.$this->doExport($id).",\n";
}
return $code." );\n";
return $code." ];\n";
}
private function addInlineRequires(): string
@ -1168,7 +1168,7 @@ EOF;
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
}
$export = $this->exportParameters([$value]);
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);
if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDirs\[\d++\])/", $export[1])) {
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
@ -1176,7 +1176,8 @@ EOF;
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
}
}
$parameters = sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', 8));
$parameters = sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', 8));
$code = <<<'EOF'
@ -1246,14 +1247,14 @@ EOF;
EOF;
$getDynamicParameter = sprintf($getDynamicParameter, implode("\n", $dynamicPhp));
} else {
$loadedDynamicParameters = 'array()';
$loadedDynamicParameters = '[]';
$getDynamicParameter = str_repeat(' ', 8).'throw new InvalidArgumentException(sprintf(\'The dynamic parameter "%s" must be defined.\', $name));';
}
$code .= <<<EOF
private \$loadedDynamicParameters = {$loadedDynamicParameters};
private \$dynamicParameters = array();
private \$dynamicParameters = [];
/*{$this->docStar}
* Computes a dynamic parameter.
@ -1310,7 +1311,7 @@ EOF;
$php[] = sprintf('%s%s => %s,', str_repeat(' ', $indent), $this->export($key), $value);
}
return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4));
return sprintf("[\n%s\n%s]", implode("\n", $php), str_repeat(' ', $indent - 4));
}
private function endClass(): string
@ -1404,7 +1405,7 @@ EOF;
$code[] = sprintf('%s => %s', $this->dumpValue($k, $interpolate), $this->dumpValue($v, $interpolate));
}
return sprintf('array(%s)', implode(', ', $code));
return sprintf('[%s]', implode(', ', $code));
} elseif ($value instanceof ArgumentInterface) {
$scope = [$this->definitionVariables, $this->referenceVariables];
$this->definitionVariables = $this->referenceVariables = null;

View File

@ -361,7 +361,7 @@ interface DecoratorInterface
class Decorated implements DecoratorInterface
{
public function __construct($quz = null, \NonExistent $nonExistent = null, DecoratorInterface $decorated = null, array $foo = array())
public function __construct($quz = null, \NonExistent $nonExistent = null, DecoratorInterface $decorated = null, array $foo = [])
{
}
}

View File

@ -2,7 +2,7 @@ Array
(
[Container%s/removed-ids.php] => <?php
return array(
return [
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'configurator_service' => true,
@ -14,7 +14,7 @@ return array(
'inlined' => true,
'new_factory' => true,
'tagged_iterator_foo' => true,
);
];
[Container%s/getBAR2Service.php] => <?php
@ -179,11 +179,11 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException;
$a = ($this->services['foo.baz'] ?? $this->load('getFoo_BazService.php'));
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, array('bar' => 'foo is bar', 'foobar' => 'bar'), true, $this);
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, ['bar' => 'foo is bar', 'foobar' => 'bar'], true, $this);
$instance->foo = 'bar';
$instance->moo = $a;
$instance->qux = array('bar' => 'foo is bar', 'foobar' => 'bar');
$instance->qux = ['bar' => 'foo is bar', 'foobar' => 'bar'];
$instance->setBar(($this->services['bar'] ?? $this->getBarService()));
$instance->initialize();
sc_configure($instance);
@ -383,14 +383,14 @@ class ProjectServiceContainer extends Container
private $buildParameters;
private $containerDir;
private $parameters;
private $targetDirs = array();
private $targetDirs = [];
/**
* @internal but protected for BC on cache:clear
*/
protected $privates = array();
protected $privates = [];
public function __construct(array $buildParameters = array(), $containerDir = __DIR__)
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
@ -400,14 +400,14 @@ class ProjectServiceContainer extends Container
$this->containerDir = $containerDir;
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = array();
$this->syntheticIds = array(
$this->services = $this->privates = [];
$this->syntheticIds = [
'request' => true,
);
$this->methodMap = array(
];
$this->methodMap = [
'bar' => 'getBarService',
);
$this->fileMap = array(
];
$this->fileMap = [
'BAR' => 'getBAR2Service.php',
'BAR2' => 'getBAR22Service.php',
'bar2' => 'getBar23Service.php',
@ -431,17 +431,17 @@ class ProjectServiceContainer extends Container
'runtime_error' => 'getRuntimeErrorService.php',
'service_from_static_method' => 'getServiceFromStaticMethodService.php',
'tagged_iterator' => 'getTaggedIteratorService.php',
);
$this->aliases = array(
];
$this->aliases = [
'alias_for_alias' => 'foo',
'alias_for_foo' => 'foo',
'decorated' => 'decorator_service_with_name',
);
];
}
public function reset()
{
$this->privates = array();
$this->privates = [];
parent::reset();
}
@ -529,8 +529,8 @@ class ProjectServiceContainer extends Container
return $this->parameterBag;
}
private $loadedDynamicParameters = array();
private $dynamicParameters = array();
private $loadedDynamicParameters = [];
private $dynamicParameters = [];
/**
* Computes a dynamic parameter.
@ -553,11 +553,11 @@ class ProjectServiceContainer extends Container
*/
protected function getDefaultParameters()
{
return array(
return [
'baz_class' => 'BazClass',
'foo_class' => 'Bar\\FooClass',
'foo' => 'bar',
);
];
}
}
@ -577,10 +577,10 @@ if (!\class_exists(ProjectServiceContainer::class, false)) {
\class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
}
return new \Container%s\ProjectServiceContainer(array(
return new \Container%s\ProjectServiceContainer([
'container.build_hash' => '%s',
'container.build_id' => '%s',
'container.build_time' => %d,
), __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
)

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

@ -727,7 +727,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]).
*/
private function getSchemeAndHierarchy(string $filename): array
{

View File

@ -31,7 +31,7 @@ class HeaderUtils
* Example:
*
* HeaderUtils::split("da, en-gb;q=0.8", ",;")
* // => array(array('da'), array('en-gb', 'q=0.8'))
* // => ['da'], ['en-gb', 'q=0.8']]
*
* @param string $header HTTP header value
* @param string $separators List of characters to split on, ordered by
@ -75,8 +75,8 @@ class HeaderUtils
*
* Example:
*
* HeaderUtils::combine(array(array("foo", "abc"), array("bar")))
* // => array("foo" => "abc", "bar" => true)
* HeaderUtils::combine([["foo", "abc"], ["bar"]])
* // => ["foo" => "abc", "bar" => true]
*/
public static function combine(array $parts): array
{
@ -99,7 +99,7 @@ class HeaderUtils
*
* Example:
*
* HeaderUtils::toString(array("foo" => "abc", "bar" => true, "baz" => "a b c"), ",")
* HeaderUtils::toString(["foo" => "abc", "bar" => true, "baz" => "a b c"], ",")
* // => 'foo=abc, bar, baz="a b c"'
*/
public static function toString(array $assoc, string $separator): string

View File

@ -328,7 +328,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

@ -155,7 +155,7 @@ class ControllerResolver implements ControllerResolverInterface
}
if (!isset($callable[0]) || !isset($callable[1]) || 2 !== \count($callable)) {
return 'Invalid array callable, expected array(controller, method).';
return 'Invalid array callable, expected [controller, method].';
}
list($controller, $method) = $callable;

View File

@ -189,7 +189,7 @@ class ControllerResolverTest extends TestCase
[[$controller, 'protectedAction'], \InvalidArgumentException::class, 'The controller for URI "/" is not callable. Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'],
[[$controller, 'undefinedAction'], \InvalidArgumentException::class, 'The controller for URI "/" is not callable. Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'],
[$controller, \InvalidArgumentException::class, 'The controller for URI "/" is not callable. Controller class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" cannot be called without a method name. You need to implement "__invoke" or use one of the available methods: "publicAction", "staticAction".'],
[['a' => 'foo', 'b' => 'bar'], \InvalidArgumentException::class, 'The controller for URI "/" is not callable. Invalid array callable, expected array(controller, method).'],
[['a' => 'foo', 'b' => 'bar'], \InvalidArgumentException::class, 'The controller for URI "/" is not callable. Invalid array callable, expected [controller, method].'],
];
}

View File

@ -12,9 +12,9 @@ CHANGELOG
-----
* environment variables will always be inherited
* added a second `array $env = array()` argument to the `start()`, `run()`,
* added a second `array $env = []` argument to the `start()`, `run()`,
`mustRun()`, and `restart()` methods of the `Process` class
* added a second `array $env = array()` argument to the `start()` method of the
* added a second `array $env = []` argument to the `start()` method of the
`PhpProcess` class
* the `ProcessUtils::escapeArgument()` method has been removed
* the `areEnvironmentVariablesInherited()`, `getOptions()`, and `setOptions()`

View File

@ -1133,8 +1133,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

@ -111,7 +111,7 @@ EOF;
$code = <<<EOF
{
\$allow = \$allowSchemes = array();
\$allow = \$allowSchemes = [];
\$pathinfo = rawurldecode(\$pathinfo) ?: '/';
\$trimmedPathinfo = rtrim(\$pathinfo, '/') ?: '/';
\$context = \$this->context;
@ -129,14 +129,14 @@ EOF;
return <<<'EOF'
public function match($pathinfo)
{
$allow = $allowSchemes = array();
$allow = $allowSchemes = [];
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
return $ret;
}
if ($allow) {
throw new MethodNotAllowedException(array_keys($allow));
}
if (!in_array($this->context->getMethod(), array('HEAD', 'GET'), true)) {
if (!in_array($this->context->getMethod(), ['HEAD', 'GET'], true)) {
// no-op
} elseif ($allowSchemes) {
redirect_scheme:
@ -162,10 +162,10 @@ EOF;
throw new ResourceNotFoundException();
}
private function doMatch(string $pathinfo, array &$allow = array(), array &$allowSchemes = array()): array
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
EOF
.$code."\n return array();\n }";
.$code."\n return [];\n }";
}
return " public function match(\$pathinfo)\n".$code."\n throw \$allow ? new MethodNotAllowedException(array_keys(\$allow)) : new ResourceNotFoundException();\n }";
@ -272,7 +272,7 @@ EOF
unset($defaults['_canonical_route']);
}
$default .= sprintf(
"%s => array(%s, %s, %s, %s, %s),\n",
"%s => [%s, %s, %s, %s, %s],\n",
self::export($url),
self::export(['_route' => $name] + $defaults),
self::export(!$route->compile()->getHostVariables() ? $route->getHost() : $route->compile()->getHostRegex() ?: null),
@ -294,8 +294,8 @@ EOF
if ($default) {
$code .= <<<EOF
default:
\$routes = array(
{$this->indent($default, 4)} );
\$routes = [
{$this->indent($default, 4)} ];
if (!isset(\$routes[\$trimmedPathinfo])) {
break;
@ -437,8 +437,8 @@ EOF;
if ($state->default) {
$state->switch .= <<<EOF
default:
\$routes = array(
{$this->indent($state->default, 4)} );
\$routes = [
{$this->indent($state->default, 4)} ];
list(\$ret, \$vars, \$requiredMethods, \$requiredSchemes, \$hasTrailingSlash, \$hasTrailingVar) = \$routes[\$m];
{$this->compileSwitchDefault(true, $matchHost)}
@ -450,8 +450,8 @@ EOF;
return <<<EOF
\$matchedPathinfo = {$matchedPathinfo};
\$regexList = array({$code}
);
\$regexList = [{$code}
];
foreach (\$regexList as \$offset => \$regex) {
while (preg_match(\$regex, \$matchedPathinfo, \$matches)) {
@ -518,7 +518,7 @@ EOF;
unset($defaults['_canonical_route']);
}
$state->default .= sprintf(
"%s => array(%s, %s, %s, %s, %s, %s),\n",
"%s => [%s, %s, %s, %s, %s, %s],\n",
$state->mark,
self::export(['_route' => $name] + $defaults),
self::export($vars),
@ -551,7 +551,7 @@ EOF;
$code = <<<'EOF'
if ('GET' === $canonicalMethod && (!$requiredMethods || isset($requiredMethods['GET']))) {
return $allow = $allowSchemes = array();
return $allow = $allowSchemes = [];
}
EOF;
} else {
@ -699,7 +699,7 @@ EOF;
$code = sprintf($code, <<<'EOF'
if ('GET' === $canonicalMethod) {
return $allow = $allowSchemes = array();
return $allow = $allowSchemes = [];
}
EOF
,
@ -710,11 +710,11 @@ EOF
}
if ($vars) {
$code .= ' $matches = array(';
$code .= ' $matches = [';
foreach ($vars as $j => $m) {
$code .= sprintf('%s => $matches[%d] ?? null, ', self::export($m), 1 + $j);
}
$code = substr_replace($code, ");\n\n", -2);
$code = substr_replace($code, "];\n\n", -2);
}
if ($route->getCondition()) {
@ -755,7 +755,7 @@ EOF;
// optimize parameters array
if ($matches || $hostMatches) {
$vars = ["array('_route' => '$name')"];
$vars = ["['_route' => '$name']"];
if ($matches || ($hostMatches && !$checkHost)) {
$vars[] = '$matches';
}
@ -771,7 +771,7 @@ EOF;
} elseif ($defaults) {
$code .= sprintf(" \$ret = %s;\n", self::export(['_route' => $name] + $defaults));
} else {
$code .= sprintf(" \$ret = array('_route' => '%s');\n", $name);
$code .= sprintf(" \$ret = ['_route' => '%s'];\n", $name);
}
if ($methods) {
@ -865,11 +865,11 @@ EOF;
return str_replace("\n", '\'."\n".\'', var_export($value, true));
}
if (!$value) {
return 'array()';
return '[]';
}
$i = 0;
$export = 'array(';
$export = '[';
foreach ($value as $k => $v) {
if ($i === $k) {
@ -885,6 +885,6 @@ EOF;
$export .= self::export($v).', ';
}
return substr_replace($export, ')', -2);
return substr_replace($export, ']', -2);
}
}

View File

@ -25,7 +25,7 @@ CHANGELOG
* removed the `Serializer::$normalizerCache` and `Serializer::$denormalizerCache`
properties
* added an optional `string $format = null` argument to `AbstractNormalizer::instantiateObject`
* added an optional `array $context = array()` to `Serializer::supportsNormalization`, `Serializer::supportsDenormalization`,
* added an optional `array $context = []` to `Serializer::supportsNormalization`, `Serializer::supportsDenormalization`,
`Serializer::supportsEncoding` and `Serializer::supportsDecoding`
3.4.0

View File

@ -368,7 +368,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
/*
* 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

@ -1,5 +1,5 @@
<?php
return array (
return [
'foo' => 'bar',
);
];

View File

@ -6,7 +6,7 @@ yaml: |
- Sammy Sosa
- Ken Griffey
php: |
array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey')
['Mark McGwire', 'Sammy Sosa', 'Ken Griffey']
---
test: Mapping of scalars to scalars
spec: 2.2
@ -15,7 +15,7 @@ yaml: |
avg: 0.278
rbi: 147
php: |
array('hr' => 65, 'avg' => 0.278, 'rbi' => 147)
['hr' => 65, 'avg' => 0.278, 'rbi' => 147]
---
test: Mapping of scalars to sequences
spec: 2.3
@ -29,13 +29,13 @@ yaml: |
- Chicago Cubs
- Atlanta Braves
php: |
array('american' =>
array( 'Boston Red Sox', 'Detroit Tigers',
'New York Yankees' ),
['american' =>
[ 'Boston Red Sox', 'Detroit Tigers',
'New York Yankees' ],
'national' =>
array( 'New York Mets', 'Chicago Cubs',
'Atlanta Braves' )
)
[ 'New York Mets', 'Chicago Cubs',
'Atlanta Braves' ]
]
---
test: Sequence of mappings
spec: 2.4
@ -49,10 +49,10 @@ yaml: |
hr: 63
avg: 0.288
php: |
array(
array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278),
array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288)
)
[
['name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278],
['name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288]
]
---
test: Legacy A5
todo: true
@ -134,11 +134,11 @@ yaml: |
- [ Mark McGwire , 65 , 0.278 ]
- [ Sammy Sosa , 63 , 0.288 ]
php: |
array(
array( 'name', 'hr', 'avg' ),
array( 'Mark McGwire', 65, 0.278 ),
array( 'Sammy Sosa', 63, 0.288 )
)
[
[ 'name', 'hr', 'avg' ],
[ 'Mark McGwire', 65, 0.278 ],
[ 'Sammy Sosa', 63, 0.288 ]
]
---
test: Mapping of mappings
todo: true
@ -150,12 +150,12 @@ yaml: |
avg: 0.288
}
php: |
array(
[
'Mark McGwire' =>
array( 'hr' => 65, 'avg' => 0.278 ),
[ 'hr' => 65, 'avg' => 0.278 ],
'Sammy Sosa' =>
array( 'hr' => 63, 'avg' => 0.288 )
)
[ 'hr' => 63, 'avg' => 0.288 ]
]
---
test: Two documents in a stream each with a leading comment
todo: true
@ -208,10 +208,10 @@ yaml: |
- Sammy Sosa
- Ken Griffey
php: |
array(
'hr' => array( 'Mark McGwire', 'Sammy Sosa' ),
'rbi' => array( 'Sammy Sosa', 'Ken Griffey' )
)
[
'hr' => [ 'Mark McGwire', 'Sammy Sosa' ],
'rbi' => [ 'Sammy Sosa', 'Ken Griffey' ]
]
---
test: Node for Sammy Sosa appears twice in this document
spec: 2.10
@ -225,12 +225,12 @@ yaml: |
- *SS # Subsequent occurrence
- Ken Griffey
php: |
array(
[
'hr' =>
array('Mark McGwire', 'Sammy Sosa'),
['Mark McGwire', 'Sammy Sosa'],
'rbi' =>
array('Sammy Sosa', 'Ken Griffey')
)
['Sammy Sosa', 'Ken Griffey']
]
---
test: Mapping between sequences
todo: true
@ -297,20 +297,20 @@ yaml: |
- item : Big Shoes
quantity: 1
php: |
array (
array (
[
[
'item' => 'Super Hoop',
'quantity' => 1,
),
array (
],
[
'item' => 'Basketball',
'quantity' => 4,
),
array (
],
[
'item' => 'Big Shoes',
'quantity' => 1,
)
)
]
]
perl: |
[
{ item => 'Super Hoop', quantity => 1 },
@ -462,11 +462,11 @@ yaml: |
65 Home Runs
0.278 Batting Average
php: |
array(
[
'name' => 'Mark McGwire',
'accomplishment' => "Mark set a major league home run record in 1998.\n",
'stats' => "65 Home Runs\n0.278 Batting Average\n"
)
]
---
test: Quoted scalars
todo: true
@ -512,11 +512,11 @@ yaml: |
octal: 014
hexadecimal: 0xC
php: |
array(
[
'canonical' => 12345,
'octal' => 014,
'hexadecimal' => 0xC
)
]
---
# FIX: spec shows parens around -inf and NaN
test: Floating point
@ -528,13 +528,13 @@ yaml: |
not a number: .NaN
float as whole number: !!float 1
php: |
array(
[
'canonical' => 1230.15,
'exponential' => 1230.15,
'negative infinity' => log(0),
'not a number' => -log(0),
'float as whole number' => (float) 1
)
]
---
test: Timestamps
todo: true
@ -545,12 +545,12 @@ yaml: |
spaced: 2001-12-14 21:59:43.10 -05:00
date: 2002-12-14 # Time is noon UTC
php: |
array(
[
'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
'date' => Date.new( 2002, 12, 14 )
)
]
---
test: legacy Timestamps test
todo: true
@ -561,12 +561,12 @@ yaml: |
spaced: 2001-12-14 21:59:43.00 -05:00
date: 2002-12-14
php: |
array(
[
'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
'date' => Date.new( 2002, 12, 14 )
)
]
---
test: Various explicit families
todo: true
@ -734,20 +734,20 @@ yaml: |
Backup contact is Nancy
Billsmer @ 338-4338.
php: |
array(
[
'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'bill-to' =>
array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
[ 'given' => 'Chris', 'family' => 'Dumars', 'address' => [ 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ]]
, 'ship-to' =>
array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
[ 'given' => 'Chris', 'family' => 'Dumars', 'address' => [ 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ]]
, 'product' =>
array(
array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
),
[
[ 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ],
[ 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 ]
],
'tax' => 251.42, 'total' => 4443.52,
'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
)
]
---
test: Log file
todo: true
@ -806,9 +806,9 @@ yaml: |
# These are three throwaway comment
# lines (the first line is empty).
php: |
array(
[
'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
)
]
---
test: Document with a single value
todo: true
@ -858,11 +858,11 @@ yaml: |
date : 2001-01-23
total : 4443.52
php: |
array(
[
'invoice' => 34843,
'date' => gmmktime(0, 0, 0, 1, 23, 2001),
'total' => 4443.52
)
]
---
test: Single-line documents
todo: true
@ -913,7 +913,7 @@ yaml: |
no int: ! 12
string: !!str 12
php: |
array( 'integer' => 12, 'no int' => '12', 'string' => '12' )
[ 'integer' => 12, 'no int' => '12', 'string' => '12' ]
---
test: Private types
todo: true
@ -945,7 +945,7 @@ yaml: |
# The URI is 'tag:yaml.org,2002:str'
- !!str a Unicode string
php: |
array( 'a Unicode string' )
[ 'a Unicode string' ]
---
test: Type family under perl.yaml.org
todo: true
@ -1018,9 +1018,9 @@ yaml: |
repeated use of this value.
alias : *A001
php: |
array( 'anchor' => 'This scalar has an anchor.',
[ 'anchor' => 'This scalar has an anchor.',
'override' => "The alias node below is a repeated use of this value.\n",
'alias' => "The alias node below is a repeated use of this value.\n" )
'alias' => "The alias node below is a repeated use of this value.\n" ]
---
test: Flow and block formatting
todo: true
@ -1131,12 +1131,12 @@ yaml: |
redundant: |2
This value is indented 2 spaces.
php: |
array(
[
'leading spaces' => " This value starts with four spaces.\n",
'leading line break' => "\nThis value starts with a line break.\n",
'leading comment indicator' => "# first line starts with a\n# character.\n",
'redundant' => "This value is indented 2 spaces.\n"
)
]
---
test: Chomping and keep modifiers
yaml: |
@ -1155,14 +1155,14 @@ yaml: |
same as "kept" above: "This has two newlines.\n\n"
php: |
array(
[
'clipped' => "This has one newline.\n",
'same as "clipped" above' => "This has one newline.\n",
'stripped' => 'This has no newline.',
'same as "stripped" above' => 'This has no newline.',
'kept' => "This has two newlines.\n\n",
'same as "kept" above' => "This has two newlines.\n\n"
)
]
---
test: Literal combinations
todo: true
@ -1200,7 +1200,7 @@ yaml: |
both are equal to: " This has no newline."
php: |
array(
[
'empty' => '',
'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
"is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
@ -1211,7 +1211,7 @@ php: |
'indented and chomped' => ' This has no newline.',
'also written as' => ' This has no newline.',
'both are equal to' => ' This has no newline.'
)
]
---
test: Folded combinations
todo: true
@ -1267,7 +1267,7 @@ yaml: |
# Explicit comments may follow
# but must be less indented.
php: |
array(
[
'empty' => '',
'one paragraph' => 'Line feeds are converted to spaces, so this value'.
" contains no line breaks except for the final one.\n",
@ -1279,7 +1279,7 @@ php: |
'above is equal to' => "This is a folded paragraph followed by a list:\n".
" * first entry\n * second entry\nFollowed by another folded paragraph, ".
"another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
)
]
---
test: Single quotes
todo: true
@ -1294,13 +1294,13 @@ yaml: |
line break'
is same as: "this contains six spaces\nand one line break"
php: |
array(
[
'empty' => '',
'second' => '! : \\ etc. can be used freely.',
'third' => "a single quote ' must be escaped.",
'span' => "this contains six spaces\nand one line break",
'is same as' => "this contains six spaces\nand one line break"
)
]
---
test: Double quotes
todo: true
@ -1314,14 +1314,14 @@ yaml: |
spaces"
is equal to: "this contains four spaces"
php: |
array(
[
'empty' => '',
'second' => '! : etc. can be used freely.',
'third' => 'a " or a \\ must be escaped.',
'fourth' => "this value ends with an LF.\n",
'span' => "this contains four spaces",
'is equal to' => "this contains four spaces"
)
]
---
test: Unquoted strings
todo: true
@ -1350,7 +1350,7 @@ yaml: |
note: { one-line keys: but multi-line values }
php: |
array(
[
'first' => 'There is no unquoted empty string.',
'second' => 12,
'third' => '12',
@ -1358,7 +1358,7 @@ php: |
'indicators' => "this has no comments. #:foo and bar# are both text.",
'flow' => [ 'can span lines', 'like this' ],
'note' => { 'one-line keys' => 'but multi-line values' }
)
]
---
test: Spanning sequences
todo: true
@ -1372,11 +1372,11 @@ yaml: |
- one
- two
php: |
array(
[
'flow' => [ 'one', 'two' ],
'spanning' => [ 'one', 'two' ],
'block' => [ 'one', 'two' ]
)
]
---
test: Flow mappings
yaml: |
@ -1387,10 +1387,10 @@ yaml: |
one: 1
two: 2
php: |
array(
'flow' => array( 'one' => 1, 'two' => 2 ),
'block' => array( 'one' => 1, 'two' => 2 )
)
[
'flow' => [ 'one' => 1, 'two' => 2 ],
'block' => [ 'one' => 1, 'two' => 2 ]
]
---
test: Representations of 12
todo: true
@ -1412,7 +1412,7 @@ yaml: |
- foo/bar
- /a.*b/
php: |
array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
[ 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' ]
---
test: "Null"
todo: true
@ -1434,12 +1434,12 @@ yaml: |
only two with values.
php: |
array (
[
'canonical' => null,
'english' => null,
'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
'sparse' => [ null, '2nd entry', null, '4th entry', null ]],
'four' => 'This mapping has five keys, only two with values.'
)
]
---
test: Omap
todo: true
@ -1504,11 +1504,11 @@ yaml: |
octal: 014
hexadecimal: 0xC
php: |
array(
[
'canonical' => 12345,
'octal' => 12,
'hexadecimal' => 12
)
]
---
test: Float
yaml: |
@ -1517,12 +1517,12 @@ yaml: |
negative infinity: -.inf
not a number: .NaN
php: |
array(
[
'canonical' => 1230.15,
'exponential' => 1230.15,
'negative infinity' => log(0),
'not a number' => -log(0)
)
]
---
test: Timestamp
todo: true
@ -1532,12 +1532,12 @@ yaml: |
space separated: 2001-12-14 21:59:43.10 -05:00
date (noon UTC): 2002-12-14
ruby: |
array(
[
'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
'date (noon UTC)' => Date.new( 2002, 12, 14 )
)
]
---
test: Binary
todo: true

View File

@ -25,14 +25,14 @@ yaml: |
- No, I mean, "And what about Yaml?"
- Oh, oh yeah. Uh.. Yaml for Ruby.
php: |
array(
[
"What's Yaml?",
"It's for writing data structures in plain text.",
"And?",
"And what? That's not good enough for you?",
"No, I mean, \"And what about Yaml?\"",
"Oh, oh yeah. Uh.. Yaml for Ruby."
)
]
---
test: Indicators in Strings
brief: >
@ -43,11 +43,11 @@ yaml: |
same for the pound sign: here we have it#in a string
the comma can, honestly, be used in most cases: [ but not in, inline collections ]
php: |
array(
[
'the colon followed by space is an indicator' => 'but is a string:right here',
'same for the pound sign' => 'here we have it#in a string',
'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections')
)
'the comma can, honestly, be used in most cases' => ['but not in', 'inline collections']
]
---
test: Forcing Strings
brief: >
@ -57,10 +57,10 @@ yaml: |
date string: !!str 2001-08-01
number string: !!str 192
php: |
array(
[
'date string' => '2001-08-01',
'number string' => '192'
)
]
---
test: Single-quoted Strings
brief: >
@ -75,12 +75,12 @@ yaml: |
why do i hate them?: 'it''s very hard to explain'
entities: '&pound; me'
php: |
array(
[
'all my favorite symbols' => '#:!/%.)',
'a few i hate' => '&(*',
'why do i hate them?' => 'it\'s very hard to explain',
'entities' => '&pound; me'
)
]
---
test: Double-quoted Strings
brief: >
@ -90,9 +90,9 @@ brief: >
yaml: |
i know where i want my line breaks: "one here\nand another here\n"
php: |
array(
[
'i know where i want my line breaks' => "one here\nand another here\n"
)
]
---
test: Multi-line Quoted Strings
todo: true
@ -106,10 +106,10 @@ yaml: |
let it go on and on to other lines
until i end it with a quote."
php: |
array('i want a long string' => "so i'm going to ".
['i want a long string' => "so i'm going to ".
"let it go on and on to other lines ".
"until i end it with a quote."
)
]
---
test: Plain scalars
@ -128,7 +128,7 @@ yaml: |
- This would impair my skiing ability somewhat for the
duration, as can be imagined.
php: |
array(
[
"My little toe is broken in two places;",
"I'm crazy to have skied this way;",
"I'm not the craziest he's seen, since there was always ".
@ -139,7 +139,7 @@ php: |
"He's going to put my foot in plaster for a month;",
"This would impair my skiing ability somewhat for the duration, ".
"as can be imagined."
)
]
---
test: 'Null'
brief: >
@ -149,11 +149,11 @@ yaml: |
hosted by: Bob and David
date of next season: ~
php: |
array(
[
'name' => 'Mr. Show',
'hosted by' => 'Bob and David',
'date of next season' => null
)
]
---
test: Boolean
brief: >
@ -162,10 +162,10 @@ yaml: |
Is Gus a Liar?: true
Do I rely on Gus for Sustenance?: false
php: |
array(
[
'Is Gus a Liar?' => true,
'Do I rely on Gus for Sustenance?' => false
)
]
---
test: Integers
dump_skip: true
@ -177,10 +177,10 @@ yaml: |
zero: 0
simple: 12
php: |
array(
[
'zero' => 0,
'simple' => 12,
)
]
---
test: Floats
dump_skip: true
@ -192,10 +192,10 @@ yaml: |
a simple float: 2.00
scientific notation: 1.00009e+3
php: |
array(
[
'a simple float' => 2.0,
'scientific notation' => 1000.09
)
]
---
test: Time
todo: true
@ -208,10 +208,10 @@ yaml: |
iso8601: 2001-12-14t21:59:43.10-05:00
space separated: 2001-12-14 21:59:43.10 -05:00
php: |
array(
[
'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" )
)
]
---
test: Date
todo: true