folded all curly brackets of control structures to conform to PEAR/ZF CS, part two
This commit is contained in:
parent
16055d229b
commit
9ed3d0468e
|
@ -110,8 +110,7 @@ class CookieJar
|
|||
|
||||
$cookies = array();
|
||||
foreach ($this->cookieJar as $cookie) {
|
||||
if ($cookie->getDomain() && $cookie->getDomain() != substr($parts['host'], -strlen($cookie->getDomain())))
|
||||
{
|
||||
if ($cookie->getDomain() && $cookie->getDomain() != substr($parts['host'], -strlen($cookie->getDomain()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -136,8 +135,7 @@ class CookieJar
|
|||
{
|
||||
$cookies = $this->cookieJar;
|
||||
foreach ($cookies as $name => $cookie) {
|
||||
if ($cookie->isExpired())
|
||||
{
|
||||
if ($cookie->isExpired()) {
|
||||
unset($this->cookieJar[$name]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ class Response
|
|||
public function getHeader($header)
|
||||
{
|
||||
foreach ($this->headers as $key => $value) {
|
||||
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header)))
|
||||
{
|
||||
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,7 @@ class Application
|
|||
try {
|
||||
$statusCode = $this->doRun($input, $output);
|
||||
} catch (\Exception $e) {
|
||||
if (!$this->catchExceptions)
|
||||
{
|
||||
if (!$this->catchExceptions) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
@ -152,8 +151,7 @@ class Application
|
|||
}
|
||||
|
||||
if (true === $input->hasParameterOption(array('--help', '-H'))) {
|
||||
if (!$name)
|
||||
{
|
||||
if (!$name) {
|
||||
$name = 'help';
|
||||
$input = new ArrayInput(array('command' => 'help'));
|
||||
} else {
|
||||
|
@ -420,8 +418,7 @@ class Application
|
|||
{
|
||||
$namespaces = array();
|
||||
foreach ($this->commands as $command) {
|
||||
if ($command->getNamespace())
|
||||
{
|
||||
if ($command->getNamespace()) {
|
||||
$namespaces[$command->getNamespace()] = true;
|
||||
}
|
||||
}
|
||||
|
@ -477,8 +474,7 @@ class Application
|
|||
// name
|
||||
$commands = array();
|
||||
foreach ($this->commands as $command) {
|
||||
if ($command->getNamespace() == $namespace)
|
||||
{
|
||||
if ($command->getNamespace() == $namespace) {
|
||||
$commands[] = $command->getName();
|
||||
}
|
||||
}
|
||||
|
@ -524,8 +520,7 @@ class Application
|
|||
|
||||
$commands = array();
|
||||
foreach ($this->commands as $name => $command) {
|
||||
if ($namespace === $command->getNamespace())
|
||||
{
|
||||
if ($namespace === $command->getNamespace()) {
|
||||
$commands[$name] = $command;
|
||||
}
|
||||
}
|
||||
|
@ -544,8 +539,7 @@ class Application
|
|||
{
|
||||
$abbrevs = array();
|
||||
foreach ($names as $name) {
|
||||
for ($len = strlen($name) - 1; $len > 0; --$len)
|
||||
{
|
||||
for ($len = strlen($name) - 1; $len > 0; --$len) {
|
||||
$abbrev = substr($name, 0, $len);
|
||||
if (!isset($abbrevs[$abbrev])) {
|
||||
$abbrevs[$abbrev] = array($name);
|
||||
|
@ -589,8 +583,7 @@ class Application
|
|||
|
||||
// add commands by namespace
|
||||
foreach ($this->sortCommands($commands) as $space => $commands) {
|
||||
if (!$namespace && '_global' !== $space)
|
||||
{
|
||||
if (!$namespace && '_global' !== $space) {
|
||||
$messages[] = '<comment>'.$space.'</comment>';
|
||||
}
|
||||
|
||||
|
@ -630,15 +623,13 @@ class Application
|
|||
|
||||
// add commands by namespace
|
||||
foreach ($this->sortCommands($commands) as $space => $commands) {
|
||||
if (!$namespace)
|
||||
{
|
||||
if (!$namespace) {
|
||||
$namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
|
||||
$namespaceArrayXML->setAttribute('id', $space);
|
||||
}
|
||||
|
||||
foreach ($commands as $command) {
|
||||
if (!$namespace)
|
||||
{
|
||||
if (!$namespace) {
|
||||
$namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
|
||||
$commandXML->appendChild($dom->createTextNode($command->getName()));
|
||||
}
|
||||
|
|
|
@ -134,8 +134,7 @@ class Command
|
|||
try {
|
||||
$input->bind($this->definition);
|
||||
} catch (\Exception $e) {
|
||||
if (!$this->ignoreValidationErrors)
|
||||
{
|
||||
if (!$this->ignoreValidationErrors) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,7 @@ class DialogHelper extends Helper
|
|||
// @codeCoverageIgnoreStart
|
||||
$error = null;
|
||||
while (false === $attempts || $attempts--) {
|
||||
if (null !== $error)
|
||||
{
|
||||
if (null !== $error) {
|
||||
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ class ArgvInput extends Input
|
|||
{
|
||||
$this->parsed = $this->tokens;
|
||||
while (null !== $token = array_shift($this->parsed)) {
|
||||
if ('--' === substr($token, 0, 2))
|
||||
{
|
||||
if ('--' === substr($token, 0, 2)) {
|
||||
$this->parseLongOption($token);
|
||||
} elseif ('-' === $token[0]) {
|
||||
$this->parseShortOption($token);
|
||||
|
@ -91,8 +90,7 @@ class ArgvInput extends Input
|
|||
$name = substr($token, 1);
|
||||
|
||||
if (strlen($name) > 1) {
|
||||
if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptParameter())
|
||||
{
|
||||
if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptParameter()) {
|
||||
// an option with a value (with no space)
|
||||
$this->addShortOption($name[0], substr($name, 1));
|
||||
} else {
|
||||
|
@ -114,8 +112,7 @@ class ArgvInput extends Input
|
|||
{
|
||||
$len = strlen($name);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
if (!$this->definition->hasShortcut($name[$i]))
|
||||
{
|
||||
if (!$this->definition->hasShortcut($name[$i])) {
|
||||
throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i]));
|
||||
}
|
||||
|
||||
|
@ -207,8 +204,7 @@ class ArgvInput extends Input
|
|||
}
|
||||
|
||||
if (null === $value) {
|
||||
if ($option->isParameterRequired())
|
||||
{
|
||||
if ($option->isParameterRequired()) {
|
||||
throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name));
|
||||
}
|
||||
|
||||
|
@ -226,8 +222,7 @@ class ArgvInput extends Input
|
|||
public function getFirstArgument()
|
||||
{
|
||||
foreach ($this->tokens as $token) {
|
||||
if ($token && '-' === $token[0])
|
||||
{
|
||||
if ($token && '-' === $token[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -252,8 +247,7 @@ class ArgvInput extends Input
|
|||
}
|
||||
|
||||
foreach ($this->tokens as $v) {
|
||||
if (in_array($v, $values))
|
||||
{
|
||||
if (in_array($v, $values)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,7 @@ class ArrayInput extends Input
|
|||
public function getFirstArgument()
|
||||
{
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if ($key && '-' === $key[0])
|
||||
{
|
||||
if ($key && '-' === $key[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -73,8 +72,7 @@ class ArrayInput extends Input
|
|||
}
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (!is_int($k))
|
||||
{
|
||||
if (!is_int($k)) {
|
||||
$v = $k;
|
||||
}
|
||||
|
||||
|
@ -92,8 +90,7 @@ class ArrayInput extends Input
|
|||
protected function parse()
|
||||
{
|
||||
foreach ($this->parameters as $key => $value) {
|
||||
if ('--' === substr($key, 0, 2))
|
||||
{
|
||||
if ('--' === substr($key, 0, 2)) {
|
||||
$this->addLongOption(substr($key, 2), $value);
|
||||
} elseif ('-' === $key[0]) {
|
||||
$this->addShortOption(substr($key, 1), $value);
|
||||
|
@ -138,8 +135,7 @@ class ArrayInput extends Input
|
|||
$option = $this->definition->getOption($name);
|
||||
|
||||
if (null === $value) {
|
||||
if ($option->isParameterRequired())
|
||||
{
|
||||
if ($option->isParameterRequired()) {
|
||||
throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name));
|
||||
}
|
||||
|
||||
|
|
|
@ -98,8 +98,7 @@ class InputArgument
|
|||
}
|
||||
|
||||
if ($this->isArray()) {
|
||||
if (null === $default)
|
||||
{
|
||||
if (null === $default) {
|
||||
$default = array();
|
||||
} else if (!is_array($default)) {
|
||||
throw new \LogicException('A default value for an array argument must be an array.');
|
||||
|
|
|
@ -49,8 +49,7 @@ class InputDefinition
|
|||
$arguments = array();
|
||||
$options = array();
|
||||
foreach ($definition as $item) {
|
||||
if ($item instanceof InputOption)
|
||||
{
|
||||
if ($item instanceof InputOption) {
|
||||
$options[] = $item;
|
||||
} else {
|
||||
$arguments[] = $item;
|
||||
|
@ -82,8 +81,7 @@ class InputDefinition
|
|||
public function addArguments($arguments = array())
|
||||
{
|
||||
if (null !== $arguments) {
|
||||
foreach ($arguments as $argument)
|
||||
{
|
||||
foreach ($arguments as $argument) {
|
||||
$this->addArgument($argument);
|
||||
}
|
||||
}
|
||||
|
@ -386,8 +384,7 @@ class InputDefinition
|
|||
if ($this->getArguments()) {
|
||||
$text[] = '<comment>Arguments:</comment>';
|
||||
foreach ($this->getArguments() as $argument) {
|
||||
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault())))
|
||||
{
|
||||
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
|
||||
$default = sprintf('<comment> (default: %s)</comment>', is_array($argument->getDefault()) ? str_replace("\n", '', var_export($argument->getDefault(), true)): $argument->getDefault());
|
||||
} else {
|
||||
$default = '';
|
||||
|
@ -403,8 +400,7 @@ class InputDefinition
|
|||
$text[] = '<comment>Options:</comment>';
|
||||
|
||||
foreach ($this->getOptions() as $option) {
|
||||
if ($option->acceptParameter() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault())))
|
||||
{
|
||||
if ($option->acceptParameter() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
|
||||
$default = sprintf('<comment> (default: %s)</comment>', is_array($option->getDefault()) ? str_replace("\n", '', print_r($option->getDefault(), true)): $option->getDefault());
|
||||
} else {
|
||||
$default = '';
|
||||
|
|
|
@ -53,8 +53,7 @@ class InputOption
|
|||
}
|
||||
|
||||
if (null !== $shortcut) {
|
||||
if ('-' === $shortcut[0])
|
||||
{
|
||||
if ('-' === $shortcut[0]) {
|
||||
$shortcut = substr($shortcut, 1);
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +148,7 @@ class InputOption
|
|||
}
|
||||
|
||||
if ($this->isArray()) {
|
||||
if (null === $default)
|
||||
{
|
||||
if (null === $default) {
|
||||
$default = array();
|
||||
} elseif (!is_array($default)) {
|
||||
throw new \LogicException('A default value for an array option must be an array.');
|
||||
|
|
|
@ -51,8 +51,7 @@ class StringInput extends ArgvInput
|
|||
$length = strlen($input);
|
||||
$cursor = 0;
|
||||
while ($cursor < $length) {
|
||||
if (preg_match('/\s+/A', $input, $match, null, $cursor))
|
||||
{
|
||||
if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
|
||||
} elseif (preg_match('/([^="\' ]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
|
||||
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2)));
|
||||
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
|
||||
|
|
|
@ -141,8 +141,7 @@ abstract class Output implements OutputInterface
|
|||
}
|
||||
|
||||
foreach ($messages as $message) {
|
||||
switch ($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case Output::OUTPUT_NORMAL:
|
||||
$message = $this->format($message);
|
||||
break;
|
||||
|
@ -206,8 +205,7 @@ abstract class Output implements OutputInterface
|
|||
}
|
||||
|
||||
foreach (static::$options as $option => $value) {
|
||||
if (isset($parameters[$option]) && $parameters[$option])
|
||||
{
|
||||
if (isset($parameters[$option]) && $parameters[$option]) {
|
||||
$codes[] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ class FunctionNode implements NodeInterface
|
|||
|
||||
$xpath->addStarPrefix();
|
||||
if ($a == 0) {
|
||||
if ($last)
|
||||
{
|
||||
if ($last) {
|
||||
$b = sprintf('last() - %s', $b);
|
||||
}
|
||||
$xpath->addCondition(sprintf('position() = %s', $b));
|
||||
|
|
|
@ -32,8 +32,7 @@ class Parser
|
|||
static public function cssToXpath($cssExpr, $prefix = 'descendant-or-self::')
|
||||
{
|
||||
if (is_string($cssExpr)) {
|
||||
if (preg_match('#^\w+\s*$#u', $cssExpr, $match))
|
||||
{
|
||||
if (preg_match('#^\w+\s*$#u', $cssExpr, $match)) {
|
||||
return $prefix.trim($match[0]);
|
||||
}
|
||||
|
||||
|
@ -162,8 +161,7 @@ class Parser
|
|||
while (1) {
|
||||
$peek = $stream->peek();
|
||||
if ($peek == '#') {
|
||||
if ($has_hash)
|
||||
{
|
||||
if ($has_hash) {
|
||||
/* You can't have two hashes
|
||||
(FIXME: is there some more general rule I'm missing?) */
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@ -219,8 +217,7 @@ class Parser
|
|||
|
||||
continue;
|
||||
} else {
|
||||
if ($peek == ' ')
|
||||
{
|
||||
if ($peek == ' ') {
|
||||
$stream->next();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,7 @@ class TokenStream
|
|||
public function peek()
|
||||
{
|
||||
if (!$this->peeking) {
|
||||
if (!count($this->tokens))
|
||||
{
|
||||
if (!count($this->tokens)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ class Tokenizer
|
|||
$s = preg_replace('#/\*.*?\*/#s', '', $s);
|
||||
|
||||
while (1) {
|
||||
if (preg_match('#\s+#A', $s, $match, 0, $pos))
|
||||
{
|
||||
if (preg_match('#\s+#A', $s, $match, 0, $pos)) {
|
||||
$preceding_whitespace_pos = $pos;
|
||||
$pos += strlen($match[0]);
|
||||
} else {
|
||||
|
@ -44,8 +43,7 @@ class Tokenizer
|
|||
}
|
||||
|
||||
if ($pos >= strlen($s)) {
|
||||
if (isset($mbEncoding))
|
||||
{
|
||||
if (isset($mbEncoding)) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
|
||||
|
@ -70,8 +68,7 @@ class Tokenizer
|
|||
}
|
||||
|
||||
if (in_array($c, array('>', '+', '~', ',', '.', '*', '=', '[', ']', '(', ')', '|', ':', '#'))) {
|
||||
if (in_array($c, array('.', '#', '[')) && $preceding_whitespace_pos > 0)
|
||||
{
|
||||
if (in_array($c, array('.', '#', '[')) && $preceding_whitespace_pos > 0) {
|
||||
$tokens[] = new Token('Token', ' ', $preceding_whitespace_pos);
|
||||
}
|
||||
$tokens[] = new Token('Token', $c, $pos);
|
||||
|
|
|
@ -165,8 +165,7 @@ class XPathExpr
|
|||
$string = $s;
|
||||
$parts = array();
|
||||
while (true) {
|
||||
if (false !== $pos = strpos($string, "'"))
|
||||
{
|
||||
if (false !== $pos = strpos($string, "'")) {
|
||||
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
|
||||
$parts[] = "\"'\"";
|
||||
$string = substr($string, $pos + 1);
|
||||
|
|
|
@ -68,8 +68,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
try {
|
||||
return parent::getService($id, Container::EXCEPTION_ON_INVALID_REFERENCE);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
if (isset($this->loading[$id]))
|
||||
{
|
||||
if (isset($this->loading[$id])) {
|
||||
throw new \LogicException(sprintf('The service "%s" has a circular reference to itself.', $id));
|
||||
}
|
||||
|
||||
|
@ -80,8 +79,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
try {
|
||||
$definition = $this->getDefinition($id);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
if (Container::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior)
|
||||
{
|
||||
if (Container::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -349,8 +347,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
|
||||
$ok = true;
|
||||
foreach ($services as $s) {
|
||||
if (!$this->hasService($s))
|
||||
{
|
||||
if (!$this->hasService($s)) {
|
||||
$ok = false;
|
||||
break;
|
||||
}
|
||||
|
@ -362,8 +359,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
}
|
||||
|
||||
if ($callable = $definition->getConfigurator()) {
|
||||
if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference)
|
||||
{
|
||||
if (is_array($callable) && is_object($callable[0]) && $callable[0] instanceof Reference) {
|
||||
$callable[0] = $this->getService((string) $callable[0]);
|
||||
} elseif (is_array($callable)) {
|
||||
$callable[0] = self::resolveValue($callable[0], $this->parameters);
|
||||
|
@ -398,8 +394,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
|
||||
$value = $args;
|
||||
} else if (is_string($value)) {
|
||||
if (preg_match('/^%([^%]+)%$/', $value, $match))
|
||||
{
|
||||
if (preg_match('/^%([^%]+)%$/', $value, $match)) {
|
||||
// we do this to deal with non string values (boolean, integer, ...)
|
||||
// the preg_replace_callback converts them to strings
|
||||
if (!array_key_exists($name = strtolower($match[1]), $parameters)) {
|
||||
|
@ -434,8 +429,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
public function resolveServices($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as &$v)
|
||||
{
|
||||
foreach ($value as &$v) {
|
||||
$v = $this->resolveServices($v);
|
||||
}
|
||||
} else if (is_object($value) && $value instanceof Reference) {
|
||||
|
@ -456,8 +450,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
{
|
||||
$annotations = array();
|
||||
foreach ($this->getDefinitions() as $id => $definition) {
|
||||
if ($definition->getAnnotation($name))
|
||||
{
|
||||
if ($definition->getAnnotation($name)) {
|
||||
$annotations[$id] = $definition->getAnnotation($name);
|
||||
}
|
||||
}
|
||||
|
@ -470,8 +463,7 @@ class Builder extends Container implements AnnotatedContainerInterface
|
|||
$services = array();
|
||||
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $v)
|
||||
{
|
||||
foreach ($value as $v) {
|
||||
$services = array_unique(array_merge($services, self::getServiceConditionals($v)));
|
||||
}
|
||||
} elseif (is_object($value) && $value instanceof Reference && $value->getInvalidBehavior() === Container::IGNORE_ON_INVALID_REFERENCE) {
|
||||
|
|
|
@ -215,8 +215,7 @@ class Container implements ContainerInterface, \ArrayAccess
|
|||
$ids = array();
|
||||
$r = new \ReflectionClass($this);
|
||||
foreach ($r->getMethods() as $method) {
|
||||
if (preg_match('/^get(.+)Service$/', $name = $method->getName(), $match))
|
||||
{
|
||||
if (preg_match('/^get(.+)Service$/', $name = $method->getName(), $match)) {
|
||||
$ids[] = self::underscore($match[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,7 @@ class GraphvizDumper extends Dumper
|
|||
);
|
||||
|
||||
foreach (array('graph', 'node', 'edge', 'node.instance', 'node.definition', 'node.missing') as $key) {
|
||||
if (isset($options[$key]))
|
||||
{
|
||||
if (isset($options[$key])) {
|
||||
$this->options[$key] = array_merge($this->options[$key], $options[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -99,8 +98,7 @@ class GraphvizDumper extends Dumper
|
|||
{
|
||||
$code = '';
|
||||
foreach ($this->edges as $id => $edges) {
|
||||
foreach ($edges as $edge)
|
||||
{
|
||||
foreach ($edges as $edge) {
|
||||
$code .= sprintf(" node_%s -> node_%s [label=\"%s\" style=\"%s\"];\n", $this->dotize($id), $this->dotize($edge['to']), $edge['name'], $edge['required'] ? 'filled' : 'dashed');
|
||||
}
|
||||
}
|
||||
|
@ -112,16 +110,14 @@ class GraphvizDumper extends Dumper
|
|||
{
|
||||
$edges = array();
|
||||
foreach ($arguments as $argument) {
|
||||
if (is_object($argument) && $argument instanceof Parameter)
|
||||
{
|
||||
if (is_object($argument) && $argument instanceof Parameter) {
|
||||
$argument = $this->container->hasParameter($argument) ? $this->container->getParameter($argument) : null;
|
||||
} elseif (is_string($argument) && preg_match('/^%([^%]+)%$/', $argument, $match)) {
|
||||
$argument = $this->container->hasParameter($match[1]) ? $this->container->getParameter($match[1]) : null;
|
||||
}
|
||||
|
||||
if ($argument instanceof Reference) {
|
||||
if (!$this->container->hasService((string) $argument))
|
||||
{
|
||||
if (!$this->container->hasService((string) $argument)) {
|
||||
$this->nodes[(string) $argument] = array('name' => $name, 'required' => $required, 'class' => '', 'attributes' => $this->options['node.missing']);
|
||||
}
|
||||
|
||||
|
@ -211,8 +207,7 @@ class GraphvizDumper extends Dumper
|
|||
{
|
||||
$aliases = array();
|
||||
foreach ($this->container->getAliases() as $alias => $origin) {
|
||||
if ($id == $origin)
|
||||
{
|
||||
if ($id == $origin) {
|
||||
$aliases[] = $alias;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,8 +128,7 @@ EOF;
|
|||
}
|
||||
|
||||
if (is_array($callable)) {
|
||||
if (is_object($callable[0]) && $callable[0] instanceof Reference)
|
||||
{
|
||||
if (is_object($callable[0]) && $callable[0] instanceof Reference) {
|
||||
return sprintf(" %s->%s(\$instance);\n", $this->getServiceCall((string) $callable[0]), $callable[1]);
|
||||
} else {
|
||||
return sprintf(" call_user_func(array(%s, '%s'), \$instance);\n", $this->dumpValue($callable[0]), $callable[1]);
|
||||
|
@ -222,8 +221,7 @@ EOF;
|
|||
{
|
||||
$annotations = array();
|
||||
foreach ($this->container->getDefinitions() as $id => $definition) {
|
||||
foreach ($definition->getAnnotations() as $name => $ann)
|
||||
{
|
||||
foreach ($definition->getAnnotations() as $name => $ann) {
|
||||
if (!isset($annotations[$name])) {
|
||||
$annotations[$name] = array();
|
||||
}
|
||||
|
@ -342,8 +340,7 @@ EOF;
|
|||
{
|
||||
$php = array();
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_array($value))
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = $this->exportParameters($value, $indent + 4);
|
||||
} elseif ($value instanceof Reference) {
|
||||
throw new \InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain references to other services (reference to service %s found).', $value));
|
||||
|
@ -396,8 +393,7 @@ EOF;
|
|||
} elseif (is_object($value) && $value instanceof Parameter) {
|
||||
return sprintf("\$this->getParameter('%s')", strtolower($value));
|
||||
} elseif (is_string($value)) {
|
||||
if (preg_match('/^%([^%]+)%$/', $value, $match))
|
||||
{
|
||||
if (preg_match('/^%([^%]+)%$/', $value, $match)) {
|
||||
// we do this to deal with non string values (boolean, integer, ...)
|
||||
// the preg_replace_callback converts them to strings
|
||||
return sprintf("\$this->getParameter('%s')", strtolower($match[1]));
|
||||
|
@ -430,8 +426,7 @@ EOF;
|
|||
if (null !== $reference && Container::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
||||
return sprintf('$this->getService(\'%s\', Container::NULL_ON_INVALID_REFERENCE)', $id);
|
||||
} else {
|
||||
if ($this->container->hasAlias($id))
|
||||
{
|
||||
if ($this->container->hasAlias($id)) {
|
||||
$id = $this->container->getAlias($id);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,7 @@ class XmlDumper extends Dumper
|
|||
);
|
||||
|
||||
foreach ($definition->getAnnotations() as $name => $annotations) {
|
||||
foreach ($annotations as $attributes)
|
||||
{
|
||||
foreach ($annotations as $attributes) {
|
||||
$att = array();
|
||||
foreach ($attributes as $key => $value) {
|
||||
$att[] = sprintf('%s="%s"', $key, $value);
|
||||
|
@ -76,8 +75,7 @@ class XmlDumper extends Dumper
|
|||
}
|
||||
|
||||
foreach ($definition->getMethodCalls() as $call) {
|
||||
if (count($call[1]))
|
||||
{
|
||||
if (count($call[1])) {
|
||||
$code .= sprintf(" <call method=\"%s\">\n%s </call>\n", $call[0], $this->convertParameters($call[1], 'argument', 8));
|
||||
} else {
|
||||
$code .= sprintf(" <call method=\"%s\" />\n", $call[0]);
|
||||
|
@ -85,8 +83,7 @@ class XmlDumper extends Dumper
|
|||
}
|
||||
|
||||
if ($callable = $definition->getConfigurator()) {
|
||||
if (is_array($callable))
|
||||
{
|
||||
if (is_array($callable)) {
|
||||
if (is_object($callable[0]) && $callable[0] instanceof Reference) {
|
||||
$code .= sprintf(" <configurator service=\"%s\" method=\"%s\" />\n", $callable[0], $callable[1]);
|
||||
} else {
|
||||
|
@ -141,8 +138,7 @@ class XmlDumper extends Dumper
|
|||
if (is_object($value) && $value instanceof Reference) {
|
||||
$xml .= sprintf("%s<%s%s type=\"service\" id=\"%s\" %s/>\n", $white, $type, $key, (string) $value, $this->getXmlInvalidBehavior($value));
|
||||
} else {
|
||||
if (in_array($value, array('null', 'true', 'false'), true))
|
||||
{
|
||||
if (in_array($value, array('null', 'true', 'false'), true)) {
|
||||
$attributes = ' type="string"';
|
||||
}
|
||||
|
||||
|
@ -186,8 +182,7 @@ EOF;
|
|||
{
|
||||
$args = array();
|
||||
foreach ($arguments as $k => $v) {
|
||||
if (is_array($v))
|
||||
{
|
||||
if (is_array($v)) {
|
||||
$args[$k] = $this->escape($v);
|
||||
} elseif (is_string($v)) {
|
||||
$args[$k] = str_replace('%', '%%', $v);
|
||||
|
|
|
@ -44,8 +44,7 @@ class YamlDumper extends Dumper
|
|||
|
||||
$annotationsCode = '';
|
||||
foreach ($definition->getAnnotations() as $name => $annotations) {
|
||||
foreach ($annotations as $attributes)
|
||||
{
|
||||
foreach ($annotations as $attributes) {
|
||||
$att = array();
|
||||
foreach ($attributes as $key => $value) {
|
||||
$att[] = sprintf('%s: %s', Yaml::dump($key), Yaml::dump($value));
|
||||
|
@ -80,8 +79,7 @@ class YamlDumper extends Dumper
|
|||
}
|
||||
|
||||
if ($callable = $definition->getConfigurator()) {
|
||||
if (is_array($callable))
|
||||
{
|
||||
if (is_array($callable)) {
|
||||
if (is_object($callable[0]) && $callable[0] instanceof Reference) {
|
||||
$callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]);
|
||||
} else {
|
||||
|
@ -168,8 +166,7 @@ class YamlDumper extends Dumper
|
|||
{
|
||||
$filtered = array();
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_array($value))
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = $this->prepareParameters($value);
|
||||
} elseif ($value instanceof Reference) {
|
||||
$value = '@'.$value;
|
||||
|
@ -185,8 +182,7 @@ class YamlDumper extends Dumper
|
|||
{
|
||||
$args = array();
|
||||
foreach ($arguments as $k => $v) {
|
||||
if (is_array($v))
|
||||
{
|
||||
if (is_array($v)) {
|
||||
$args[$k] = $this->escape($v);
|
||||
} elseif (is_string($v)) {
|
||||
$args[$k] = str_replace('%', '%%', $v);
|
||||
|
|
|
@ -56,8 +56,7 @@ abstract class FileLoader extends Loader
|
|||
} else if (null !== $currentPath && file_exists($currentPath.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $currentPath.DIRECTORY_SEPARATOR.$file;
|
||||
} else {
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
foreach ($this->paths as $path) {
|
||||
if (file_exists($path.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $path.DIRECTORY_SEPARATOR.$file;
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@ class IniFileLoader extends FileLoader
|
|||
}
|
||||
|
||||
if (isset($result['parameters']) && is_array($result['parameters'])) {
|
||||
foreach ($result['parameters'] as $key => $value)
|
||||
{
|
||||
foreach ($result['parameters'] as $key => $value) {
|
||||
$configuration->setParameter(strtolower($key), $value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,8 +127,7 @@ class XmlFileLoader extends FileLoader
|
|||
$definition = new Definition((string) $service['class']);
|
||||
|
||||
foreach (array('shared', 'constructor') as $key) {
|
||||
if (isset($service[$key]))
|
||||
{
|
||||
if (isset($service[$key])) {
|
||||
$method = 'set'.ucfirst($key);
|
||||
$definition->$method((string) $service->getAttributeAsPhp($key));
|
||||
}
|
||||
|
@ -141,12 +140,10 @@ class XmlFileLoader extends FileLoader
|
|||
$definition->setArguments($service->getArgumentsAsPhp('argument'));
|
||||
|
||||
if (isset($service->configurator)) {
|
||||
if (isset($service->configurator['function']))
|
||||
{
|
||||
if (isset($service->configurator['function'])) {
|
||||
$definition->setConfigurator((string) $service->configurator['function']);
|
||||
} else {
|
||||
if (isset($service->configurator['service']))
|
||||
{
|
||||
if (isset($service->configurator['service'])) {
|
||||
$class = new Reference((string) $service->configurator['service']);
|
||||
} else {
|
||||
$class = (string) $service->configurator['class'];
|
||||
|
@ -163,8 +160,7 @@ class XmlFileLoader extends FileLoader
|
|||
foreach ($service->annotation as $annotation) {
|
||||
$parameters = array();
|
||||
foreach ($annotation->attributes() as $name => $value) {
|
||||
if ('name' === $name)
|
||||
{
|
||||
if ('name' === $name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -240,8 +236,7 @@ class XmlFileLoader extends FileLoader
|
|||
if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) {
|
||||
$items = preg_split('/\s+/', $element);
|
||||
for ($i = 0, $nb = count($items); $i < $nb; $i += 2) {
|
||||
if ($extension = static::getExtension($items[$i]))
|
||||
{
|
||||
if ($extension = static::getExtension($items[$i])) {
|
||||
$path = str_replace('http://www.symfony-project.org/', str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);
|
||||
|
||||
if (!file_exists($path)) {
|
||||
|
@ -284,8 +279,7 @@ EOF
|
|||
protected function validateExtensions($dom, $file)
|
||||
{
|
||||
foreach ($dom->documentElement->childNodes as $node) {
|
||||
if (!$node instanceof \DOMElement || in_array($node->tagName, array('imports', 'parameters', 'services')))
|
||||
{
|
||||
if (!$node instanceof \DOMElement || in_array($node->tagName, array('imports', 'parameters', 'services'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -322,8 +316,7 @@ EOF
|
|||
protected function loadFromExtensions(BuilderConfiguration $configuration, $xml)
|
||||
{
|
||||
foreach (dom_import_simplexml($xml)->childNodes as $node) {
|
||||
if (!$node instanceof \DOMElement || $node->namespaceURI === 'http://www.symfony-project.org/schema/dic/services')
|
||||
{
|
||||
if (!$node instanceof \DOMElement || $node->namespaceURI === 'http://www.symfony-project.org/schema/dic/services') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -367,15 +360,13 @@ EOF
|
|||
|
||||
$nodeValue = false;
|
||||
foreach ($element->childNodes as $node) {
|
||||
if ($node instanceof \DOMText)
|
||||
{
|
||||
if ($node instanceof \DOMText) {
|
||||
if (trim($node->nodeValue)) {
|
||||
$nodeValue = trim($node->nodeValue);
|
||||
$empty = false;
|
||||
}
|
||||
} elseif (!$node instanceof \DOMComment) {
|
||||
if (isset($config[$node->localName]))
|
||||
{
|
||||
if (isset($config[$node->localName])) {
|
||||
if (!is_array($config[$node->localName])) {
|
||||
$config[$node->localName] = array($config[$node->localName]);
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ class YamlFileLoader extends FileLoader
|
|||
|
||||
// parameters
|
||||
if (isset($content['parameters'])) {
|
||||
foreach ($content['parameters'] as $key => $value)
|
||||
{
|
||||
foreach ($content['parameters'] as $key => $value) {
|
||||
$configuration->setParameter(strtolower($key), $this->resolveServices($value));
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +142,7 @@ class YamlFileLoader extends FileLoader
|
|||
}
|
||||
|
||||
if (isset($service['configurator'])) {
|
||||
if (is_string($service['configurator']))
|
||||
{
|
||||
if (is_string($service['configurator'])) {
|
||||
$definition->setConfigurator($service['configurator']);
|
||||
} else {
|
||||
$definition->setConfigurator(array($this->resolveServices($service['configurator'][0]), $service['configurator'][1]));
|
||||
|
@ -152,15 +150,13 @@ class YamlFileLoader extends FileLoader
|
|||
}
|
||||
|
||||
if (isset($service['calls'])) {
|
||||
foreach ($service['calls'] as $call)
|
||||
{
|
||||
foreach ($service['calls'] as $call) {
|
||||
$definition->addMethodCall($call[0], $this->resolveServices($call[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($service['annotations'])) {
|
||||
foreach ($service['annotations'] as $annotation)
|
||||
{
|
||||
foreach ($service['annotations'] as $annotation) {
|
||||
$name = $annotation['name'];
|
||||
unset($annotation['name']);
|
||||
|
||||
|
@ -190,8 +186,7 @@ class YamlFileLoader extends FileLoader
|
|||
}
|
||||
|
||||
foreach (array_keys($content) as $key) {
|
||||
if (in_array($key, array('imports', 'parameters', 'services')))
|
||||
{
|
||||
if (in_array($key, array('imports', 'parameters', 'services'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -227,8 +222,7 @@ class YamlFileLoader extends FileLoader
|
|||
protected function loadFromExtensions(BuilderConfiguration $configuration, $content)
|
||||
{
|
||||
foreach ($content as $key => $values) {
|
||||
if (in_array($key, array('imports', 'parameters', 'services')))
|
||||
{
|
||||
if (in_array($key, array('imports', 'parameters', 'services'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,8 +191,7 @@ class Crawler extends \SplObjectStorage
|
|||
public function eq($position)
|
||||
{
|
||||
foreach ($this as $i => $node) {
|
||||
if ($i == $position)
|
||||
{
|
||||
if ($i == $position) {
|
||||
return new static($node, $this->uri);
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +238,7 @@ class Crawler extends \SplObjectStorage
|
|||
{
|
||||
$nodes = array();
|
||||
foreach ($this as $i => $node) {
|
||||
if (false !== $closure($node, $i))
|
||||
{
|
||||
if (false !== $closure($node, $i)) {
|
||||
$nodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
@ -331,8 +329,7 @@ class Crawler extends \SplObjectStorage
|
|||
$nodes = array();
|
||||
|
||||
while ($node = $node->parentNode) {
|
||||
if (1 === $node->nodeType && '_root' !== $node->nodeName)
|
||||
{
|
||||
if (1 === $node->nodeType && '_root' !== $node->nodeName) {
|
||||
$nodes[] = $node;
|
||||
}
|
||||
}
|
||||
|
@ -413,8 +410,7 @@ class Crawler extends \SplObjectStorage
|
|||
foreach ($this as $node) {
|
||||
$elements = array();
|
||||
foreach ($attributes as $attribute) {
|
||||
if ('_text' === $attribute)
|
||||
{
|
||||
if ('_text' === $attribute) {
|
||||
$elements[] = $node->nodeValue;
|
||||
} else {
|
||||
$elements[] = $node->getAttribute($attribute);
|
||||
|
@ -563,8 +559,7 @@ class Crawler extends \SplObjectStorage
|
|||
protected function getNode($position)
|
||||
{
|
||||
foreach ($this as $i => $node) {
|
||||
if ($i == $position)
|
||||
{
|
||||
if ($i == $position) {
|
||||
return $node;
|
||||
}
|
||||
// @codeCoverageIgnoreStart
|
||||
|
@ -594,8 +589,7 @@ class Crawler extends \SplObjectStorage
|
|||
$nodes = array();
|
||||
|
||||
do {
|
||||
if ($node !== $this->getNode(0) && $node->nodeType === 1)
|
||||
{
|
||||
if ($node !== $this->getNode(0) && $node->nodeType === 1) {
|
||||
$nodes[] = $node;
|
||||
}
|
||||
} while($node = $node->$siblingDir);
|
||||
|
@ -616,8 +610,7 @@ class Crawler extends \SplObjectStorage
|
|||
$string = $s;
|
||||
$parts = array();
|
||||
while (true) {
|
||||
if (false !== $pos = strpos($string, "'"))
|
||||
{
|
||||
if (false !== $pos = strpos($string, "'")) {
|
||||
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
|
||||
$parts[] = "\"'\"";
|
||||
$string = substr($string, $pos + 1);
|
||||
|
|
|
@ -57,15 +57,13 @@ class ChoiceFormField extends FormField
|
|||
// check
|
||||
$this->value = $this->options[0];
|
||||
} else {
|
||||
if (is_array($value))
|
||||
{
|
||||
if (is_array($value)) {
|
||||
if (!$this->multiple) {
|
||||
throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name));
|
||||
}
|
||||
|
||||
foreach ($value as $v) {
|
||||
if (!in_array($v, $this->options))
|
||||
{
|
||||
if (!in_array($v, $this->options)) {
|
||||
throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->options)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ class Form
|
|||
{
|
||||
$this->button = $node;
|
||||
if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) {
|
||||
do
|
||||
{
|
||||
do {
|
||||
// use the ancestor form element
|
||||
if (null === $node = $node->parentNode) {
|
||||
throw new \LogicException('The selected node does not have a form ancestor.');
|
||||
|
@ -130,8 +129,7 @@ class Form
|
|||
{
|
||||
$values = array();
|
||||
foreach ($this->fields as $name => $field) {
|
||||
if (!$field instanceof Field\FileFormField && $field->hasValue())
|
||||
{
|
||||
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
|
||||
$values[$name] = $field->getValue();
|
||||
}
|
||||
}
|
||||
|
@ -152,8 +150,7 @@ class Form
|
|||
|
||||
$files = array();
|
||||
foreach ($this->fields as $name => $field) {
|
||||
if ($field instanceof Field\FileFormField)
|
||||
{
|
||||
if ($field instanceof Field\FileFormField) {
|
||||
$files[$name] = $field->getValue();
|
||||
}
|
||||
}
|
||||
|
@ -305,8 +302,7 @@ class Form
|
|||
$xpath = new \DOMXPath($document);
|
||||
|
||||
foreach ($xpath->query('descendant::input | descendant::textarea | descendant::select', $root) as $node) {
|
||||
if ($node->hasAttribute('disabled') || !$node->hasAttribute('name'))
|
||||
{
|
||||
if ($node->hasAttribute('disabled') || !$node->hasAttribute('name')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -317,8 +313,7 @@ class Form
|
|||
} elseif ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == $node->getAttribute('type')) {
|
||||
$this->setField(new Field\ChoiceFormField($node));
|
||||
} elseif ('input' == $nodeName && 'radio' == $node->getAttribute('type')) {
|
||||
if ($this->hasField($node->getAttribute('name')))
|
||||
{
|
||||
if ($this->hasField($node->getAttribute('name'))) {
|
||||
$this->getField($node->getAttribute('name'))->addChoice($node);
|
||||
} else {
|
||||
$this->setField(new Field\ChoiceFormField($node));
|
||||
|
|
|
@ -53,8 +53,7 @@ class EventDispatcher
|
|||
}
|
||||
|
||||
foreach ($this->listeners[$name] as $i => $callable) {
|
||||
if ($listener === $callable)
|
||||
{
|
||||
if ($listener === $callable) {
|
||||
unset($this->listeners[$name][$i]);
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +85,7 @@ class EventDispatcher
|
|||
public function notifyUntil(Event $event)
|
||||
{
|
||||
foreach ($this->getListeners($event->getName()) as $listener) {
|
||||
if (call_user_func($listener, $event))
|
||||
{
|
||||
if (call_user_func($listener, $event)) {
|
||||
$event->setProcessed(true);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -292,8 +292,7 @@ class Finder implements \IteratorAggregate
|
|||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
if (!is_dir($dir)) {
|
||||
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,7 @@ class Glob
|
|||
for ($i = 0; $i < $sizeGlob; $i++) {
|
||||
$car = $glob[$i];
|
||||
if ($firstByte) {
|
||||
if ($strictLeadingDot && $car !== '.')
|
||||
{
|
||||
if ($strictLeadingDot && $car !== '.') {
|
||||
$regex .= '(?=[^\.])';
|
||||
}
|
||||
|
||||
|
@ -85,8 +84,7 @@ class Glob
|
|||
} elseif ($car === ',' && $inCurlies) {
|
||||
$regex .= $escaping ? ',' : '|';
|
||||
} elseif ($car === '\\') {
|
||||
if ($escaping)
|
||||
{
|
||||
if ($escaping) {
|
||||
$regex .= '\\\\';
|
||||
$escaping = false;
|
||||
} else {
|
||||
|
|
|
@ -48,8 +48,7 @@ class CustomFilterIterator extends \FilterIterator
|
|||
$fileinfo = $this->getInnerIterator()->current();
|
||||
|
||||
foreach ($this->filters as $filter) {
|
||||
if (false === $filter($fileinfo))
|
||||
{
|
||||
if (false === $filter($fileinfo)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,7 @@ class FilenameFilterIterator extends \FilterIterator
|
|||
if ($this->matchRegexps) {
|
||||
$match = false;
|
||||
foreach ($this->matchRegexps as $regex) {
|
||||
if (preg_match($regex, $fileinfo->getFilename()))
|
||||
{
|
||||
if (preg_match($regex, $fileinfo->getFilename())) {
|
||||
$match = true;
|
||||
break;
|
||||
}
|
||||
|
@ -74,8 +73,7 @@ class FilenameFilterIterator extends \FilterIterator
|
|||
if ($this->noMatchRegexps) {
|
||||
$exclude = false;
|
||||
foreach ($this->noMatchRegexps as $regex) {
|
||||
if (preg_match($regex, $fileinfo->getFilename()))
|
||||
{
|
||||
if (preg_match($regex, $fileinfo->getFilename())) {
|
||||
$exclude = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ class SizeRangeFilterIterator extends \FilterIterator
|
|||
|
||||
$filesize = $fileinfo->getSize();
|
||||
foreach ($this->patterns as $compare) {
|
||||
if (!$compare->test($filesize))
|
||||
{
|
||||
if (!$compare->test($filesize)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,10 @@ class CacheControl
|
|||
$parts = array();
|
||||
ksort($this->attributes);
|
||||
foreach ($this->attributes as $key => $value) {
|
||||
if (true === $value)
|
||||
{
|
||||
if (true === $value) {
|
||||
$parts[] = $key;
|
||||
} else {
|
||||
if (preg_match('#[^a-zA-Z0-9._-]#', $value))
|
||||
{
|
||||
if (preg_match('#[^a-zA-Z0-9._-]#', $value)) {
|
||||
$value = '"'.$value.'"';
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ class HttpKernel implements HttpKernelInterface
|
|||
try {
|
||||
return $this->handleRaw($request, $main);
|
||||
} catch (\Exception $e) {
|
||||
if (true === $raw)
|
||||
{
|
||||
if (true === $raw) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
@ -130,8 +129,7 @@ class HttpKernel implements HttpKernelInterface
|
|||
// controller
|
||||
$event = $this->dispatcher->notifyUntil(new Event($this, 'core.controller', array('main_request' => $main, 'request' => $request, 'controller' => &$controller, 'arguments' => &$arguments)));
|
||||
if ($event->isProcessed()) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
return $this->filterResponse($event->getReturnValue(), $request, 'A "core.controller" listener returned a non response object.', $main);
|
||||
} catch (\Exception $e) {
|
||||
$retval = $event->getReturnValue();
|
||||
|
|
|
@ -309,8 +309,7 @@ class Request
|
|||
public function getMethod()
|
||||
{
|
||||
if (null === $this->method) {
|
||||
switch ($this->server->get('REQUEST_METHOD', 'GET'))
|
||||
{
|
||||
switch ($this->server->get('REQUEST_METHOD', 'GET')) {
|
||||
case 'POST':
|
||||
$this->method = strtoupper($this->request->get('_method', 'POST'));
|
||||
break;
|
||||
|
@ -365,8 +364,7 @@ class Request
|
|||
}
|
||||
|
||||
foreach (static::$formats as $format => $mimeTypes) {
|
||||
if (in_array($mimeType, (array) $mimeTypes))
|
||||
{
|
||||
if (in_array($mimeType, (array) $mimeTypes)) {
|
||||
return $format;
|
||||
}
|
||||
}
|
||||
|
@ -456,8 +454,7 @@ class Request
|
|||
|
||||
$languages = $this->splitHttpAcceptHeader($this->headers->get('Accept-Language'));
|
||||
foreach ($languages as $lang) {
|
||||
if (strstr($lang, '-'))
|
||||
{
|
||||
if (strstr($lang, '-')) {
|
||||
$codes = explode('-', $lang);
|
||||
if ($codes[0] == 'i') {
|
||||
// Language not listed in ISO 639 that are not variants
|
||||
|
@ -467,8 +464,7 @@ class Request
|
|||
$lang = $codes[1];
|
||||
}
|
||||
} else {
|
||||
for ($i = 0, $max = count($codes); $i < $max; $i++)
|
||||
{
|
||||
for ($i = 0, $max = count($codes); $i < $max; $i++) {
|
||||
if ($i == 0) {
|
||||
$lang = strtolower($codes[0]);
|
||||
} else {
|
||||
|
@ -725,8 +721,7 @@ class Request
|
|||
{
|
||||
$headers = array();
|
||||
foreach ($this->server->all() as $key => $value) {
|
||||
if ('http_' === strtolower(substr($key, 0, 5)))
|
||||
{
|
||||
if ('http_' === strtolower(substr($key, 0, 5))) {
|
||||
$headers[substr($key, 5)] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,8 +203,7 @@ class Response
|
|||
public function setCookie($name, $value, $expire = null, $path = '/', $domain = '', $secure = false, $httpOnly = false)
|
||||
{
|
||||
if (null !== $expire) {
|
||||
if (is_numeric($expire))
|
||||
{
|
||||
if (is_numeric($expire)) {
|
||||
$expire = (int) $expire;
|
||||
} else {
|
||||
$expire = strtotime($expire);
|
||||
|
|
|
@ -118,8 +118,7 @@ class ResponseTester extends Tester
|
|||
{
|
||||
$headers = explode(', ', $this->response->headers->get($key));
|
||||
foreach ($headers as $header) {
|
||||
if ($header == $value)
|
||||
{
|
||||
if ($header == $value) {
|
||||
return $this->test->pass(sprintf('Response header "%s" is "%s" (%s)', $key, $value, $this->response->headers->get($key)));
|
||||
}
|
||||
}
|
||||
|
@ -137,8 +136,7 @@ class ResponseTester extends Tester
|
|||
{
|
||||
$headers = explode(', ', $this->response->headers->get($key));
|
||||
foreach ($headers as $header) {
|
||||
if ($header == $value)
|
||||
{
|
||||
if ($header == $value) {
|
||||
return $this->test->fail(sprintf('Response header "%s" is not "%s" (%s)', $key, $value, $this->response->headers->get($key)));
|
||||
}
|
||||
}
|
||||
|
@ -156,8 +154,7 @@ class ResponseTester extends Tester
|
|||
{
|
||||
$headers = explode(', ', $this->response->headers->get($key));
|
||||
foreach ($headers as $header) {
|
||||
if (preg_match($regex, $header))
|
||||
{
|
||||
if (preg_match($regex, $header)) {
|
||||
return $this->test->pass(sprintf('Response header "%s" matches "%s" (%s)', $key, $value, $this->response->headers->get($key)));
|
||||
}
|
||||
}
|
||||
|
@ -175,8 +172,7 @@ class ResponseTester extends Tester
|
|||
{
|
||||
$headers = explode(', ', $this->response->headers->get($key));
|
||||
foreach ($headers as $header) {
|
||||
if (!preg_match($regex, $header))
|
||||
{
|
||||
if (!preg_match($regex, $header)) {
|
||||
return $this->test->pass(sprintf('Response header "%s" matches "%s" (%s)', $key, $value, $this->response->headers->get($key)));
|
||||
}
|
||||
}
|
||||
|
@ -194,8 +190,7 @@ class ResponseTester extends Tester
|
|||
public function assertCookie($name, $value = null, $attributes = array())
|
||||
{
|
||||
foreach ($this->response->getCookies() as $cookie) {
|
||||
if ($name == $cookie['name'])
|
||||
{
|
||||
if ($name == $cookie['name']) {
|
||||
if (null === $value) {
|
||||
$this->test->pass(sprintf('Response sets cookie "%s"', $name));
|
||||
} else {
|
||||
|
@ -203,8 +198,7 @@ class ResponseTester extends Tester
|
|||
}
|
||||
|
||||
foreach ($attributes as $attributeName => $attributeValue) {
|
||||
if (!array_key_exists($attributeName, $cookie))
|
||||
{
|
||||
if (!array_key_exists($attributeName, $cookie)) {
|
||||
throw new \LogicException(sprintf('The cookie attribute "%s" is not valid.', $attributeName));
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,7 @@ abstract class Escaper
|
|||
}
|
||||
|
||||
if (is_object($value)) {
|
||||
if ($value instanceof Escaper)
|
||||
{
|
||||
if ($value instanceof Escaper) {
|
||||
// avoid double decoration
|
||||
$copy = clone $value;
|
||||
|
||||
|
@ -165,8 +164,7 @@ abstract class Escaper
|
|||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $name => $v)
|
||||
{
|
||||
foreach ($value as $name => $v) {
|
||||
$value[$name] = self::unescape($v);
|
||||
}
|
||||
|
||||
|
@ -194,8 +192,7 @@ abstract class Escaper
|
|||
}
|
||||
|
||||
foreach (self::$safeClasses as $safeClass) {
|
||||
if (is_subclass_of($class, $safeClass))
|
||||
{
|
||||
if (is_subclass_of($class, $safeClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,7 @@ class PhpProcess extends Process
|
|||
static public function getPhpBinary()
|
||||
{
|
||||
if (getenv('PHP_PATH')) {
|
||||
if (!is_executable($php = getenv('PHP_PATH')))
|
||||
{
|
||||
if (!is_executable($php = getenv('PHP_PATH'))) {
|
||||
throw new \RuntimeException('The defined PHP_PATH environment variable is not a valid PHP executable.');
|
||||
}
|
||||
|
||||
|
@ -79,8 +78,7 @@ class PhpProcess extends Process
|
|||
|
||||
$suffixes = DIRECTORY_SEPARATOR == '\\' ? (getenv('PATHEXT') ? explode(PATH_SEPARATOR, getenv('PATHEXT')) : array('.exe', '.bat', '.cmd', '.com')) : array('');
|
||||
foreach ($suffixes as $suffix) {
|
||||
if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix))
|
||||
{
|
||||
if (is_executable($php = PHP_BINDIR.DIRECTORY_SEPARATOR.'php'.$suffix)) {
|
||||
return $php;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,8 +83,7 @@ class UrlGenerator implements UrlGeneratorInterface
|
|||
$url = '';
|
||||
$optional = true;
|
||||
foreach ($tokens as $token) {
|
||||
if ('variable' === $token[0])
|
||||
{
|
||||
if ('variable' === $token[0]) {
|
||||
if (false === $optional || !isset($defaults[$token[3]]) || (isset($parameters[$token[3]]) && $parameters[$token[3]] != $defaults[$token[3]])) {
|
||||
// check requirement
|
||||
if (isset($requirements[$token[3]]) && !preg_match('#^'.$requirements[$token[3]].'$#', $tparams[$token[3]])) {
|
||||
|
|
|
@ -56,8 +56,7 @@ abstract class FileLoader implements LoaderInterface
|
|||
} else if (null !== $currentPath && file_exists($currentPath.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $currentPath.DIRECTORY_SEPARATOR.$file;
|
||||
} else {
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
foreach ($this->paths as $path) {
|
||||
if (file_exists($path.DIRECTORY_SEPARATOR.$file)) {
|
||||
return $path.DIRECTORY_SEPARATOR.$file;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ class XmlFileLoader extends FileLoader
|
|||
|
||||
// process routes and imports
|
||||
foreach ($xml->documentElement->childNodes as $node) {
|
||||
if (!$node instanceof \DOMElement)
|
||||
{
|
||||
if (!$node instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -71,8 +70,7 @@ class XmlFileLoader extends FileLoader
|
|||
$options = array();
|
||||
|
||||
foreach ($definition->childNodes as $node) {
|
||||
if (!$node instanceof \DOMElement)
|
||||
{
|
||||
if (!$node instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@ class YamlFileLoader extends FileLoader
|
|||
$collection->addResource(new FileResource($path));
|
||||
|
||||
foreach ($config as $name => $config) {
|
||||
if (isset($config['resource']))
|
||||
{
|
||||
if (isset($config['resource'])) {
|
||||
$this->parseImport($collection, $name, $config, $path);
|
||||
} elseif (isset($config['pattern'])) {
|
||||
$this->parseRoute($collection, $name, $config, $path);
|
||||
|
|
|
@ -56,8 +56,7 @@ class ApacheUrlMatcher extends UrlMatcher
|
|||
|
||||
$parameters = array();
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if ('_ROUTING_' === substr($key, 0, 9))
|
||||
{
|
||||
if ('_ROUTING_' === substr($key, 0, 9)) {
|
||||
$parameters[substr($key, 9)] = $value;
|
||||
unset($_SERVER[$key]);
|
||||
}
|
||||
|
|
|
@ -81,8 +81,7 @@ class UrlMatcher implements UrlMatcherInterface
|
|||
{
|
||||
$parameters = array_merge($this->defaults, $defaults);
|
||||
foreach ($params as $key => $value) {
|
||||
if (!is_int($key))
|
||||
{
|
||||
if (!is_int($key)) {
|
||||
$parameters[$key] = urldecode($value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,8 +188,7 @@ class Route
|
|||
{
|
||||
$this->requirements = array();
|
||||
foreach ($requirements as $key => $regex) {
|
||||
if ('^' == $regex[0])
|
||||
{
|
||||
if ('^' == $regex[0]) {
|
||||
$regex = substr($regex, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,7 @@ class RouteCompiler implements RouteCompilerInterface
|
|||
// optimize tokens for generation
|
||||
$tokens = array();
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
if ($i + 1 === count($this->tokens) && 'separator' === $token[0])
|
||||
{
|
||||
if ($i + 1 === count($this->tokens) && 'separator' === $token[0]) {
|
||||
// trailing /
|
||||
$tokens[] = array('text', $token[2], '', null);
|
||||
} elseif ('separator' !== $token[0]) {
|
||||
|
@ -103,8 +102,7 @@ class RouteCompiler implements RouteCompilerInterface
|
|||
|
||||
$this->staticPrefix = '';
|
||||
foreach ($this->tokens as $token) {
|
||||
switch ($token[0])
|
||||
{
|
||||
switch ($token[0]) {
|
||||
case 'separator':
|
||||
break;
|
||||
case 'text':
|
||||
|
@ -132,8 +130,7 @@ class RouteCompiler implements RouteCompilerInterface
|
|||
|
||||
// a route is an array of (separator + variable) or (separator + text) segments
|
||||
while (strlen($buffer)) {
|
||||
if (false !== $this->tokenizeBufferBefore($buffer, $tokens, $afterASeparator, $currentSeparator))
|
||||
{
|
||||
if (false !== $this->tokenizeBufferBefore($buffer, $tokens, $afterASeparator, $currentSeparator)) {
|
||||
// a custom token
|
||||
$this->customToken = true;
|
||||
} else if ($afterASeparator && preg_match('#^'.$this->options['variable_prefix_regex'].'('.$this->options['variable_regex'].')#', $buffer, $match)) {
|
||||
|
|
|
@ -224,8 +224,7 @@ class Router implements RouterInterface
|
|||
$time = filemtime($file);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
foreach ($meta as $resource) {
|
||||
if (!$resource->isUptodate($time))
|
||||
{
|
||||
if (!$resource->isUptodate($time)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ class SlotsHelper extends Helper
|
|||
public function output($name, $default = false)
|
||||
{
|
||||
if (!isset($this->slots[$name])) {
|
||||
if (false !== $default)
|
||||
{
|
||||
if (false !== $default) {
|
||||
echo $default;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -66,8 +66,7 @@ class CacheLoader extends Loader
|
|||
}
|
||||
|
||||
if (file_exists($path)) {
|
||||
if (null !== $this->debugger)
|
||||
{
|
||||
if (null !== $this->debugger) {
|
||||
$this->debugger->log(sprintf('Fetching template "%s" from cache', $template));
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ class ChainLoader extends Loader
|
|||
public function load($template, array $options = array())
|
||||
{
|
||||
foreach ($this->loaders as $loader) {
|
||||
if (false !== $ret = $loader->load($template, $options))
|
||||
{
|
||||
if (false !== $ret = $loader->load($template, $options)) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,8 +65,7 @@ class FilesystemLoader extends Loader
|
|||
|
||||
$logs = array();
|
||||
foreach ($this->templatePathPatterns as $templatePathPattern) {
|
||||
if (is_file($file = strtr($templatePathPattern, $replacements)))
|
||||
{
|
||||
if (is_file($file = strtr($templatePathPattern, $replacements))) {
|
||||
if (null !== $this->debugger) {
|
||||
$this->debugger->log(sprintf('Loaded template file "%s" (renderer: %s)', $file, $options['renderer']));
|
||||
}
|
||||
|
@ -80,8 +79,7 @@ class FilesystemLoader extends Loader
|
|||
}
|
||||
|
||||
if (null !== $this->debugger) {
|
||||
foreach ($logs as $log)
|
||||
{
|
||||
foreach ($logs as $log) {
|
||||
$this->debugger->log($log);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,8 +232,7 @@ class Inline
|
|||
|
||||
// [foo, bar, ...]
|
||||
while ($i < $len) {
|
||||
switch ($sequence[$i])
|
||||
{
|
||||
switch ($sequence[$i]) {
|
||||
case '[':
|
||||
// nested sequence
|
||||
$output[] = self::parseSequence($sequence, $i);
|
||||
|
@ -289,8 +288,7 @@ class Inline
|
|||
|
||||
// {foo: bar, bar:foo, ...}
|
||||
while ($i < $len) {
|
||||
switch ($mapping[$i])
|
||||
{
|
||||
switch ($mapping[$i]) {
|
||||
case ' ':
|
||||
case ',':
|
||||
++$i;
|
||||
|
@ -305,8 +303,7 @@ class Inline
|
|||
// value
|
||||
$done = false;
|
||||
while ($i < $len) {
|
||||
switch ($mapping[$i])
|
||||
{
|
||||
switch ($mapping[$i]) {
|
||||
case '[':
|
||||
// nested sequence
|
||||
$output[$key] = self::parseSequence($mapping, $i);
|
||||
|
|
|
@ -57,8 +57,7 @@ class Parser
|
|||
|
||||
$data = array();
|
||||
while ($this->moveToNextLine()) {
|
||||
if ($this->isCurrentLineEmpty())
|
||||
{
|
||||
if ($this->isCurrentLineEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -69,8 +68,7 @@ class Parser
|
|||
|
||||
$isRef = $isInPlace = $isProcessed = false;
|
||||
if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#', $this->currentLine, $values)) {
|
||||
if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#', $values['value'], $matches))
|
||||
{
|
||||
if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#', $values['value'], $matches)) {
|
||||
$isRef = $matches['ref'];
|
||||
$values['value'] = $matches['value'];
|
||||
}
|
||||
|
@ -105,15 +103,13 @@ class Parser
|
|||
$key = Inline::parseScalar($values['key']);
|
||||
|
||||
if ('<<' === $key) {
|
||||
if (isset($values['value']) && '*' === substr($values['value'], 0, 1))
|
||||
{
|
||||
if (isset($values['value']) && '*' === substr($values['value'], 0, 1)) {
|
||||
$isInPlace = substr($values['value'], 1);
|
||||
if (!array_key_exists($isInPlace, $this->refs)) {
|
||||
throw new ParserException(sprintf('Reference "%s" does not exist at line %s (%s).', $isInPlace, $this->getRealCurrentLineNb() + 1, $this->currentLine));
|
||||
}
|
||||
} else {
|
||||
if (isset($values['value']) && $values['value'] !== '')
|
||||
{
|
||||
if (isset($values['value']) && $values['value'] !== '') {
|
||||
$value = $values['value'];
|
||||
} else {
|
||||
$value = $this->getNextEmbedBlock();
|
||||
|
@ -129,8 +125,7 @@ class Parser
|
|||
} else if (isset($parsed[0])) {
|
||||
// Numeric array, merge individual elements
|
||||
foreach (array_reverse($parsed) as $parsedItem) {
|
||||
if (!is_array($parsedItem))
|
||||
{
|
||||
if (!is_array($parsedItem)) {
|
||||
throw new ParserException(sprintf('Merge items must be arrays at line %s (%s).', $this->getRealCurrentLineNb() + 1, $parsedItem));
|
||||
}
|
||||
$merged = array_merge($parsedItem, $merged);
|
||||
|
@ -163,8 +158,7 @@ class Parser
|
|||
$data[$key] = $parser->parse($this->getNextEmbedBlock());
|
||||
}
|
||||
} else {
|
||||
if ($isInPlace)
|
||||
{
|
||||
if ($isInPlace) {
|
||||
$data = $this->refs[$isInPlace];
|
||||
} else {
|
||||
$data[$key] = $this->parseValue($values['value']);
|
||||
|
@ -273,8 +267,7 @@ class Parser
|
|||
$data = array(substr($this->currentLine, $newIndent));
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
if ($this->isCurrentLineEmpty())
|
||||
{
|
||||
if ($this->isCurrentLineEmpty()) {
|
||||
if ($this->isCurrentLineBlank()) {
|
||||
$data[] = substr($this->currentLine, $newIndent);
|
||||
}
|
||||
|
@ -335,8 +328,7 @@ class Parser
|
|||
protected function parseValue($value)
|
||||
{
|
||||
if ('*' === substr($value, 0, 1)) {
|
||||
if (false !== $pos = strpos($value, '#'))
|
||||
{
|
||||
if (false !== $pos = strpos($value, '#')) {
|
||||
$value = substr($value, 1, $pos - 2);
|
||||
} else {
|
||||
$value = substr($value, 1);
|
||||
|
@ -397,8 +389,7 @@ class Parser
|
|||
$this->moveToNextLine();
|
||||
|
||||
if (preg_match('#^(?P<indent> {'.strlen($textIndent).',})(?P<text>.+)$#', $this->currentLine, $matches)) {
|
||||
if (' ' == $separator && $previousIndent != $matches['indent'])
|
||||
{
|
||||
if (' ' == $separator && $previousIndent != $matches['indent']) {
|
||||
$text = substr($text, 0, -1)."\n";
|
||||
}
|
||||
$previousIndent = $matches['indent'];
|
||||
|
|
|
@ -46,8 +46,7 @@ abstract class Bundle implements BundleInterface
|
|||
|
||||
// look for commands
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($commandDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($file->isDir() || substr($file, -4) !== '.php')
|
||||
{
|
||||
if ($file->isDir() || substr($file, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,7 @@ class KernelExtension extends LoaderExtension
|
|||
} else {
|
||||
$classes = array();
|
||||
foreach (explode("\n", $config['compilation']) as $class) {
|
||||
if ($class)
|
||||
{
|
||||
if ($class) {
|
||||
$classes[] = trim($class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ class ClassCollectionLoader
|
|||
if ($meta[1] != $classes) {
|
||||
$reload = true;
|
||||
} else {
|
||||
foreach ($meta[0] as $resource)
|
||||
{
|
||||
foreach ($meta[0] as $resource) {
|
||||
if (!file_exists($resource) || filemtime($resource) > $time) {
|
||||
$reload = true;
|
||||
|
||||
|
@ -61,8 +60,7 @@ class ClassCollectionLoader
|
|||
$files = array();
|
||||
$content = '';
|
||||
foreach ($classes as $class) {
|
||||
if (!class_exists($class) && !interface_exists($class))
|
||||
{
|
||||
if (!class_exists($class) && !interface_exists($class)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
public function notify(Event $event)
|
||||
{
|
||||
foreach ($this->getListeners($event->getName()) as $listener) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Notifying event "%s" to listener "%s"', $event->getName(), $this->listenerToString($listener)));
|
||||
}
|
||||
|
||||
|
@ -71,14 +70,12 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
public function notifyUntil(Event $event)
|
||||
{
|
||||
foreach ($this->getListeners($event->getName()) as $listener) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Notifying (until) event "%s" to listener "%s"', $event->getName(), $this->listenerToString($listener)));
|
||||
}
|
||||
|
||||
if (call_user_func($listener, $event)) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Listener "%s" processed the event "%s"', $this->listenerToString($listener), $event->getName()));
|
||||
}
|
||||
|
||||
|
@ -101,8 +98,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
public function filter(Event $event, $value)
|
||||
{
|
||||
foreach ($this->getListeners($event->getName()) as $listener) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Notifying (filter) event "%s" to listener "%s"', $event->getName(), $this->listenerToString($listener)));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
$this->container = $container;
|
||||
|
||||
foreach ($container->findAnnotatedServiceIds('kernel.listener') as $id => $attributes) {
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
foreach ($attributes as $attribute) {
|
||||
if (isset($attribute['event'])) {
|
||||
$this->connect($attribute['event'], array($id, isset($attribute['method']) ? $attribute['method'] : 'handle'));
|
||||
}
|
||||
|
@ -59,8 +58,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
}
|
||||
|
||||
foreach ($this->listeners[$name] as $i => $listener) {
|
||||
if (is_array($listener) && is_string($listener[0]))
|
||||
{
|
||||
if (is_array($listener) && is_string($listener[0])) {
|
||||
$this->listeners[$name][$i] = array($this->container->getService($listener[0]), $listener[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,8 +280,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||
{
|
||||
$parameters = array();
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if ('SYMFONY__' === substr($key, 0, 9))
|
||||
{
|
||||
if ('SYMFONY__' === substr($key, 0, 9)) {
|
||||
$parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -298,8 +297,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||
$meta = unserialize(file_get_contents($location.'.meta'));
|
||||
$time = filemtime($location.'.php');
|
||||
foreach ($meta as $resource) {
|
||||
if (!$resource->isUptodate($time))
|
||||
{
|
||||
if (!$resource->isUptodate($time)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +320,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||
foreach (array('cache', 'logs') as $name) {
|
||||
$dir = $container->getParameter(sprintf('kernel.%s_dir', $name));
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true))
|
||||
{
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
die(sprintf('Unable to create the %s directory (%s)', $name, dirname($dir)));
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
|
@ -356,8 +353,7 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
|||
{
|
||||
// replace all classes with the real value
|
||||
foreach ($container->getDefinitions() as $definition) {
|
||||
if (false !== strpos($class = $definition->getClass(), '%'))
|
||||
{
|
||||
if (false !== strpos($class = $definition->getClass(), '%')) {
|
||||
$definition->setClass(Builder::resolveValue($class, $container->getParameters()));
|
||||
unset($container[substr($class, 1, -1)]);
|
||||
}
|
||||
|
|
|
@ -130,8 +130,7 @@ EOF;
|
|||
protected function addTestersFromContainer()
|
||||
{
|
||||
foreach ($this->container->findAnnotatedServiceIds('test.tester') as $id => $config) {
|
||||
if (!isset($config[0]['alias']))
|
||||
{
|
||||
if (!isset($config[0]['alias'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,8 +129,7 @@ class UniversalClassLoader
|
|||
// namespaced class name
|
||||
$namespace = substr($class, 0, $pos);
|
||||
foreach ($this->namespaces as $ns => $dir) {
|
||||
if (0 === strpos($namespace, $ns))
|
||||
{
|
||||
if (0 === strpos($namespace, $ns)) {
|
||||
$class = substr($class, $pos + 1);
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
if (file_exists($file)) {
|
||||
|
@ -143,8 +142,7 @@ class UniversalClassLoader
|
|||
} else {
|
||||
// PEAR-like class name
|
||||
foreach ($this->prefixes as $prefix => $dir) {
|
||||
if (0 === strpos($class, $prefix))
|
||||
{
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
|
|
|
@ -32,8 +32,7 @@ abstract class Bundle implements BundleInterface
|
|||
}
|
||||
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($commandDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($file->isDir() || substr($file, -4) !== '.php')
|
||||
{
|
||||
if ($file->isDir() || substr($file, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -167,8 +166,7 @@ class KernelExtension extends LoaderExtension
|
|||
} else {
|
||||
$classes = array();
|
||||
foreach (explode("\n", $config['compilation']) as $class) {
|
||||
if ($class)
|
||||
{
|
||||
if ($class) {
|
||||
$classes[] = trim($class);
|
||||
}
|
||||
}
|
||||
|
@ -270,8 +268,7 @@ class ClassCollectionLoader
|
|||
if ($meta[1] != $classes) {
|
||||
$reload = true;
|
||||
} else {
|
||||
foreach ($meta[0] as $resource)
|
||||
{
|
||||
foreach ($meta[0] as $resource) {
|
||||
if (!file_exists($resource) || filemtime($resource) > $time) {
|
||||
$reload = true;
|
||||
|
||||
|
@ -291,8 +288,7 @@ class ClassCollectionLoader
|
|||
$files = array();
|
||||
$content = '';
|
||||
foreach ($classes as $class) {
|
||||
if (!class_exists($class) && !interface_exists($class))
|
||||
{
|
||||
if (!class_exists($class) && !interface_exists($class)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
|
@ -350,8 +346,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
$this->container = $container;
|
||||
|
||||
foreach ($container->findAnnotatedServiceIds('kernel.listener') as $id => $attributes) {
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
foreach ($attributes as $attribute) {
|
||||
if (isset($attribute['event'])) {
|
||||
$this->connect($attribute['event'], array($id, isset($attribute['method']) ? $attribute['method'] : 'handle'));
|
||||
}
|
||||
|
@ -367,8 +362,7 @@ class EventDispatcher extends BaseEventDispatcher
|
|||
}
|
||||
|
||||
foreach ($this->listeners[$name] as $i => $listener) {
|
||||
if (is_array($listener) && is_string($listener[0]))
|
||||
{
|
||||
if (is_array($listener) && is_string($listener[0])) {
|
||||
$this->listeners[$name][$i] = array($this->container->getService($listener[0]), $listener[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ class Bundle extends BaseBundle
|
|||
$class = basename($tmp);
|
||||
|
||||
if (isset($bundleDirs[$namespace])) {
|
||||
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata'))
|
||||
{
|
||||
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata')) {
|
||||
$metadataDirs[] = realpath($dir);
|
||||
}
|
||||
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) {
|
||||
|
|
|
@ -60,8 +60,7 @@ EOT
|
|||
$bundleClass = null;
|
||||
$bundleDirs = $this->container->getKernelService()->getBundleDirs();
|
||||
foreach ($this->container->getKernelService()->getBundles() as $bundle) {
|
||||
if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false)
|
||||
{
|
||||
if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false) {
|
||||
$tmp = dirname(str_replace('\\', '/', get_class($bundle)));
|
||||
$namespace = str_replace('/', '\\', dirname($tmp));
|
||||
$class = basename($tmp);
|
||||
|
|
|
@ -54,16 +54,14 @@ EOT
|
|||
$found = false;
|
||||
$connections = $this->getDoctrineConnections();
|
||||
foreach ($connections as $name => $connection) {
|
||||
if ($input->getOption('connection') && $name != $input->getOption('connection'))
|
||||
{
|
||||
if ($input->getOption('connection') && $name != $input->getOption('connection')) {
|
||||
continue;
|
||||
}
|
||||
$this->createDatabaseForConnection($connection, $output);
|
||||
$found = true;
|
||||
}
|
||||
if ($found === false) {
|
||||
if ($input->getOption('connection'))
|
||||
{
|
||||
if ($input->getOption('connection')) {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $input->getOption('connection')));
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find any configured connections</error>', $input->getOption('connection')));
|
||||
|
@ -80,7 +78,7 @@ EOT
|
|||
|
||||
$tmpConnection = \Doctrine\DBAL\DriverManager::getConnection($params);
|
||||
|
||||
try {
|
||||
try {
|
||||
$tmpConnection->getSchemaManager()->createDatabase($name);
|
||||
$output->writeln(sprintf('<info>Created database for connection named <comment>%s</comment></info>', $name));
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -163,8 +163,7 @@ abstract class DoctrineCommand extends Command
|
|||
$cmf = new SymfonyDisconnectedClassMetadataFactory($em);
|
||||
$metadatas = $cmf->getAllMetadata();
|
||||
foreach ($metadatas as $metadata) {
|
||||
if (strpos($metadata->name, $namespace) !== false)
|
||||
{
|
||||
if (strpos($metadata->name, $namespace) !== false) {
|
||||
$bundleMetadatas[] = $metadata;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,16 +54,14 @@ EOT
|
|||
$found = false;
|
||||
$connections = $this->getDoctrineConnections();
|
||||
foreach ($connections as $name => $connection) {
|
||||
if ($input->getOption('connection') && $name != $input->getOption('connection'))
|
||||
{
|
||||
if ($input->getOption('connection') && $name != $input->getOption('connection')) {
|
||||
continue;
|
||||
}
|
||||
$this->dropDatabaseForConnection($connection, $output);
|
||||
$found = true;
|
||||
}
|
||||
if ($found === false) {
|
||||
if ($input->getOption('connection'))
|
||||
{
|
||||
if ($input->getOption('connection')) {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find a connection named <comment>%s</comment></error>', $input->getOption('connection')));
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('<error>Could not find any configured connections</error>', $input->getOption('connection')));
|
||||
|
@ -76,7 +74,7 @@ EOT
|
|||
$params = $connection->getParams();
|
||||
$name = isset($params['path']) ? $params['path']:$params['dbname'];
|
||||
|
||||
try {
|
||||
try {
|
||||
$connection->getSchemaManager()->dropDatabase($name);
|
||||
$output->writeln(sprintf('<info>Dropped database for connection named <comment>%s</comment></info>', $name));
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -54,8 +54,7 @@ EOT
|
|||
if ($metadatas = $this->getBundleMetadatas($bundle)) {
|
||||
$output->writeln(sprintf('Generating entity repositories for "<info>%s</info>"', $class));
|
||||
foreach ($metadatas as $metadata) {
|
||||
if ($metadata->customRepositoryClassName)
|
||||
{
|
||||
if ($metadata->customRepositoryClassName) {
|
||||
$output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->customRepositoryClassName));
|
||||
$generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $destination);
|
||||
}
|
||||
|
|
|
@ -58,8 +58,7 @@ EOT
|
|||
$bundleClass = null;
|
||||
$bundleDirs = $this->container->getKernelService()->getBundleDirs();
|
||||
foreach ($this->container->getKernelService()->getBundles() as $bundle) {
|
||||
if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false)
|
||||
{
|
||||
if (strpos(get_class($bundle), $input->getArgument('bundle')) !== false) {
|
||||
$tmp = dirname(str_replace('\\', '/', get_class($bundle)));
|
||||
$namespace = str_replace('/', '\\', dirname($tmp));
|
||||
$class = basename($tmp);
|
||||
|
|
|
@ -78,8 +78,7 @@ EOT
|
|||
|
||||
$files = array();
|
||||
foreach ($paths as $path) {
|
||||
if (is_dir($path))
|
||||
{
|
||||
if (is_dir($path)) {
|
||||
$finder = new Finder();
|
||||
$found = iterator_to_array($finder
|
||||
->files()
|
||||
|
@ -117,8 +116,7 @@ EOT
|
|||
$emEntities[$emName][] = $value;
|
||||
}
|
||||
foreach ($ems as $emName => $em) {
|
||||
if (!$input->getOption('append'))
|
||||
{
|
||||
if (!$input->getOption('append')) {
|
||||
$output->writeln(sprintf('<info>Purging data from entity manager named <comment>"%s"</comment></info>', $emName));
|
||||
$this->purgeEntityManager($em);
|
||||
}
|
||||
|
@ -146,8 +144,7 @@ EOT
|
|||
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
||||
|
||||
foreach ($metadatas as $metadata) {
|
||||
if (!$metadata->isMappedSuperclass)
|
||||
{
|
||||
if (!$metadata->isMappedSuperclass) {
|
||||
$classes[] = $metadata;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +171,7 @@ EOT
|
|||
if ($assoc->isOwningSide) {
|
||||
$targetClass = $em->getClassMetadata($assoc->targetEntityName);
|
||||
|
||||
if ( ! $calc->hasClass($targetClass->name)) {
|
||||
if ( ! $calc->hasClass($targetClass->name)) {
|
||||
$calc->addClass($targetClass);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
|
||||
$connections = array();
|
||||
if (isset($config['connections'])) {
|
||||
foreach ($config['connections'] as $name => $connection)
|
||||
{
|
||||
foreach ($config['connections'] as $name => $connection) {
|
||||
$connections[isset($connection['id']) ? $connection['id'] : $name] = $connection;
|
||||
}
|
||||
} else {
|
||||
|
@ -122,8 +121,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
$driverOptions['driverOptions'] = $connection['options'];
|
||||
}
|
||||
foreach (array('dbname', 'host', 'user', 'password', 'path', 'port') as $key) {
|
||||
if (isset($connection[$key]))
|
||||
{
|
||||
if (isset($connection[$key])) {
|
||||
$driverOptions[$key] = $connection[$key];
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +160,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
|
||||
$config['default_entity_manager'] = isset($config['default_entity_manager']) ? $config['default_entity_manager'] : 'default';
|
||||
foreach (array('metadata_driver', 'cache_driver') as $key) {
|
||||
if (isset($config[$key]))
|
||||
{
|
||||
if (isset($config[$key])) {
|
||||
$configuration->setParameter('doctrine.orm.'.$key, $config[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -205,8 +202,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
}
|
||||
|
||||
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities')) {
|
||||
if ($type === false)
|
||||
{
|
||||
if ($type === false) {
|
||||
$type = 'annotation';
|
||||
}
|
||||
$aliasMap[$class] = $namespace.'\\'.$class.'\\Entities';
|
||||
|
|
|
@ -107,8 +107,7 @@ class ProfilerStorage
|
|||
$stmt = $db->prepare($query);
|
||||
|
||||
if ($db instanceof \SQLite3) {
|
||||
foreach ($args as $arg => $val)
|
||||
{
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT);
|
||||
}
|
||||
$res = $stmt->execute();
|
||||
|
@ -118,8 +117,7 @@ class ProfilerStorage
|
|||
$res->finalize();
|
||||
$stmt->close();
|
||||
} else {
|
||||
foreach ($args as $arg => $val)
|
||||
{
|
||||
foreach ($args as $arg => $val) {
|
||||
$stmt->bindValue($arg, $val, is_int($val) ? \PDO::PARAM_INT : \PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
|
|
|
@ -69,8 +69,7 @@ class SwiftMailerExtension extends LoaderExtension
|
|||
}
|
||||
|
||||
foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode') as $key) {
|
||||
if (isset($config[$key]))
|
||||
{
|
||||
if (isset($config[$key])) {
|
||||
$configuration->setParameter('swiftmailer.transport.'.$config['transport'].'.'.$key, $config[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +83,7 @@ class SwiftMailerExtension extends LoaderExtension
|
|||
$configuration->setAlias('swiftmailer.spool', 'swiftmailer.spool.'.$type);
|
||||
|
||||
foreach (array('path') as $key) {
|
||||
if (isset($config['spool'][$key]))
|
||||
{
|
||||
if (isset($config['spool'][$key])) {
|
||||
$configuration->setParameter('swiftmailer.spool.'.$type.'.'.$key, $config['spool'][$key]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,8 +140,7 @@ EOF
|
|||
|
||||
$tokens = '';
|
||||
foreach ($route->getTokens() as $token) {
|
||||
if (!$tokens)
|
||||
{
|
||||
if (!$tokens) {
|
||||
$tokens = $this->displayToken($token);
|
||||
} else {
|
||||
$tokens .= "\n".str_repeat(' ', 13).$this->displayToken($token);
|
||||
|
|
|
@ -61,14 +61,13 @@ class ExceptionController extends Controller
|
|||
|
||||
$errors = 0;
|
||||
foreach ($logs as $log) {
|
||||
if ('ERR' === $log['priorityName'])
|
||||
{
|
||||
if ('ERR' === $log['priorityName']) {
|
||||
++$errors;
|
||||
}
|
||||
}
|
||||
|
||||
$currentContent = '';
|
||||
while (false !== $content = ob_get_clean()) { $currentContent .= $content; }
|
||||
while (false !== $content = ob_get_clean()) { $currentContent .= $content; }
|
||||
|
||||
ob_start();
|
||||
require $template;
|
||||
|
|
|
@ -118,8 +118,7 @@ class ExceptionFormatter
|
|||
$single and $args = array($args);
|
||||
|
||||
foreach ($args as $key => $value) {
|
||||
if (is_object($value))
|
||||
{
|
||||
if (is_object($value)) {
|
||||
$formattedValue = ($format == 'html' ? '<em>object</em>' : 'object').sprintf("('%s')", get_class($value));
|
||||
} else if (is_array($value)) {
|
||||
$formattedValue = ($format == 'html' ? '<em>array</em>' : 'array').sprintf("(%s)", $this->formatArgs($value));
|
||||
|
|
|
@ -61,8 +61,7 @@ class WebExtension extends LoaderExtension
|
|||
}
|
||||
|
||||
foreach (array('name', 'auto_start', 'lifetime', 'path', 'domain', 'secure', 'httponly', 'cache_limiter', 'pdo.db_table') as $name) {
|
||||
if (isset($config['session'][$name]))
|
||||
{
|
||||
if (isset($config['session'][$name])) {
|
||||
$configuration->setParameter('session.options.'.$name, $config['session'][$name]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,7 @@ class ControllerLoader
|
|||
$request = $event->getParameter('request');
|
||||
|
||||
if (!($bundle = $request->path->get('_bundle')) || !($controller = $request->path->get('_controller')) || !($action = $request->path->get('_action'))) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->err(sprintf('Unable to look for the controller as some mandatory parameters are missing (_bundle: %s, _controller: %s, _action: %s)', isset($bundle) ? var_export($bundle, true) : 'NULL', isset($controller) ? var_export($controller, true) : 'NULL', isset($action) ? var_export($action, true) : 'NULL'));
|
||||
}
|
||||
|
||||
|
@ -88,8 +87,7 @@ class ControllerLoader
|
|||
foreach (array_keys($this->container->getParameter('kernel.bundle_dirs')) as $namespace) {
|
||||
$try = $namespace.'\\'.$bundle.'\\Controller\\'.$controller.'Controller';
|
||||
if (!class_exists($try)) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$logs[] = sprintf('Failed finding controller "%s:%s" from namespace "%s" (%s)', $bundle, $controller, $namespace, $try);
|
||||
}
|
||||
} else {
|
||||
|
@ -105,8 +103,7 @@ class ControllerLoader
|
|||
}
|
||||
|
||||
if (null === $class) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
foreach ($logs as $log) {
|
||||
$this->logger->info($log);
|
||||
}
|
||||
|
@ -136,8 +133,7 @@ class ControllerLoader
|
|||
{
|
||||
$arguments = array();
|
||||
foreach ($r->getParameters() as $param) {
|
||||
if (array_key_exists($param->getName(), $parameters))
|
||||
{
|
||||
if (array_key_exists($param->getName(), $parameters)) {
|
||||
$arguments[] = $parameters[$param->getName()];
|
||||
} elseif ($param->isDefaultValueAvailable()) {
|
||||
$arguments[] = $param->getDefaultValue();
|
||||
|
|
|
@ -64,8 +64,7 @@ class RequestParser
|
|||
}
|
||||
|
||||
if (false !== $parameters = $this->router->match($request->getPathInfo())) {
|
||||
if (null !== $this->logger)
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info(sprintf('Matched route "%s" (parameters: %s)', $parameters['_route'], str_replace("\n", '', var_export($parameters, true))));
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ class Engine extends BaseEngine
|
|||
|
||||
$this->helpers = array();
|
||||
foreach ($this->container->findAnnotatedServiceIds('templating.helper') as $id => $attributes) {
|
||||
if (isset($attributes[0]['alias']))
|
||||
{
|
||||
if (isset($attributes[0]['alias'])) {
|
||||
$this->helpers[$attributes[0]['alias']] = $id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,16 +104,14 @@ class Filesystem
|
|||
|
||||
$files = array_reverse($files);
|
||||
foreach ($files as $file) {
|
||||
if (!file_exists($file))
|
||||
{
|
||||
if (!file_exists($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($file) && !is_link($file)) {
|
||||
$fp = opendir($file);
|
||||
while (false !== $item = readdir($fp)) {
|
||||
if (!in_array($item, array('.', '..')))
|
||||
{
|
||||
if (!in_array($item, array('.', '..'))) {
|
||||
$this->remove($file.'/'.$item);
|
||||
}
|
||||
}
|
||||
|
@ -184,8 +182,7 @@ class Filesystem
|
|||
|
||||
$ok = false;
|
||||
if (is_link($targetDir)) {
|
||||
if (readlink($targetDir) != $originDir)
|
||||
{
|
||||
if (readlink($targetDir) != $originDir) {
|
||||
unlink($targetDir);
|
||||
} else {
|
||||
$ok = true;
|
||||
|
|
|
@ -49,8 +49,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
$loader = new ProjectLoader3(self::$fixturesPath.'/yaml');
|
||||
|
||||
foreach (array('nonvalid1', 'nonvalid2') as $fixture) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$loader->loadFile($fixture.'.yml');
|
||||
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not validate');
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
@ -29,8 +29,7 @@ class RealIteratorTestCase extends IteratorTestCase
|
|||
mkdir($tmpDir);
|
||||
|
||||
foreach (self::$files as $file) {
|
||||
if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1])
|
||||
{
|
||||
if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1]) {
|
||||
touch($file);
|
||||
} else {
|
||||
mkdir($file);
|
||||
|
@ -44,8 +43,7 @@ class RealIteratorTestCase extends IteratorTestCase
|
|||
static public function tearDownAfterClass()
|
||||
{
|
||||
foreach (self::$files as $file) {
|
||||
if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1])
|
||||
{
|
||||
if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1]) {
|
||||
@unlink($file);
|
||||
} else {
|
||||
@rmdir($file);
|
||||
|
|
|
@ -59,8 +59,7 @@ class ArrayDecoratorTest extends \PHPUnit_Framework_TestCase
|
|||
public function testIteratorInterface()
|
||||
{
|
||||
foreach (self::$escaped as $key => $value) {
|
||||
switch ($key)
|
||||
{
|
||||
switch ($key) {
|
||||
case 0:
|
||||
$this->assertEquals('<strong>escaped!</strong>', $value, 'The escaped object behaves like an array');
|
||||
break;
|
||||
|
|
|
@ -40,8 +40,7 @@ class DumperTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
// split YAMLs documents
|
||||
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
||||
if (!$yaml)
|
||||
{
|
||||
if (!$yaml) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
foreach ($this->getTestsForLoad() as $yaml => $value) {
|
||||
if ($value == 1230)
|
||||
{
|
||||
if ($value == 1230) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -45,8 +44,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
foreach ($testsForDump as $yaml => $value) {
|
||||
if ($value == 1230)
|
||||
{
|
||||
if ($value == 1230) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
// split YAMLs documents
|
||||
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
||||
if (!$yaml)
|
||||
{
|
||||
if (!$yaml) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -66,8 +65,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
|
||||
foreach ($yamls as $yaml) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
$content = $this->parser->parse($yaml);
|
||||
|
||||
$this->fail('YAML files must not contain tabs');
|
||||
|
|
|
@ -14,8 +14,7 @@ class ProjectTemplateDebugger implements DebuggerInterface
|
|||
public function hasMessage($regex)
|
||||
{
|
||||
foreach ($this->messages as $message) {
|
||||
if (preg_match('#'.preg_quote($regex, '#').'#', $message))
|
||||
{
|
||||
if (preg_match('#'.preg_quote($regex, '#').'#', $message)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue