Skip to content

Commit

Permalink
Merge pull request #26 from LExpress/php-5.5
Browse files Browse the repository at this point in the history
Fix PHP 5.5+ compatibility + require PHP 5.3+
  • Loading branch information
GromNaN committed Oct 30, 2013
2 parents 21f140c + 158d78e commit 09bd455
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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;'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ It runs on *nix and Windows platforms.
Requirements
------------

PHP 5.2.4 and up. See prerequisites on http://symfony.com/legacy/doc/getting-started/1_4/en/02-Prerequisites
PHP 5.3.4 and up. See prerequisites on http://symfony.com/legacy/doc/getting-started/1_4/en/02-Prerequisites

Installation
------------
Expand Down
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.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);

This comment has been minimized.

Copy link
@j0k3r

j0k3r Dec 7, 2013

Contributor

5.3.1 or 5.3.4 ?


// warnings
echo "\n** Optional checks **\n\n";
Expand Down Expand Up @@ -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>';
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/form/addon/sfFormObject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ' => ''));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setTableMethod($tableMethod)

/**
* Sets the query object to use.
*
*
* @param Doctrine_Query $query
*/
public function setQuery($query)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
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 @@ -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(' ' => '-'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/service/sfServiceContainer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions lib/util/sfInflector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ' => ''));
}

/**
Expand Down
9 changes: 8 additions & 1 deletion lib/util/sfToolkit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,14 @@ 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;
if (!is_string($value))
{
return $value;
}

return preg_replace_callback('/%(.+?)%/', function ($v) {
return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : '%'.$v[1].'%';
}, $value);
}

/**
Expand Down
33 changes: 29 additions & 4 deletions lib/vendor/lime/lime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 09bd455

Please sign in to comment.