diff --git a/.travis.yml b/.travis.yml index d7cd26c59..5c5a8542f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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;' diff --git a/README.md b/README.md index 5ff9ae6ee..94ae827e3 100644 --- a/README.md +++ b/README.md @@ -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 ------------ diff --git a/data/bin/check_configuration.php b/data/bin/check_configuration.php index 121b24498..a1997d0cf 100644 --- a/data/bin/check_configuration.php +++ b/data/bin/check_configuration.php @@ -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 ''; diff --git a/lib/command/sfCommandManager.class.php b/lib/command/sfCommandManager.class.php index 12264414d..d7c0b2f63 100644 --- a/lib/command/sfCommandManager.class.php +++ b/lib/command/sfCommandManager.class.php @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier - * + * * 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); } diff --git a/lib/form/addon/sfFormObject.class.php b/lib/form/addon/sfFormObject.class.php index 16295630a..3652a511c 100644 --- a/lib/form/addon/sfFormObject.class.php +++ b/lib/form/addon/sfFormObject.class.php @@ -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(' ' => '')); } } diff --git a/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php b/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php index 9c2fcfc56..8354e5bf5 100644 --- a/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php +++ b/lib/plugins/sfDoctrinePlugin/lib/form/sfFormFilterDoctrine.class.php @@ -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() diff --git a/lib/response/sfWebResponse.class.php b/lib/response/sfWebResponse.class.php index 95e14c477..36dd49102 100644 --- a/lib/response/sfWebResponse.class.php +++ b/lib/response/sfWebResponse.class.php @@ -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(' ' => '-')); } /** diff --git a/lib/service/sfServiceContainer.class.php b/lib/service/sfServiceContainer.class.php index e6b4deff4..83964ea47 100644 --- a/lib/service/sfServiceContainer.class.php +++ b/lib/service/sfServiceContainer.class.php @@ -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) diff --git a/lib/util/sfInflector.class.php b/lib/util/sfInflector.class.php index 50c1673d5..73b7b48e4 100644 --- a/lib/util/sfInflector.class.php +++ b/lib/util/sfInflector.class.php @@ -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(' ' => '')); } /** diff --git a/lib/util/sfToolkit.class.php b/lib/util/sfToolkit.class.php index 43762a19f..a471c97ea 100644 --- a/lib/util/sfToolkit.class.php +++ b/lib/util/sfToolkit.class.php @@ -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); } /** diff --git a/lib/vendor/lime/lime.php b/lib/vendor/lime/lime.php index 7a2ca5788..f62e5c97c 100644 --- a/lib/vendor/lime/lime.php +++ b/lib/vendor/lime/lime.php @@ -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";