change array_push() to $array[] (#254)
http://php.net/manual/en/function.array-push.php#refsect1-function.array-push-description > Note: If you use array_push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function.
This commit is contained in:
parent
b3e6538066
commit
ee700f7c7d
|
@ -856,8 +856,8 @@ $conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsh
|
||||||
$conditional2->getStyle()->getFont()->setBold(true);
|
$conditional2->getStyle()->getFont()->setBold(true);
|
||||||
|
|
||||||
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
||||||
array_push($conditionalStyles, $conditional1);
|
$conditionalStyles[] = $conditional1;
|
||||||
array_push($conditionalStyles, $conditional2);
|
$conditionalStyles[] = $conditional2;
|
||||||
|
|
||||||
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
||||||
```
|
```
|
||||||
|
|
|
@ -79,9 +79,9 @@ $conditional3->getStyle()->getFont()->setItalic(true);
|
||||||
$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
|
||||||
|
|
||||||
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
|
||||||
array_push($conditionalStyles, $conditional1);
|
$conditionalStyles[] = $conditional1;
|
||||||
array_push($conditionalStyles, $conditional2);
|
$conditionalStyles[] = $conditional2;
|
||||||
array_push($conditionalStyles, $conditional3);
|
$conditionalStyles[] = $conditional3;
|
||||||
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
|
||||||
|
|
||||||
// duplicate the conditional styles across a range of cells
|
// duplicate the conditional styles across a range of cells
|
||||||
|
|
|
@ -55,8 +55,8 @@ $conditional3->setConditionType(Conditional::CONDITION_CELLIS)
|
||||||
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
|
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
|
||||||
|
|
||||||
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles();
|
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles();
|
||||||
array_push($conditionalStyles, $conditional1);
|
$conditionalStyles[] = $conditional1;
|
||||||
array_push($conditionalStyles, $conditional3);
|
$conditionalStyles[] = $conditional3;
|
||||||
$spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
|
$spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
|
||||||
|
|
||||||
// duplicate the conditional styles across a range of cells
|
// duplicate the conditional styles across a range of cells
|
||||||
|
|
|
@ -86,7 +86,7 @@ class WorkbookTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
// Add new color after all existing color
|
// Add new color after all existing color
|
||||||
$colorsAddTwo = array_map([$this, 'paletteToColor'], $palette);
|
$colorsAddTwo = array_map([$this, 'paletteToColor'], $palette);
|
||||||
array_push($colorsAddTwo, $this->paletteToColor($newColor1));
|
$colorsAddTwo[] = $this->paletteToColor($newColor1);
|
||||||
$paletteTestSix = $palette;
|
$paletteTestSix = $palette;
|
||||||
|
|
||||||
// Add one existing color
|
// Add one existing color
|
||||||
|
|
Loading…
Reference in New Issue