8000 Various fixes by pborreli · Pull Request #119 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Various fixes #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you accou 8000 nt related emails.

Already on GitHub? Sign in to your account

Merged
16 commits merged into from
Feb 27, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
use Doctrine\Common\Cli\Configuration;
use Doctrine\Common\Cli\CliController as DoctrineCliController;
use Doctrine\DBAL\Connection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
use Doctrine\Common\Cli\Configuration;
use Doctrine\Common\Cli\CliController as DoctrineCliController;
use Doctrine\DBAL\Connection;

/**
Expand Down Expand Up @@ -74,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
} else {
$output->writeln(sprintf('<info>Would drop the database named <comment>%s</comment>.</info>', $name));
$output->writeln(sprintf('<error>All data will be lost!</error>', $name));
$output->writeln('<error>All data will be lost!</error>');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use Symfony\Component\Finder\Finder;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
use Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader as DataFixturesLoader;
use Doctrine\Common\Cli\Configuration;
use Doctrine\Common\Cli\CliController as DoctrineCliController;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use Symfony\Component\Finder\Finder;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
use Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader as DataFixturesLoader;
use Doctrine\Common\Cli\Configuration;
use Doctrine\Common\Cli\CliController as DoctrineCliController;
use Doctrine\Common\DataFixtures\Executor\MongoDBExecutor;
use Doctrine\Common\DataFixtures\Purger\MongoDBPurger;
use Doctrine\ODM\MongoDB\DocumentManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ protected function formatValue($value)
{
if (is_object($value)) {
return sprintf('object(%s)', get_class($value));
} else {
return preg_replace("/\n\s*/s", '', var_export($value, true));
}

return preg_replace("/\n\s*/s", '', var_export($value, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ private function attributesCallback($name, $value)
{
if (false === $value || null === $value || ('' === $value && 'value' != $name)) {
return '';
} else {
return ' '.$this->attribute($name, $value);
}

return ' '.$this->attribute($name, $value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public function getHeader($header, $first = true)
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) {
if ($first) {
return is_array($value) ? (count($value) ? $value[0] : '') : $value;
} else {
return is_array($value) ? $value : array($value);
}

return is_array($value) ? $value : array($value);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public function run(InputInterface $input = null, OutputInterface $output = null
// @codeCoverageIgnoreStart
exit($statusCode);
// @codeCoverageIgnoreEnd
} else {
return $statusCode;
}

return $statusCode;
}

/**
Expand Down Expand Up @@ -315,9 +315,9 @@ public function getLongVersion()
{
if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {
return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
} else {
return '<info>Console Tool</info>';
}

return '<info>Console Tool</info>';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function run(InputInterface $input, OutputInterface $output)

if ($this->code) {
return call_user_func($this->code, $input, $output);
} else {
return $this->execute($input, $output);
}

return $this->execute($input, $output);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Helper/DialogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function askConfirmation(OutputInterface $output, $question, $default = t

if (false === $default) {
return $answer && 'y' == strtolower($answer[0]);
} else {
return !$answer || 'y' == strtolower($answer[0]);
}

return !$answer || 'y' == strtolower($answer[0]);
// @codeCoverageIgnoreEnd
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Input/ArgvInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public function getParameterOption($values, $default = false)
if (0 === strpos($token, $value)) {
if (false !== $pos = strpos($token, '=')) {
return substr($token, $pos + 1);
} else {
return array_shift($tokens);
}

return array_shift($tokens);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ protected function hasColorSupport()
// @codeCoverageIgnoreStart
if (DIRECTORY_SEPARATOR == '\\') {
return false !== getenv('ANSICON');
} else {
return function_exists('posix_isatty') && @posix_isatty($this->stream);
}

return function_exists('posix_isatty') && @posix_isatty($this->stream);
// @codeCoverageIgnoreEnd
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/CssSelector/Node/AttribNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function __toString()
{
if ($this->operator == 'exists') {
return sprintf('%s[%s[%s]]', __CLASS__, $this->selector, $this->formatAttrib());
} else {
return sprintf('%s[%s[%s %s %s]]', __CLASS__, $this->selector, $this->formatAttrib(), $this->operator, $this->value);
}

return sprintf('%s[%s[%s %s %s]]', __CLASS__, $this->selector, $this->formatAttrib(), $this->operator, $this->value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ protected function resolveValue($value)
return $resolved;
} else if (is_string($value)) {
return $this->resolveString($value);
} else {
return $value;
}

return $value;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ protected function addServiceConfigurator($id, $definition, $variableName = 'ins
if (is_array($callable)) {
if (is_object($callable[0]) && $callable[0] instanceof Reference) {
return sprintf(" %s->%s(\$%s);\n", $this->getServiceCall((string) $callable[0]), $callable[1], $variableName);
} else {
return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
}
} else {
return sprintf(" %s(\$%s);\n", $callable, $variableName);

return sprintf(" call_user_func(array(%s, '%s'), \$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
}

return sprintf(" %s(\$%s);\n", $callable, $variableName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ protected function dumpValue($value)
return $this->getParameterCall((string) $value);
} elseif (is_object($value) || is_resource($value)) {
throw new \RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
} else {
return $value;
}

return $value;
}

/**
Expand All @@ -222,9 +222,9 @@ protected function getServiceCall($id, Reference $reference = null)
{
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
return sprintf('@?%s', $id);
} else {
return sprintf('@%s', $id);
}

return sprintf('@%s', $id);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Form/ChoiceField.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ protected function newChoiceField($choice, $label)
return new CheckboxField($choice, array(
'value' => $choice,
));
} else {
return new RadioField($choice, array(
'value' => $choice,
));
}

return new RadioField($choice, array(
'value' => $choice,
));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,9 @@ public function isPostMaxSizeReached()
}

return $length > $max;
} else {
return false;
}

return false;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Form/HybridField.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public function getDisplayedData()
{
if ($this->mode === self::FORM) {
return parent::getDisplayedData();
} else {
return Field::getDisplayedData();
}

return Field::getDisplayedData();
}

/**
Expand Down Expand Up @@ -131,8 +131,8 @@ public function isEmpty()
{
if ($this->mode === self::FORM) {
return parent::isEmpty();
} else {
return Field::isEmpty();
}

return Field::isEmpty();
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/PropertyPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ protected function readPropertyPath(&$objectOrArray, $currentIndex)

if ($currentIndex < $this->length) {
return $this->readPropertyPath($value, $currentIndex);
} else {
return $value;
}

return $value;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/HttpFoundation/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ public function getExtension()
{
if ($ext = pathinfo($this->getName(), \PATHINFO_EXTENSION)) {
return '.' . $ext;
} else {
return '';
}

return '';
}

/**
Expand All @@ -537,9 +537,9 @@ public function getDefaultExtension()

if (isset(self::$defaultExtensions[$type])) {
return '.' . self::$defaultExtensions[$type];
} else {
return $this->getExtension();
}

return $this->getExtension();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/HttpFoundation/FileBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ protected function convertFileInformation($file)
}
if ($keys != $this->fileKeys) {
$file = array_map(array($this, 'convertFileInformation'), $file);
} else
} else {
if ($file['error'] === UPLOAD_ERR_NO_FILE) {
$file = null;
} else {
$file = new UploadedFile($file['tmp_name'], $file['name'],
$file['type'], $file['size'], $file['error']);
}
}
}
return $file;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/HttpFoundation/HeaderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ public function get($key, $default = null, $first = true)
if (!array_key_exists($key, $this->headers)) {
if (null === $default) {
return $first ? null : array();
} else {
return $first ? $default : array($default);
}

return $first ? $default : array($default);
}

if ($first) {
return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
} else {
return $this->headers[$key];
}

return $this->headers[$key];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ public function getHttpHost()

if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
return $name;
} else {
return $name.':'.$port;
}

return $name.':'.$port;
}

public function getRequestUri()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ public function sessionRead($id)

if (count($sessionRows) == 1) {
return $sessionRows[0][0];
} else {
// session does not exist, create it
$sql = 'INSERT INTO '.$db_table.'('.$db_id_col.', '.$db_data_col.', '.$db_time_col.') VALUES (?, ?, ?)';
}

$stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $id, \PDO::PARAM_STR);
$stmt->bindValue(2, '', \PDO::PARAM_STR);
$stmt->bindValue(3, time(), \PDO::PARAM_INT);
$stmt->execute();
// session does not exist, create it
$sql = 'INSERT INTO '.$db_table.'('.$db_id_col.', '.$db_data_col.', '.$db_time_col.') VALUES (?, ?, ?)';

return '';
}
$stmt = $this->db->prepare($sql);
$stmt->bindParam(1, $id, \PDO::PARAM_STR);
$stmt->bindValue(2, '', \PDO::PARAM_STR);
$stmt->bindValue(3, time(), \PDO::PARAM_INT);
$stmt->execute();

return '';
} catch (\PDOException $e) {
throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e);
}
Expand Down
Loading
0