Skip to content

Commit

Permalink
minor #13866 [2.3] Remove most refs uses (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.3 branch.

Discussion
----------

[2.3] Remove most refs uses

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13813
| License       | MIT
| Doc PR        | -

Removes some references usages. They are error prone, and trigger too many copies-on-writes.

Commits
-------

8862705 [2.3] Remove most refs uses
  • Loading branch information
fabpot committed Mar 9, 2015
2 parents a73413e + 8862705 commit de0bd91
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Expand Up @@ -117,8 +117,10 @@ private function sanitizeQueries($connectionName, $queries)
private function sanitizeQuery($connectionName, $query)
{
$query['explainable'] = true;
$query['params'] = (array) $query['params'];
foreach ($query['params'] as $j => &$param) {
if (!is_array($query['params'])) {
$query['params'] = array($query['params']);
}
foreach ($query['params'] as $j => $param) {
if (isset($query['types'][$j])) {
// Transform the param according to the type
$type = $query['types'][$j];
Expand All @@ -131,7 +133,7 @@ private function sanitizeQuery($connectionName, $query)
}
}

list($param, $explainable) = $this->sanitizeParam($param);
list($query['params'][$j], $explainable) = $this->sanitizeParam($param);
if (!$explainable) {
$query['explainable'] = false;
}
Expand Down
Expand Up @@ -36,13 +36,13 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.xml');

foreach ($configs as &$config) {
foreach ($configs as $key => $config) {
if (isset($config['globals'])) {
foreach ($config['globals'] as $name => $value) {
if (is_array($value) && isset($value['key'])) {
$config['globals'][$name] = array(
$configs[$key]['globals'][$name] = array(
'key' => $name,
'value' => $config['globals'][$name],
'value' => $value,
);
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/Symfony/Component/Console/Helper/FormatterHelper.php
Expand Up @@ -45,7 +45,9 @@ public function formatSection($section, $message, $style = 'info')
*/
public function formatBlock($messages, $style, $large = false)
{
$messages = (array) $messages;
if (!is_array($messages)) {
$messages = array($messages);
}

$len = 0;
$lines = array();
Expand All @@ -56,15 +58,15 @@ public function formatBlock($messages, $style, $large = false)
}

$messages = $large ? array(str_repeat(' ', $len)) : array();
foreach ($lines as $line) {
$messages[] = $line.str_repeat(' ', $len - $this->strlen($line));
for ($i = 0; isset($lines[$i]); ++$i) {
$messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
}
if ($large) {
$messages[] = str_repeat(' ', $len);
}

foreach ($messages as &$message) {
$message = sprintf('<%s>%s</%s>', $style, $message, $style);
for ($i = 0; isset($messages[$i]); ++$i) {
$messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
}

return implode("\n", $messages);
Expand Down
Expand Up @@ -997,9 +997,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
public function resolveServices($value)
{
if (is_array($value)) {
foreach ($value as &$v) {
$v = $this->resolveServices($v);
}
$value = array_map(array($this, 'resolveServices'), $value);
} elseif ($value instanceof Reference) {
$value = $this->get((string) $value, $value->getInvalidBehavior());
} elseif ($value instanceof Definition) {
Expand Down

0 comments on commit de0bd91

Please sign in to comment.