Skip to content

Commit

Permalink
replaced create_function calls with anonymous functions, fixes nexces…
Browse files Browse the repository at this point in the history
  • Loading branch information
sprankhub committed Oct 31, 2018
1 parent 96bbdda commit 4c0470f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,9 @@ protected function _loadEsiCacheClearEvents() {
$events = $layoutXml->xpath(
'//action[@method=\'setEsiOptions\']/params/flush_events/*' );
if ($events) {
$events = array_unique(array_map(
create_function('$e',
'return (string)$e->getName();'),
$events ));
$events = array_unique(array_map(function ($e) {
return (string)$e->getName();
}, $events));
} else {
$events = array();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ public function banProductReview($eventObject) {

$products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems();

$productIds = array_unique(array_map(
create_function('$p', 'return $p->getEntityId();'),
$products ));
$productIds = array_unique(array_map(function ($p) {
return $p->getEntityId();
}, $products));
$patterns[] = sprintf('/review/product/list/id/(?:%s)/category/',
implode('|', array_unique($productIds)));
$patterns[] = sprintf('/review/product/view/id/%d/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ protected function _getCustomTemplateFilename() {
* @return string
*/
protected function _formatTemplate($template, array $vars) {
$needles = array_map(create_function('$k', 'return "{{".$k."}}";'),
array_keys($vars));
$needles = array_map(function ($k) {
return '{{' . $k . '}}';
}, array_keys($vars));
$replacements = array_values($vars);
// do replacements, then delete unused template vars
return preg_replace('~{{[^}]+}}~', '',
Expand Down Expand Up @@ -269,9 +270,9 @@ protected function _vcl_sub_allowed_hosts_regex() {
*/
public function getBaseUrlPathRegex() {
$pattern = '^(%s)(?:(?:index|litespeed)\\.php/)?';
return sprintf($pattern, implode('|',
array_map(create_function('$x', 'return preg_quote($x,"|");'),
$this->_getBaseUrlPaths())));
return sprintf($pattern, implode('|', array_map(function ($x) {
return preg_quote($x, '|');
}, $this->_getBaseUrlPaths())));
}

/**
Expand All @@ -294,8 +295,9 @@ protected function _getBaseUrlPaths() {
}
}
$paths = array_unique($paths);
usort($paths, create_function('$a, $b',
'return strlen( $b ) - strlen( $a );'));
usort($paths, function ($a, $b) {
return strlen($b) - strlen($a);
});
return array_values($paths);
}

Expand Down Expand Up @@ -794,7 +796,9 @@ protected function _vcl_acl($name, array $hosts) {
{{hosts}}
}
EOS;
$fmtHost = create_function('$h', 'return sprintf(\'"%s";\',$h);');
$fmtHost = function ($h) {
return sprintf('"%s";', $h);
};
$vars = array(
'name' => $name,
'hosts' => implode("\n ", array_map($fmtHost, $hosts)),
Expand Down
8 changes: 3 additions & 5 deletions util/varnishadm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ class Turpentine_Shell_Varnishadm extends Mage_Shell_Abstract {
* @return array
*/
protected function _parseArgs() {
$this->_args = array_slice(
array_filter($_SERVER['argv'],
create_function('$e',
'return $e != \'--\';')),
1 );
$this->_args = array_slice(array_filter($_SERVER['argv'], function ($e) {
return $e != '--';
}), 1);
return $this;
}

Expand Down

0 comments on commit 4c0470f

Please sign in to comment.