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:
mosa 2017-10-19 11:07:31 +09:00 committed by Adrien Crivelli
parent b3e6538066
commit ee700f7c7d
4 changed files with 8 additions and 8 deletions

View File

@ -856,8 +856,8 @@ $conditional2->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsh
$conditional2->getStyle()->getFont()->setBold(true);
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $conditional1);
array_push($conditionalStyles, $conditional2);
$conditionalStyles[] = $conditional1;
$conditionalStyles[] = $conditional2;
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
```

View File

@ -79,9 +79,9 @@ $conditional3->getStyle()->getFont()->setItalic(true);
$conditional3->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $conditional1);
array_push($conditionalStyles, $conditional2);
array_push($conditionalStyles, $conditional3);
$conditionalStyles[] = $conditional1;
$conditionalStyles[] = $conditional2;
$conditionalStyles[] = $conditional3;
$spreadsheet->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
// duplicate the conditional styles across a range of cells

View File

@ -55,8 +55,8 @@ $conditional3->setConditionType(Conditional::CONDITION_CELLIS)
$conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
$conditionalStyles = $spreadsheet->getActiveSheet()->getStyle('A1')->getConditionalStyles();
array_push($conditionalStyles, $conditional1);
array_push($conditionalStyles, $conditional3);
$conditionalStyles[] = $conditional1;
$conditionalStyles[] = $conditional3;
$spreadsheet->getActiveSheet()->getStyle('A1')->setConditionalStyles($conditionalStyles);
// duplicate the conditional styles across a range of cells

View File

@ -86,7 +86,7 @@ class WorkbookTest extends PHPUnit_Framework_TestCase
// Add new color after all existing color
$colorsAddTwo = array_map([$this, 'paletteToColor'], $palette);
array_push($colorsAddTwo, $this->paletteToColor($newColor1));
$colorsAddTwo[] = $this->paletteToColor($newColor1);
$paletteTestSix = $palette;
// Add one existing color