mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
remove create_function usage
This commit is contained in:
parent
2538f59ab7
commit
2aa1d8f2c4
@ -173,7 +173,9 @@ class LeftAndMainTest extends FunctionalTest {
|
|||||||
$adminuser = $this->objFromFixture('Member', 'admin');
|
$adminuser = $this->objFromFixture('Member', 'admin');
|
||||||
$securityonlyuser = $this->objFromFixture('Member', 'securityonlyuser');
|
$securityonlyuser = $this->objFromFixture('Member', 'securityonlyuser');
|
||||||
$allcmssectionsuser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
$allcmssectionsuser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
||||||
$allValsFn = create_function('$obj', 'return $obj->getValue();');
|
$allValsFn = function($obj) {
|
||||||
|
return $obj->getValue();
|
||||||
|
};
|
||||||
|
|
||||||
// anonymous user
|
// anonymous user
|
||||||
$this->session()->inst_set('loggedInAs', null);
|
$this->session()->inst_set('loggedInAs', null);
|
||||||
|
@ -373,7 +373,9 @@ class RestfulService extends ViewableData implements Flushable {
|
|||||||
if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
|
if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
|
||||||
$match[1] = preg_replace_callback(
|
$match[1] = preg_replace_callback(
|
||||||
'/(?<=^|[\x09\x20\x2D])./',
|
'/(?<=^|[\x09\x20\x2D])./',
|
||||||
create_function('$matches', 'return strtoupper($matches[0]);'),
|
function($matches) {
|
||||||
|
return strtoupper($matches[0]);
|
||||||
|
},
|
||||||
trim($match[1])
|
trim($match[1])
|
||||||
);
|
);
|
||||||
if( isset($headers[$match[1]]) ) {
|
if( isset($headers[$match[1]]) ) {
|
||||||
|
@ -948,7 +948,9 @@ abstract class Object {
|
|||||||
*/
|
*/
|
||||||
protected function createMethod($method, $code) {
|
protected function createMethod($method, $code) {
|
||||||
self::$extra_methods[get_class($this)][strtolower($method)] = array (
|
self::$extra_methods[get_class($this)][strtolower($method)] = array (
|
||||||
'function' => create_function('$obj, $args', $code)
|
'function' => function($obj, $args) use ($code) {
|
||||||
|
eval($code);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,7 +1307,9 @@ class Installer extends InstallRequirements {
|
|||||||
$locale = isset($_POST['locale']) ? addcslashes($_POST['locale'], "\'") : 'en_US';
|
$locale = isset($_POST['locale']) ? addcslashes($_POST['locale'], "\'") : 'en_US';
|
||||||
$type = addcslashes($config['db']['type'], "\'");
|
$type = addcslashes($config['db']['type'], "\'");
|
||||||
$dbConfig = $config['db'][$type];
|
$dbConfig = $config['db'][$type];
|
||||||
$dbConfig = array_map(create_function('$v', 'return addcslashes($v, "\\\'");'), $dbConfig);
|
$dbConfig = array_map(function($v) {
|
||||||
|
return addcslashes($v, "\\'");
|
||||||
|
}, $dbConfig);
|
||||||
if(!isset($dbConfig['path'])) $dbConfig['path'] = '';
|
if(!isset($dbConfig['path'])) $dbConfig['path'] = '';
|
||||||
if(!$dbConfig) {
|
if(!$dbConfig) {
|
||||||
echo "<p style=\"color: red\">Bad config submitted</p><pre>";
|
echo "<p style=\"color: red\">Bad config submitted</p><pre>";
|
||||||
|
@ -859,7 +859,9 @@ class Form extends RequestHandler {
|
|||||||
$attrs = $this->getAttributes();
|
$attrs = $this->getAttributes();
|
||||||
|
|
||||||
// Remove empty
|
// Remove empty
|
||||||
$attrs = array_filter((array)$attrs, create_function('$v', 'return ($v || $v === 0);'));
|
$attrs = array_filter((array)$attrs, function($v) {
|
||||||
|
return ($v || $v === 0);
|
||||||
|
});
|
||||||
|
|
||||||
// Remove excluded
|
// Remove excluded
|
||||||
if($exclude) $attrs = array_diff_key($attrs, array_flip($exclude));
|
if($exclude) $attrs = array_diff_key($attrs, array_flip($exclude));
|
||||||
|
@ -136,7 +136,9 @@ class ListboxField extends DropdownField {
|
|||||||
public function setSource($source) {
|
public function setSource($source) {
|
||||||
if($source) {
|
if($source) {
|
||||||
$hasCommas = array_filter(array_keys($source),
|
$hasCommas = array_filter(array_keys($source),
|
||||||
create_function('$key', 'return strpos($key, ",") !== FALSE;'));
|
function($key) {
|
||||||
|
return strpos($key, ",") !== FALSE;
|
||||||
|
});
|
||||||
if($hasCommas) {
|
if($hasCommas) {
|
||||||
throw new InvalidArgumentException('No commas allowed in $source keys');
|
throw new InvalidArgumentException('No commas allowed in $source keys');
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,9 @@ class HTMLText extends Text {
|
|||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
|
|
||||||
// Catch warnings thrown by loadHTML and turn them into a failure boolean rather than a SilverStripe error
|
// Catch warnings thrown by loadHTML and turn them into a failure boolean rather than a SilverStripe error
|
||||||
set_error_handler(create_function('$no, $str', 'throw new Exception("HTML Parse Error: ".$str);'), E_ALL);
|
set_error_handler(function($no, $str) {
|
||||||
|
throw new Exception("HTML Parse Error: " . $str);
|
||||||
|
}, E_ALL);
|
||||||
// Nonbreaking spaces get converted into weird characters, so strip them
|
// Nonbreaking spaces get converted into weird characters, so strip them
|
||||||
$value = str_replace(' ', ' ', $this->RAW());
|
$value = str_replace(' ', ' ', $this->RAW());
|
||||||
try {
|
try {
|
||||||
|
@ -728,7 +728,9 @@ class UploadFieldTest extends FunctionalTest {
|
|||||||
// A bit too much coupling with GridField, but a full template overload would make things too complex
|
// A bit too much coupling with GridField, but a full template overload would make things too complex
|
||||||
$parser = new CSSContentParser($response->getBody());
|
$parser = new CSSContentParser($response->getBody());
|
||||||
$items = $parser->getBySelector('.ss-gridfield-item');
|
$items = $parser->getBySelector('.ss-gridfield-item');
|
||||||
$itemIDs = array_map(create_function('$el', 'return (int)$el["data-id"];'), $items);
|
$itemIDs = array_map(function($el) {
|
||||||
|
return (int)$el["data-id"];
|
||||||
|
}, $items);
|
||||||
$this->assertContains($file4->ID, $itemIDs, 'Contains file in assigned folder');
|
$this->assertContains($file4->ID, $itemIDs, 'Contains file in assigned folder');
|
||||||
$this->assertContains($fileSubfolder->ID, $itemIDs, 'Contains file in subfolder');
|
$this->assertContains($fileSubfolder->ID, $itemIDs, 'Contains file in subfolder');
|
||||||
}
|
}
|
||||||
@ -746,7 +748,9 @@ class UploadFieldTest extends FunctionalTest {
|
|||||||
// A bit too much coupling with GridField, but a full template overload would make things too complex
|
// A bit too much coupling with GridField, but a full template overload would make things too complex
|
||||||
$parser = new CSSContentParser($response->getBody());
|
$parser = new CSSContentParser($response->getBody());
|
||||||
$items = $parser->getBySelector('.ss-gridfield-item');
|
$items = $parser->getBySelector('.ss-gridfield-item');
|
||||||
$itemIDs = array_map(create_function('$el', 'return (int)$el["data-id"];'), $items);
|
$itemIDs = array_map(function($el) {
|
||||||
|
return (int)$el["data-id"];
|
||||||
|
}, $items);
|
||||||
$this->assertContains($file4->ID, $itemIDs, 'Contains file in assigned folder');
|
$this->assertContains($file4->ID, $itemIDs, 'Contains file in assigned folder');
|
||||||
$this->assertNotContains($fileSubfolder->ID, $itemIDs, 'Does not contain file in subfolder');
|
$this->assertNotContains($fileSubfolder->ID, $itemIDs, 'Does not contain file in subfolder');
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class sfYamlInline
|
|||||||
if (
|
if (
|
||||||
(1 == count($keys) && '0' == $keys[0])
|
(1 == count($keys) && '0' == $keys[0])
|
||||||
||
|
||
|
||||||
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))
|
(count($keys) > 1 && array_reduce($keys, function($v,$w) { return (integer) $v + $w;}, 0) == count($keys) * (count($keys) - 1) / 2))
|
||||||
{
|
{
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach ($value as $val)
|
foreach ($value as $val)
|
||||||
|
Loading…
Reference in New Issue
Block a user