Skip to content

Commit

Permalink
Fix PHP 5.5+ compatibility + require PHP 5.3+
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	data/bin/check_configuration.php
	lib/form/addon/sfFormObject.class.php
	lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php
	lib/service/sfServiceContainer.class.php
	lib/util/sfInflector.class.php
	lib/vendor/lime/lime.php
  • Loading branch information
GromNaN authored and Nico Schoenmaker committed Feb 27, 2014
1 parent 968ce35 commit a3bf5ce
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
4 changes: 1 addition & 3 deletions data/bin/check_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function get_ini_path()

// mandatory
echo "\n** Mandatory requirements **\n\n";
check(version_compare(phpversion(), '5.1.3', '>='), 'requires PHP >= 5.1.3', '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);
check(!ini_get('zend.ze1_compatibility_mode'), 'php.ini: requires zend.ze1_compatibility_mode set to off', sprintf('Set it to off in php.ini (%s)', get_ini_path()), true);

// warnings
Expand All @@ -90,8 +90,6 @@ function_exists('xcache_set')
check(!ini_get('register_globals'), 'php.ini: register_globals set to off', 'Set it to off in php.ini', false);
check(!ini_get('session.auto_start'), 'php.ini: 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>';
Expand Down
6 changes: 4 additions & 2 deletions lib/command/sfCommandManager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <[email protected]>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/response/sfWebResponse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,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(' ' => '-'));
}

/**
Expand Down
6 changes: 1 addition & 5 deletions lib/util/sfInflector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ 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(' ' => ''));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/util/sfToolkit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,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;
}

/**
Expand Down
36 changes: 32 additions & 4 deletions lib/vendor/lime/lime.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,38 @@ public function error($message)

public function echoln($message, $colorizer_parameter = null)
{
$message = preg_replace('/(?:^|\.)((?:not ok|dubious) *\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);
if ($colorize)
{
$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";
}
Expand Down

0 comments on commit a3bf5ce

Please sign in to comment.