-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function create_function() is deprecated in PHP 7.2 #55
Comments
|
All create_function( '$m', 'return EMT_Lib::decrypt_tag($m[1]);');
// ↓↓↓
function ($m){
return EMT_Lib::decrypt_tag($m[1]);
} And, for BC it could be used with wrapper: if (version_compare(PHP_VERSION, '7.2.0', '<')) { ... } But looks like all pull requests are merged quite rarely. So for own usage i just changed some things inside my local fork. |
If you need to upgrade more than one It's tested on 30 various (and really weird :)) cases. -$callback = create_function('$a', 'return "<cas:proxy>$a</cas:proxy>";');
+$callback = function ($a) {
+ return "<cas:proxy>{$a}</cas:proxy>";
+}; Includes concat (.), string quotes and inclined function calls: -$func = create_function('$atts, $content = null','return "<div class=\"' . $class_list . '\">" . do_shortcode($content) . "</div>";' );
+$func = function ($atts, $content = null) use ($class_list) {
+ return "<div class=\"{$class_list}\">" . do_shortcode($content) . "</div>";
+}; Do you want to automate the hard work? 1. Instal Rectorcomposer require rector/rector --dev 2. Create config# rector.yml
services:
Rector\Php\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector: ~ 3. Upgrade your Codevendor/bin/rector process src --config rector.yml --dry-run
vendor/bin/rector process src --config rector.yml Enjoy! |
See http://php.net/manual/ru/function.create-function.php
The text was updated successfully, but these errors were encountered: