Problem/Motivation

A PHP strict warning is emitted by the following code due to use of the return value of the nested function call as the parameter to array_pop or array_shift, as opposed to a variable. The warning is: "Only variables should be passed by reference."

$default_pivot_col = empty($this->options['pivot_col']) ?
  array_pop(array_keys($columns)) :
  $this->options['pivot_col'];
$default_pivot_row = empty($this->options['pivot_row']) ?
  array_shift(array_keys($columns)) :
  $this->options['pivot_row'];

Proposed resolution

Create a variable for the column keys to pass to the outer array function calls.

Remaining tasks

Review and test. No documentation.

User interface changes

None.

API changes

None.

Comments

solotandem’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

Attached patch implements proposed resolution.

jurgenhaas’s picture

Status: Needs review » Closed (fixed)

Thanks for your patch, this is applied and committed to the dev release.

  • Commit c96578c on 7.x-1.x by jurgenhaas:
    #2286307: Eliminate PHP strict warnings from nested array function calls