PHP's create_function() has been deprecated as of PHP 7.2. This function is used to create an anonymous function. PHP 5.3 has an alternative to doing this, this too should be avoided because Drupal 7 officially supports PHP 5.2.5+.

To make this module compatible with future versions of PHP 7, its usage should be replaced with the remaining alternative, which is using a real function definition instead of an anonymous function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bkosborne created an issue. See original summary.

Deepthi kumari’s picture

Please review the patch.

vlklavanya’s picture

Status: Active » Needs review
generalredneck’s picture

Status: Needs review » Needs work

So, as the description states... anonymous functions shouldn't be used here. If this was the d8 version that would be different. Consider changing it to the declared real function as mentioned in the description if possible.

Deepthi kumari’s picture

Status: Needs work » Needs review
FileSize
3.59 KB

Hi,
Please review the patch.

generalredneck’s picture

Status: Needs review » Fixed

Changes to admin.inc were committed. the other changes were "coding standards" changes done by an automated tool. Empty Doc blocks were added. Might as well not have any and have the running todo list to add it than add blank ones to appease a tool in my opinion.

Reguardless of the nit picks, Thank you for you contribution!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dks786’s picture

HI Deepthi,
Thanks for patch!
Can you please explain the code you added, how its works? because it also dont have function name (2nd line: function(&$val) ).

-  array_walk($beginning_words, create_function('&$val', '$val = trim($val);'));
+  array_walk($beginning_words, function(&$val) { $val = trim($val); });

If we use this following code separately, for test, than it don't work and produce error:
function(&$val) { $val = trim($val);

Can you please explain login behind it, how it works...?
I seen this type of code in other places as well in coding, but couldn't understand that.