Permalink
Browse files

Fix PHP 5.5+ compatibility + require PHP 5.3+

  • Loading branch information...
GromNaN committed Oct 2, 2013
1 parent 21f140c commit b90e1254f5208f8666491cf27392a22d38860131
View
@@ -1,9 +1,9 @@
language: php
php:
- 5.2
- 5.3
- 5.4
- 5.5
before_script:
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
@@ -67,7 +67,7 @@ function get_ini_path()
// mandatory
echo "\n** Mandatory requirements **\n\n";
check(version_compare(phpversion(), '5.2.4', '>='), sprintf('PHP version is at least 5.2.4 (%s)', phpversion()), 'Current version is '.phpversion(), true);
check(version_compare(phpversion(), '5.3.1', '>='), sprintf('PHP version is at least 5.3.1 (%s)', phpversion()), 'Current version is '.phpversion(), true);
// warnings
echo "\n** Optional checks **\n\n";
@@ -97,8 +97,6 @@ function_exists('xcache_set')
check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
check(version_compare(phpversion(), '5.2.9', '!='), 'PHP version is not 5.2.9', 'PHP 5.2.9 broke array_unique() and sfToolkit::arrayDeepMerge(). Use 5.2.10 instead [Ticket #6211]', false);
if (!is_cli())
{
echo '</pre></body></html>';
@@ -3,7 +3,7 @@
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@@ -108,7 +108,9 @@ public function process($arguments = null)
else if (!is_array($arguments))
{
// hack to split arguments with spaces : --test="with some spaces"
$arguments = preg_replace('/(\'|")(.+?)\\1/e', "str_replace(' ', '=PLACEHOLDER=', '\\2')", $arguments);
$arguments = preg_replace_callback('/(\'|")(.+?)\\1/', function ($match) {
return str_replace(' ', '=PLACEHOLDER=', $match[2]);
}, $arguments);
$arguments = preg_split('/\s+/', $arguments);
$arguments = str_replace('=PLACEHOLDER=', ' ', $arguments);
}
@@ -285,6 +285,6 @@ public function renderFormTag($url, array $attributes = array())
protected function camelize($text)
{
return preg_replace(array('#/(.?)#e', '/(^|_|-)+(.)/e'), array("'::'.strtoupper('\\1')", "strtoupper('\\2')"), $text);
return strtr(ucwords(strtr($text, array('/' => '::', '_' => ' ', '-' => ' ', '.' => '_ '))), array(' ' => ''));
}
}
@@ -64,7 +64,7 @@ public function setTableMethod($tableMethod)
/**
* Sets the query object to use.
*
*
* @param Doctrine_Query $query
*/
public function setQuery($query)
@@ -290,11 +290,11 @@ protected function setupInheritance()
/**
* Returns the name of the related model.
*
*
* @param string $alias A relation alias
*
*
* @return string
*
*
* @throws InvalidArgumentException If no relation with the supplied alias exists on the current model
*/
protected function getRelatedModelName($alias)
@@ -323,7 +323,7 @@ protected function getFieldName($colName)
protected function camelize($text)
{
return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
return strtr(ucwords(strtr($text, array('/' => '::', '_' => ' ', '-' => ' ', '.' => '_ '))), array(' ' => ''));
}
protected function getTable()
@@ -411,7 +411,7 @@ public function send()
*/
protected function normalizeHeaderName($name)
{
return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst(strtolower($name)), '_', '-'));
return strtr(ucwords(strtr(strtolower($name), array('_' => ' ', '-' => ' '))), array(' ' => '-'));
}
/**
@@ -213,7 +213,7 @@ public function getServiceIds()
static public function camelize($id)
{
return preg_replace(array('/(^|_|-)+(.)/e', '/\.(.)/e'), array("strtoupper('\\2')", "'_'.strtoupper('\\1')"), $id);
return strtr(ucwords(strtr($id, array('_' => ' ', '-' => ' ', '.' => '_ '))), array(' ' => ''));
}
static public function underscore($id)
@@ -27,11 +27,8 @@ class sfInflector
*/
public static function camelize($lower_case_and_underscored_word)
{
$tmp = $lower_case_and_underscored_word;
$tmp = sfToolkit::pregtr($tmp, array('#/(.?)#e' => "'::'.strtoupper('\\1')",
'/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
return $tmp;
return strtr(ucwords(strtr($lower_case_and_underscored_word, array('/' => '::', '_' => ' ', '-' => ' ', '.' => '_ '))), array(' ' => ''));
}
/**
@@ -348,7 +348,9 @@ public static function literalize($value, $quoted = false)
*/
public static function replaceConstants($value)
{
return is_string($value) ? preg_replace_callback('/%(.+?)%/', create_function('$v', 'return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : "%{$v[1]}%";'), $value) : $value;
return is_string($value) ? preg_replace_callback('/%(.+?)%/', function ($v) {
return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : '%'.$v[1].'%';
}, $value) : $value;
}
/**
View
@@ -684,10 +684,35 @@ public function echoln($message, $colorizer_parameter = null, $colorize = true)
{
if ($colorize)
{
$message = preg_replace('/(?:^|\.)((?:not ok|dubious|errors) *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'ERROR\')', $message);
$message = preg_replace('/(?:^|\.)(ok *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'INFO\')', $message);
$message = preg_replace('/"(.+?)"/e', '$this->colorizer->colorize(\'$1\', \'PARAMETER\')', $message);
$message = preg_replace('/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/e', '$this->colorizer->colorize(\'$1$2()\', \'PARAMETER\')', $message);
$colorizer = $this->colorizer;
$message = preg_replace_callback(
'/(?:^|\.)((?:not ok|dubious|errors) *\d*)\b/',
function ($match) use ($colorizer) {
return $colorizer->colorize($match[1], 'ERROR');
},
$message
);
$message = preg_replace_callback(
'/(?:^|\.)(ok *\d*)\b/',
function ($match) use ($colorizer) {
return $colorizer->colorize($match[1], 'INFO');
},
$message
);
$message = preg_replace_callback(
'/"(.+?)"/',
function ($match) use ($colorizer) {
return $colorizer->colorize($match[1], 'PARAMETER');
},
$message
);
$message = preg_replace_callback(
'/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/',
function ($match) use ($colorizer) {
return $colorizer->colorize($match[1].$match[2], 'PARAMETER');
},
$message
);
}
echo ($colorizer_parameter ? $this->colorizer->colorize($message, $colorizer_parameter) : $message)."\n";

0 comments on commit b90e125

Please sign in to comment.