fixed curlies folding, part three, handled remaining special cases manually

This commit is contained in:
Jordi Boggiano 2010-05-08 15:53:22 +02:00 committed by Fabien Potencier
parent 9ed3d0468e
commit 33a7d9a0a4
8 changed files with 28 additions and 35 deletions

View File

@ -68,13 +68,12 @@ abstract class FileLoader implements LoaderInterface
static protected function isAbsolutePath($file)
{
if ($file[0] == '/' || $file[0] == '\\' ||
(strlen($file) > 3 && ctype_alpha($file[0]) &&
$file[1] == ':' &&
($file[2] == '\\' || $file[2] == '/')
)
)
{
if ($file[0] == '/' || $file[0] == '\\'
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
) {
return true;
}

View File

@ -73,8 +73,9 @@ class PhpMatcherDumper extends MatcherDumper
$conditions = implode(' && ', $conditions);
$code[] = sprintf(<<<EOF
if ($conditions)
if ($conditions) {
return array_merge(\$this->mergeDefaults(\$matches, %s), array('_route' => '%s'));
}
EOF
, str_replace("\n", '', var_export($compiledRoute->getDefaults(), true)), $name);

View File

@ -96,13 +96,12 @@ class FilesystemLoader extends Loader
*/
static protected function isAbsolutePath($file)
{
if ($file[0] == '/' || $file[0] == '\\' ||
(strlen($file) > 3 && ctype_alpha($file[0]) &&
$file[1] == ':' &&
($file[2] == '\\' || $file[2] == '/')
)
)
{
if ($file[0] == '/' || $file[0] == '\\'
|| (strlen($file) > 3 && ctype_alpha($file[0])
&& $file[1] == ':'
&& ($file[2] == '\\' || $file[2] == '/')
)
) {
return true;
}

View File

@ -120,11 +120,9 @@ class Inline
{
// array
$keys = array_keys($value);
if (
(1 == count($keys) && '0' == $keys[0])
||
(count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2))
{
if ((1 == count($keys) && '0' == $keys[0])
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (integer) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
) {
$output = array();
foreach ($value as $val) {
$output[] = self::dump($val);

View File

@ -82,8 +82,8 @@ class Parser
} else {
if (isset($values['leadspaces'])
&& ' ' == $values['leadspaces']
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P<value>.+?))?\s*$#', $values['value'], $matches))
{
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P<value>.+?))?\s*$#', $values['value'], $matches)
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
$parser = new Parser($c);

View File

@ -47,16 +47,11 @@ class WebDebugToolbar
$request = $this->container->getRequestService();
if (
'3' === substr($response->getStatusCode(), 0, 1)
||
($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
||
'html' !== $request->getRequestFormat()
||
$request->isXmlHttpRequest()
)
{
if ('3' === substr($response->getStatusCode(), 0, 1)
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $request->getRequestFormat()
|| $request->isXmlHttpRequest()
) {
return $response;
}

View File

@ -67,7 +67,9 @@ class ExceptionController extends Controller
}
$currentContent = '';
while (false !== $content = ob_get_clean()) { $currentContent .= $content; }
while (false !== $content = ob_get_clean()) {
$currentContent .= $content;
}
ob_start();
require $template;

View File

@ -91,8 +91,7 @@ class ControllerLoader
$logs[] = sprintf('Failed finding controller "%s:%s" from namespace "%s" (%s)', $bundle, $controller, $namespace, $try);
}
} else {
if (!in_array($namespace.'\\'.$bundle.'\\Bundle', array_map(function ($bundle) { return get_class($bundle); }, $this->container->getKernelService()->getBundles())))
{
if (!in_array($namespace.'\\'.$bundle.'\\Bundle', array_map(function ($bundle) { return get_class($bundle); }, $this->container->getKernelService()->getBundles()))) {
throw new \LogicException(sprintf('To use the "%s" controller, you first need to enable the Bundle "%s" in your Kernel class.', $try, $namespace.'\\'.$bundle));
}