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