Skip to content

Commit 2303d1f

Browse files
author
e1himself
committed
Replace deprecated create_function in a few more places
1 parent 6450a94 commit 2303d1f

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

lib/cache/sfMemcacheCache.class.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,12 @@ public function removePattern($pattern)
210210
public function getMany($keys)
211211
{
212212
$values = array();
213-
foreach ($this->memcache->get(array_map(create_function('$k', 'return "'.$this->getOption('prefix').'".$k;'), $keys)) as $key => $value)
213+
$prefix = $this->getOption('prefix');
214+
$prefixed_keys = array_map(function($k) use ($prefix) { return $prefix . $k; }, $keys);
215+
216+
foreach ($this->memcache->get($prefixed_keys) as $key => $value)
214217
{
215-
$values[str_replace($this->getOption('prefix'), '', $key)] = $value;
218+
$values[str_replace($prefix, '', $key)] = $value;
216219
}
217220

218221
return $values;

lib/command/sfCommandApplication.class.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,12 @@ protected function fixCgi()
587587
}
588588

589589
// close the streams on script termination
590-
register_shutdown_function(create_function('', 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;'));
590+
register_shutdown_function(function() {
591+
fclose(STDIN);
592+
fclose(STDOUT);
593+
fclose(STDERR);
594+
return true;
595+
});
591596
}
592597

593598
/**

lib/routing/sfRoute.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ protected function initializeOptions()
691691
'extra_parameters_as_query_string' => true,
692692
), $this->getDefaultOptions(), $this->options);
693693

694-
$preg_quote_hash = create_function('$a', 'return preg_quote($a, \'#\');');
694+
$preg_quote_hash = function($a) { return preg_quote($a, '#'); };
695695

696696
// compute some regexes
697697
$this->options['variable_prefix_regex'] = '(?:'.implode('|', array_map($preg_quote_hash, $this->options['variable_prefixes'])).')';
@@ -701,7 +701,7 @@ protected function initializeOptions()
701701
$this->options['segment_separators_regex'] = '(?:'.implode('|', array_map($preg_quote_hash, $this->options['segment_separators'])).')';
702702

703703
// as of PHP 5.3.0, preg_quote automatically quotes dashes "-" (see http://bugs.php.net/bug.php?id=47229)
704-
$preg_quote_hash_53 = create_function('$a', 'return str_replace(\'-\', \'\-\', preg_quote($a, \'#\'));');
704+
$preg_quote_hash_53 = function($a) { return str_replace('-', '\-', preg_quote($a, '#')); };
705705
$this->options['variable_content_regex'] = '[^'.implode('',
706706
array_map(version_compare(PHP_VERSION, '5.3.0RC4', '>=') ? $preg_quote_hash : $preg_quote_hash_53, $this->options['segment_separators'])
707707
).']+';

lib/task/project/sfProjectPermissionsTask.class.php

Lines changed: 5 additions & 5 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) 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
*/
@@ -72,18 +72,18 @@ protected function execute($arguments = array(), $options = array())
7272
{
7373
$this->logBlock(array_merge(
7474
array('Permissions on the following file(s) could not be fixed:', ''),
75-
array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->failed)
75+
array_map(function($f) { return ' - '.sfDebug::shortenFilePath($f); }, $this->failed)
7676
), 'ERROR_LARGE');
7777
}
7878
}
7979

8080
/**
8181
* Chmod and capture any failures.
82-
*
82+
*
8383
* @param string $file
8484
* @param integer $mode
8585
* @param integer $umask
86-
*
86+
*
8787
* @see sfFilesystem
8888
*/
8989
protected function chmod($file, $mode, $umask = 0000)
@@ -109,7 +109,7 @@ protected function chmod($file, $mode, $umask = 0000)
109109

110110
/**
111111
* Captures those chmod commands that fail.
112-
*
112+
*
113113
* @see http://www.php.net/set_error_handler
114114
*/
115115
public function handleError($no, $string, $file, $line, $context)

lib/util/sfBrowserBase.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ protected function parseArgumentAsArray($name, $value, &$vars)
927927
if (false !== $pos = strpos($name, '['))
928928
{
929929
$var = &$vars;
930-
$tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name), create_function('$s', 'return $s !== "";'));
930+
$tmps = array_filter(preg_split('/(\[ | \[\] | \])/x', $name), function($s) { return $s !== ''; });
931931
foreach ($tmps as $tmp)
932932
{
933933
$var = &$var[$tmp];

lib/validator/sfValidatorErrorSchema.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ public function offsetUnset($offset)
283283
protected function updateCode()
284284
{
285285
$this->code = implode(' ', array_merge(
286-
array_map(create_function('$e', 'return $e->getCode();'), $this->globalErrors),
287-
array_map(create_function('$n,$e', 'return $n.\' [\'.$e->getCode().\']\';'), array_keys($this->namedErrors), array_values($this->namedErrors))
286+
array_map(function($e) { /** @var $e sfValidatorError */ return $e->getCode(); }, $this->globalErrors),
287+
array_map(function($n, $e) { /** @var $e sfValidatorError */ return $n.' ['.$e->getCode().']'; }, array_keys($this->namedErrors), array_values($this->namedErrors))
288288
));
289289
}
290290

@@ -294,8 +294,8 @@ protected function updateCode()
294294
protected function updateMessage()
295295
{
296296
$this->message = implode(' ', array_merge(
297-
array_map(create_function('$e', 'return $e->getMessage();'), $this->globalErrors),
298-
array_map(create_function('$n,$e', 'return $n.\' [\'.$e->getMessage().\']\';'), array_keys($this->namedErrors), array_values($this->namedErrors))
297+
array_map(function($e) { /** @var $e sfValidatorError */ return $e->getMessage(); }, $this->globalErrors),
298+
array_map(function($n, $e) { /** @var $e sfValidatorError */ return $n.' ['.$e->getMessage().']'; }, array_keys($this->namedErrors), array_values($this->namedErrors))
299299
));
300300
}
301301

lib/validator/sfValidatorFromDescription.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function __construct($class, $arguments = array())
294294

295295
public function asPhp()
296296
{
297-
return sprintf('new %s(%s)', $this->class, implode(', ', array_map(create_function('$a', 'return var_export($a, true);'), $this->arguments)));
297+
return sprintf('new %s(%s)', $this->class, implode(', ', array_map(function($a) { return var_export($a, true); }, $this->arguments)));
298298
}
299299

300300
public function getValidator()
@@ -353,7 +353,7 @@ public function asPhp($tokenLeft, $tokenRight)
353353
$this->class,
354354
is_object($tokenLeft) && in_array(get_class($tokenLeft), array('sfValidatorFDToken', 'sfValidatorFDTokenFilter')) ? $tokenLeft->asPhp() : $tokenLeft,
355355
is_object($tokenRight) && in_array(get_class($tokenRight), array('sfValidatorFDToken', 'sfValidatorFDTokenFilter')) ? $tokenRight->asPhp() : $tokenRight,
356-
implode(', ', array_map(create_function('$a', 'return var_export($a, true);'), $this->arguments))
356+
implode(', ', array_map(function($a) { return var_export($a, true); }, $this->arguments))
357357
);
358358
}
359359

0 commit comments

Comments
 (0)