Updated to Symfony 2.1 BETA3

This commit is contained in:
Polonkai Gergely
2012-07-16 21:40:19 +02:00
parent 7a06301624
commit 9d0d2ce524
1551 changed files with 157774 additions and 5177 deletions

View File

@@ -31,7 +31,7 @@ class ScriptHandler
return;
}
static::executeBuildBootstrap($appDir);
static::executeBuildBootstrap($appDir, $options['process-timeout']);
}
public static function clearCache($event)
@@ -45,7 +45,7 @@ class ScriptHandler
return;
}
static::executeCommand($event, $appDir, 'cache:clear --no-warmup');
static::executeCommand($event, $appDir, 'cache:clear --no-warmup', $options['process-timeout']);
}
public static function installAssets($event)
@@ -123,7 +123,7 @@ namespace { return \$loader; }
", substr(file_get_contents($file), 5)));
}
protected static function executeCommand($event, $appDir, $cmd)
protected static function executeCommand($event, $appDir, $cmd, $timeout = 300)
{
$php = escapeshellarg(self::getPhp());
$console = escapeshellarg($appDir.'/console');
@@ -131,17 +131,17 @@ namespace { return \$loader; }
$console.= ' --ansi';
}
$process = new Process($php.' '.$console.' '.$cmd, null, null, null, 300);
$process = new Process($php.' '.$console.' '.$cmd, null, null, null, $timeout);
$process->run(function ($type, $buffer) { echo $buffer; });
}
protected static function executeBuildBootstrap($appDir)
protected static function executeBuildBootstrap($appDir, $timeout = 300)
{
$php = escapeshellarg(self::getPhp());
$cmd = escapeshellarg(__DIR__.'/../Resources/bin/build_bootstrap.php');
$appDir = escapeshellarg($appDir);
$process = new Process($php.' '.$cmd.' '.$appDir, null, null, null, 300);
$process = new Process($php.' '.$cmd.' '.$appDir, null, null, null, $timeout);
$process->run(function ($type, $buffer) { echo $buffer; });
}
@@ -155,6 +155,8 @@ namespace { return \$loader; }
$options['symfony-assets-install'] = getenv('SYMFONY_ASSETS_INSTALL') ?: $options['symfony-assets-install'];
$options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout');
return $options;
}

View File

@@ -1,91 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sensio\Bundle\DistributionBundle\Diff;
/**
* Computes a Diff between files (line by line).
*
* Implements the Longest common subsequence problem algorithm.
*
* @see http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Diff
{
private $diff;
public function __construct($str1, $str2)
{
$lines1 = explode("\n", $str1);
$lines2 = explode("\n", $str2);
$this->diff = $this->computeDiff($this->computeLcs($lines1, $lines2), $lines1, $lines2, count($lines1) - 1, count($lines2) - 1);
}
public function getDiff()
{
$diff = array();
for ($i = 0, $max = count($this->diff); $i < $max; $i++) {
if ('' != $this->diff[$i][0]) {
$diff[] = array('@', sprintf(' Line %s', $this->diff[$i][2]));
do {
$diff[] = $this->diff[$i++];
} while ('' != $this->diff[$i][0]);
}
}
return $diff;
}
public function computeDiff(array $c, array $lines1, array $lines2, $i, $j)
{
$diff = array();
if ($i > -1 && $j > -1 && $lines1[$i] == $lines2[$j]) {
$diff = array_merge($diff, $this->computeDiff($c, $lines1, $lines2, $i - 1, $j - 1));
$diff[] = array('', $lines1[$i], $i, $j);
} else {
if ($j > -1 && ($i == -1 || $c[$i][$j - 1] >= $c[$i - 1][$j])) {
$diff = array_merge($diff, $this->computeDiff($c, $lines1, $lines2, $i, $j - 1));
$diff[] = array('+', $lines2[$j], $i, $j);
} elseif ($i > -1 && ($j == -1 || $c[$i][$j - 1] < $c[$i - 1][$j])) {
$diff = array_merge($diff, $this->computeDiff($c, $lines1, $lines2, $i - 1, $j));
$diff[] = array('-', $lines1[$i], $i, $j);
}
}
return $diff;
}
private function computeLcs(array $lines1, array $lines2)
{
for ($i = -1, $len1 = count($lines1); $i < $len1; $i++) {
for ($j = -1, $len2 = count($lines2); $j < $len2; $j++) {
$c[$i][$j] = 0;
}
}
for ($i = 0; $i < $len1; $i++) {
for ($j = 0; $j < $len2; $j++) {
if ($lines1[$i] == $lines2[$j]) {
$c[$i][$j] = $c[$i - 1][$j - 1] + 1;
} else {
$c[$i][$j] = max($c[$i][$j - 1], $c[$i - 1][$j]);
}
}
}
return $c;
}
}

View File

@@ -429,11 +429,11 @@ class SymfonyRequirements extends RequirementCollection
);
if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
$this->addRequirement(
(in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())),
sprintf('Default timezone is deprecated (%s)', date_default_timezone_get()),
'Fix your <strong>php.ini</strong> file (list of deprecated timezones http://us.php.net/manual/en/timezones.others.php).'
);
$this->addRequirement(
(in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())),
sprintf('Default timezone "%s" is not supported by your installation of PHP', date_default_timezone_get()),
'Fix your <strong>php.ini</strong> file (check for typos and have a look at the list of deprecated timezones http://php.net/manual/en/timezones.others.php).'
);
}
$this->addRequirement(
@@ -492,6 +492,12 @@ class SymfonyRequirements extends RequirementCollection
/* optional recommendations follow */
$this->addRecommendation(
version_compare($installedPhpVersion, '5.3.4', '>='),
sprintf('Your project might not work properly ("Notice: Trying to get property of non-object") due to the PHP bug #52083 before PHP 5.3.4 (%s installed)', $installedPhpVersion),
'Install PHP 5.3.4 or newer'
);
$this->addRecommendation(
version_compare($installedPhpVersion, '5.3.8', '>='),
sprintf('Annotations might not work properly due to the PHP bug #55156 before PHP 5.3.8 (%s installed)', $installedPhpVersion),

View File

@@ -1,59 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sensio\Bundle\DistributionBundle\Upgrade;
use Sensio\Bundle\DistributionBundle\Diff\Diff;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Upgrade class.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Upgrade
{
public function outputConsoleDiff(OutputInterface $output, $file1, $file2)
{
if (is_file($file1)) {
$file1 = realpath($file1);
$str1 = file_get_contents($file1);
} else {
$str1 = '';
}
if (!is_file($file2)) {
throw new \RuntimeException(sprintf('The skeleton file "%s" does not exist.', $file2));
}
$file2 = realpath($file2);
$str2 = file_get_contents($file2);
$diff = new Diff($str1, $str2);
$output->writeln(sprintf('--- %s', $file1));
$output->writeln(sprintf('+++ %s', $file2));
foreach ($diff->getDiff() as $line) {
if ('+' == $line[0]) {
$format = '<fg=green>+%s</>';
} elseif ('-' == $line[0]) {
$format = '<fg=red>-%s</>';
} elseif ('@' == $line[0]) {
$format = '<fg=cyan>@%s</>';
} else {
$format = ' %s';
}
$output->writeln(sprintf($format, $line[1]));
}
$output->writeln('');
}
}