Skip to content

Commit 09bd455

Browse files
committed
Merge pull request #26 from LExpress/php-5.5
Fix PHP 5.5+ compatibility + require PHP 5.3+
2 parents 21f140c + 158d78e commit 09bd455

File tree

11 files changed

+53
-24
lines changed

11 files changed

+53
-24
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: php
22

33
php:
4-
- 5.2
54
- 5.3
65
- 5.4
6+
- 5.5
77

88
before_script:
99
- 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;'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ It runs on *nix and Windows platforms.
3131
Requirements
3232
------------
3333

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

3636
Installation
3737
------------

data/bin/check_configuration.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function get_ini_path()
6767

6868
// mandatory
6969
echo "\n** Mandatory requirements **\n\n";
70-
check(version_compare(phpversion(), '5.2.4', '>='), sprintf('PHP version is at least 5.2.4 (%s)', phpversion()), 'Current version is '.phpversion(), true);
70+
check(version_compare(phpversion(), '5.3.1', '>='), sprintf('PHP version is at least 5.3.1 (%s)', phpversion()), 'Current version is '.phpversion(), true);
7171

7272
// warnings
7373
echo "\n** Optional checks **\n\n";
@@ -97,8 +97,6 @@ function_exists('xcache_set')
9797
check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
9898
check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
9999

100-
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);
101-
102100
if (!is_cli())
103101
{
104102
echo '</pre></body></html>';

lib/command/sfCommandManager.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
@@ -108,7 +108,9 @@ public function process($arguments = null)
108108
else if (!is_array($arguments))
109109
{
110110
// hack to split arguments with spaces : --test="with some spaces"
111-
$arguments = preg_replace('/(\'|")(.+?)\\1/e', "str_replace(' ', '=PLACEHOLDER=', '\\2')", $arguments);
111+
$arguments = preg_replace_callback('/(\'|")(.+?)\\1/', function ($match) {
112+
return str_replace(' ', '=PLACEHOLDER=', $match[2]);
113+
}, $arguments);
112114
$arguments = preg_split('/\s+/', $arguments);
113115
$arguments = str_replace('=PLACEHOLDER=', ' ', $arguments);
114116
}

lib/form/addon/sfFormObject.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,6 @@ public function renderFormTag($url, array $attributes = array())
285285

286286
protected function camelize($text)
287287
{
288-
return preg_replace(array('#/(.?)#e', '/(^|_|-)+(.)/e'), array("'::'.strtoupper('\\1')", "strtoupper('\\2')"), $text);
288+
return strtr(ucwords(strtr($text, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
289289
}
290290
}

lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function setTableMethod($tableMethod)
6464

6565
/**
6666
* Sets the query object to use.
67-
*
67+
*
6868
* @param Doctrine_Query $query
6969
*/
7070
public function setQuery($query)
@@ -290,11 +290,11 @@ protected function setupInheritance()
290290

291291
/**
292292
* Returns the name of the related model.
293-
*
293+
*
294294
* @param string $alias A relation alias
295-
*
295+
*
296296
* @return string
297-
*
297+
*
298298
* @throws InvalidArgumentException If no relation with the supplied alias exists on the current model
299299
*/
300300
protected function getRelatedModelName($alias)
@@ -323,7 +323,7 @@ protected function getFieldName($colName)
323323

324324
protected function camelize($text)
325325
{
326-
return sfToolkit::pregtr($text, array('#/(.?)#e' => "'::'.strtoupper('\\1')", '/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
326+
return strtr(ucwords(strtr($text, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
327327
}
328328

329329
protected function getTable()

lib/response/sfWebResponse.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public function send()
411411
*/
412412
protected function normalizeHeaderName($name)
413413
{
414-
return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", strtr(ucfirst(strtolower($name)), '_', '-'));
414+
return strtr(ucwords(strtr(strtolower($name), array('_' => ' ', '-' => ' '))), array(' ' => '-'));
415415
}
416416

417417
/**

lib/service/sfServiceContainer.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function getServiceIds()
213213

214214
static public function camelize($id)
215215
{
216-
return preg_replace(array('/(^|_|-)+(.)/e', '/\.(.)/e'), array("strtoupper('\\2')", "'_'.strtoupper('\\1')"), $id);
216+
return strtr(ucwords(strtr($id, array('_' => ' ', '-' => ' ', '.' => '_ '))), array(' ' => ''));
217217
}
218218

219219
static public function underscore($id)

lib/util/sfInflector.class.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ class sfInflector
2727
*/
2828
public static function camelize($lower_case_and_underscored_word)
2929
{
30-
$tmp = $lower_case_and_underscored_word;
31-
$tmp = sfToolkit::pregtr($tmp, array('#/(.?)#e' => "'::'.strtoupper('\\1')",
32-
'/(^|_|-)+(.)/e' => "strtoupper('\\2')"));
3330

34-
return $tmp;
31+
return strtr(ucwords(strtr($lower_case_and_underscored_word, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
3532
}
3633

3734
/**

lib/util/sfToolkit.class.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,14 @@ public static function literalize($value, $quoted = false)
348348
*/
349349
public static function replaceConstants($value)
350350
{
351-
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;
351+
if (!is_string($value))
352+
{
353+
return $value;
354+
}
355+
356+
return preg_replace_callback('/%(.+?)%/', function ($v) {
357+
return sfConfig::has(strtolower($v[1])) ? sfConfig::get(strtolower($v[1])) : '%'.$v[1].'%';
358+
}, $value);
352359
}
353360

354361
/**

lib/vendor/lime/lime.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,35 @@ public function echoln($message, $colorizer_parameter = null, $colorize = true)
684684
{
685685
if ($colorize)
686686
{
687-
$message = preg_replace('/(?:^|\.)((?:not ok|dubious|errors) *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'ERROR\')', $message);
688-
$message = preg_replace('/(?:^|\.)(ok *\d*)\b/e', '$this->colorizer->colorize(\'$1\', \'INFO\')', $message);
689-
$message = preg_replace('/"(.+?)"/e', '$this->colorizer->colorize(\'$1\', \'PARAMETER\')', $message);
690-
$message = preg_replace('/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/e', '$this->colorizer->colorize(\'$1$2()\', \'PARAMETER\')', $message);
687+
$colorizer = $this->colorizer;
688+
$message = preg_replace_callback(
689+
'/(?:^|\.)((?:not ok|dubious|errors) *\d*)\b/',
690+
function ($match) use ($colorizer) {
691+
return $colorizer->colorize($match[1], 'ERROR');
692+
},
693+
$message
694+
);
695+
$message = preg_replace_callback(
696+
'/(?:^|\.)(ok *\d*)\b/',
697+
function ($match) use ($colorizer) {
698+
return $colorizer->colorize($match[1], 'INFO');
699+
},
700+
$message
701+
);
702+
$message = preg_replace_callback(
703+
'/"(.+?)"/',
704+
function ($match) use ($colorizer) {
705+
return $colorizer->colorize($match[1], 'PARAMETER');
706+
},
707+
$message
708+
);
709+
$message = preg_replace_callback(
710+
'/(\->|\:\:)?([a-zA-Z0-9_]+?)\(\)/',
711+
function ($match) use ($colorizer) {
712+
return $colorizer->colorize($match[1].$match[2].'()', 'PARAMETER');
713+
},
714+
$message
715+
);
691716
}
692717

693718
echo ($colorizer_parameter ? $this->colorizer->colorize($message, $colorizer_parameter) : $message)."\n";

0 commit comments

Comments
 (0)