When i ran the php compatibility in file modules\field_ui\field_ui.module found below issue

FILE: C:\xampp\htdocs\drupal7_project\modules\field_ui\field_ui.module
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
278 | ERROR | Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value.
| | The parameter "$bundle" was changed on line 270.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Comments

ravikk-drupal created an issue. See original summary.

ravikk-drupal’s picture

StatusFileSize
new1.27 KB

func_get_args() should be placed at the beginning of a method or function,
changes in PHP 7.0 and onward.

ravikk-drupal’s picture

Title: Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. » PHPCompatibility 7.3: Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value.
Assigned: ravikk-drupal » Unassigned
Status: Active » Needs review
Issue tags: -filed_ui +PHP 7.3, +field ui
mohangathala’s picture

Assigned: Unassigned » mohangathala
joseph.olstad’s picture

Issue tags: +PHP 7.4
mohangathala’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new177.07 KB

This patch perfectly works for me. Screenshot attached for the same.

jungle’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/modules/field_ui/field_ui.module
@@ -266,6 +266,11 @@ function field_ui_menu_title($instance) {
+  //--- PHP7 Compatibility hints ---
+  //func_get_args() should be placed at the beginning of a method or function, ¶
+  //changes in PHP 7.0 and onwards.
+  $all_args = func_get_args();
  1. Unexpected tail space after "method or function,".
  2. one space expected after //
joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new1.54 KB
jungle’s picture

Status: Needs review » Reviewed & tested by the community

@joseph.olstad thank you! Setting back to RTBC

joseph.olstad’s picture

StatusFileSize
new1.53 KB

actually I think this comment makes a bit more sense, stretched to the 80 character limit per line.

taran2l’s picture

This one is not being triggered by any test; should a test coverage be added?

Update

It's not triggered because there is no issue: $bundle argument is nor being used actually. Arguments are sliced at line 279 and only 5+ arguments are useful for the code after the line 279.

267 function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $access_callback) {
268   // First, determine visibility according to the 'use custom display'
269   // setting for the view mode.
270   $bundle = field_extract_bundle($entity_type, $bundle);
271   $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
272   $visibility = ($view_mode == 'default') || !empty($view_mode_settings[$view_mode]['custom_settings']);
273 
274   // Then, determine access according to the $access parameter. This duplicates
275   // part of _menu_check_access().
276   if ($visibility) {
277     // Grab the variable 'access arguments' part.
278     $all_args = func_get_args();
279     $args = array_slice($all_args, 4);
280     $callback = empty($access_callback) ? 0 : trim($access_callback);
281     if (is_numeric($callback)) {
282       return (bool) $callback;
283     }
284     else {
285       // As call_user_func_array() is quite slow and user_access is a very
286       // common callback, it is worth making a special case for it.
287       if ($access_callback == 'user_access') {
288         return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]);
289       }
290       elseif (function_exists($access_callback)) {
291         return call_user_func_array($access_callback, $args);
292       }
293     }
294   }
295 }
mcdruid’s picture

Version: 7.69 » 7.x-dev
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.17 KB

I agree this doesn't seem to be necessary, but it's good to clean up the error from CodeSniffer.

Tweaked the patch a tiny bit, but it's making the same change.

mcdruid’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Pending Drupal 7 commit
mcdruid’s picture

Assigned: mohangathala » Unassigned
liam morland’s picture

fabianx’s picture

Assigned: Unassigned » mcdruid

Generally approved, but I disagree with the comment a little bit:

- I don't think it should be for avoiding code sniffs (that's not a good reason), but rather say something like:

"It is a good practice to put func_get_args() at the start of the function to avoid a changed function parameter to leak into the original arguments. By taking the copy early this is avoided. This behavior changed in PHP7: [link]"

Can be changed on commit.

It's also not a good practice to change given function parameters in the first place, but that's a debate for another day ;).

  • mcdruid committed 18d4dd3 on 7.x
    Issue #3126312 by joseph.olstad, ravikk-drupal, mcdruid, mohangathala,...
mcdruid’s picture

Title: PHPCompatibility 7.3: Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. » Since PHP 7 func_get_args() no longer reports the original value as passed to a parameter, so call it early
Assigned: mcdruid » Unassigned
Status: Reviewed & tested by the community » Fixed
Issue tags: -Pending Drupal 7 commit

Thanks everyone.

I changed the comment on commit to be more like @Fabianx's suggestion.

Status: Fixed » Closed (fixed)

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