Merge remote branch 'vicb/cast-array'
* vicb/cast-array: Make casting scalar to array consistent
This commit is contained in:
commit
fe03671c2c
@ -687,9 +687,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
|
||||
|
||||
protected function getContainer($bundles = 'YamlBundle', $vendor = null)
|
||||
{
|
||||
if (!is_array($bundles)) {
|
||||
$bundles = array($bundles);
|
||||
}
|
||||
$bundles = (array) $bundles;
|
||||
|
||||
$map = array();
|
||||
foreach ($bundles as $bundle) {
|
||||
|
@ -27,10 +27,7 @@ class FileLocator implements FileLocatorInterface
|
||||
*/
|
||||
public function __construct($paths = array())
|
||||
{
|
||||
if (!is_array($paths)) {
|
||||
$paths = array($paths);
|
||||
}
|
||||
$this->paths = $paths;
|
||||
$this->paths = (array) $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,9 +41,7 @@ class FormatterHelper extends Helper
|
||||
*/
|
||||
public function formatBlock($messages, $style, $large = false)
|
||||
{
|
||||
if (!is_array($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
$messages = (array) $messages;
|
||||
|
||||
$len = 0;
|
||||
$lines = array();
|
||||
|
@ -260,9 +260,7 @@ class ArgvInput extends Input
|
||||
*/
|
||||
public function hasParameterOption($values)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->tokens as $v) {
|
||||
if (in_array($v, $values)) {
|
||||
@ -285,9 +283,7 @@ class ArgvInput extends Input
|
||||
*/
|
||||
public function getParameterOption($values, $default = false)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$values = (array) $values;
|
||||
|
||||
$tokens = $this->tokens;
|
||||
while ($token = array_shift($tokens)) {
|
||||
|
@ -69,9 +69,7 @@ class ArrayInput extends Input
|
||||
*/
|
||||
public function hasParameterOption($values)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (!is_int($k)) {
|
||||
@ -99,9 +97,7 @@ class ArrayInput extends Input
|
||||
*/
|
||||
public function getParameterOption($values, $default = false)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (is_int($k) && in_array($v, $values)) {
|
||||
|
@ -154,9 +154,7 @@ abstract class Output implements OutputInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
$messages = (array) $messages;
|
||||
|
||||
foreach ($messages as $message) {
|
||||
switch ($type) {
|
||||
|
@ -447,9 +447,7 @@ class Crawler extends \SplObjectStorage
|
||||
*/
|
||||
public function extract($attributes)
|
||||
{
|
||||
if (!is_array($attributes)) {
|
||||
$attributes = array($attributes);
|
||||
}
|
||||
$attributes = (array) $attributes;
|
||||
|
||||
$data = array();
|
||||
foreach ($this as $node) {
|
||||
|
@ -115,8 +115,8 @@ class ChoiceFormField extends FormField
|
||||
throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->options)));
|
||||
}
|
||||
|
||||
if ($this->multiple && !is_array($value)) {
|
||||
$value = array($value);
|
||||
if ($this->multiple) {
|
||||
$value = (array) $value;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
|
@ -327,9 +327,7 @@ class Finder implements \IteratorAggregate
|
||||
*/
|
||||
public function in($dirs)
|
||||
{
|
||||
if (!is_array($dirs)) {
|
||||
$dirs = array($dirs);
|
||||
}
|
||||
$dirs = (array) $dirs;
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
|
@ -231,10 +231,6 @@ class DelegatingValidator implements FormValidatorInterface
|
||||
$groups = array('Default');
|
||||
}
|
||||
|
||||
if (!is_array($groups)) {
|
||||
$groups = array($groups);
|
||||
}
|
||||
|
||||
return $groups;
|
||||
return (array) $groups;
|
||||
}
|
||||
}
|
||||
|
@ -119,9 +119,7 @@ class HeaderBag
|
||||
{
|
||||
$key = strtr(strtolower($key), '_', '-');
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = array($values);
|
||||
}
|
||||
$values = (array) $values;
|
||||
|
||||
if (true === $replace || !isset($this->headers[$key])) {
|
||||
$this->headers[$key] = $values;
|
||||
|
@ -32,11 +32,7 @@ class AssetPackage implements AssetPackageInterface
|
||||
$this->baseUrls = array();
|
||||
$this->version = $version;
|
||||
|
||||
if (!is_array($baseUrls)) {
|
||||
$baseUrls = (array) $baseUrls;
|
||||
}
|
||||
|
||||
foreach ($baseUrls as $baseUrl) {
|
||||
foreach ((array) $baseUrls as $baseUrl) {
|
||||
$this->baseUrls[] = rtrim($baseUrl, '/');
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,7 @@ class FilesystemLoader extends Loader
|
||||
*/
|
||||
public function __construct($templatePathPatterns)
|
||||
{
|
||||
if (!is_array($templatePathPatterns)) {
|
||||
$templatePathPatterns = array($templatePathPatterns);
|
||||
}
|
||||
|
||||
$this->templatePathPatterns = $templatePathPatterns;
|
||||
$this->templatePathPatterns = (array) $templatePathPatterns;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user