diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md index 506df190d..57c801390 100644 --- a/docs/en/04_Changelogs/4.0.0.md +++ b/docs/en/04_Changelogs/4.0.0.md @@ -1295,6 +1295,7 @@ After (`mysite/_config/config.yml`): * `Injector` now complies with [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md). Accordingly, `hasService()` has been renamed to `has()`, and `get()` will throw `SilverStripe\Core\Injector\InjectorNotFoundException` when the service can't be found. +* Removed `CustomMethods::createMethod()`. Use closures instead. #### General and Core Deprecated API diff --git a/src/Core/CustomMethods.php b/src/Core/CustomMethods.php index 1810e0e1b..12b7996d4 100644 --- a/src/Core/CustomMethods.php +++ b/src/Core/CustomMethods.php @@ -292,20 +292,4 @@ trait CustomMethods 'method' => $method ); } - - /** - * Add an extra method using raw PHP code passed as a string - * - * @param string $method the method name - * @param string $code the PHP code - arguments will be in an array called $args, while you can access this object - * by using $obj. Note that you cannot call protected methods, as the method is actually an external - * function - */ - protected function createMethod($method, $code) - { - $class = get_class($this); - self::$extra_methods[$class][strtolower($method)] = array ( - 'function' => create_function('$obj, $args', $code) - ); - } } diff --git a/src/Dev/Install/install.php5 b/src/Dev/Install/install.php5 index 44fa5e712..f13633153 100755 --- a/src/Dev/Install/install.php5 +++ b/src/Dev/Install/install.php5 @@ -1389,7 +1389,9 @@ class Installer extends InstallRequirements { $locale = isset($_POST['locale']) ? addcslashes($_POST['locale'], "\'") : 'en_US'; $type = addcslashes($config['db']['type'], "\'"); $dbConfig = $config['db'][$type]; - $dbConfig = array_map(create_function('$v', 'return addcslashes($v, "\\\'");'), $dbConfig); + foreach ($dbConfig as &$configValue) { + $configValue = addcslashes($configValue, "\\\'"); + } if(!isset($dbConfig['path'])) $dbConfig['path'] = ''; if(!$dbConfig) { echo "
Bad config submitted
"; diff --git a/src/Forms/Form.php b/src/Forms/Form.php index 63dac2354..5e0ec417c 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -826,7 +826,9 @@ class Form extends ViewableData implements HasRequestHandler $attrs = $this->getAttributes(); // Remove empty - $attrs = array_filter((array)$attrs, create_function('$v', 'return ($v || $v === 0);')); + $attrs = array_filter((array)$attrs, function ($value) { + return ($value || $value === 0); + }); // Remove excluded if ($exclude) { diff --git a/tests/php/Core/ObjectTest/T2.php b/tests/php/Core/ObjectTest/T2.php index c6db8b7bd..7fc888fac 100644 --- a/tests/php/Core/ObjectTest/T2.php +++ b/tests/php/Core/ObjectTest/T2.php @@ -25,8 +25,6 @@ class T2 extends Object $this->addMethodsFrom('failover'); $this->addMethodsFrom('failoverArr', 0); $this->addMethodsFrom('failoverArr', 1); - - $this->createMethod('testCreateMethod', 'return "created";'); } public function wrappedMethod($val)