PHPOffice/PHPExcel — pull request #251 by AZielinski (2013-09-27 07:55:19+00:00)
Title: Infinite recursion on save after duplicating style from cell X (e.g. A1) to the same cell (A1)

This is basically a fix for this issue: http://stackoverflow.com/questions/18742595/phpexcel-style-fill-infinite-recursion ;

It is impossible to save a worksheet after duplicating a style from specific cell to the same cell. Let's take a look at the quick example of that issue:

```php
$phpe = new PHPExcel();
$sheet = $phpe->createSheet();

$sheet->setCellValue('A1', 'hi there') ;
$sheet->setCellValue('A2', 'hi again') ;

$sheet->duplicateStyle($sheet->getStyle('A1'), 'A2');
$sheet->duplicateStyle($sheet->getStyle('A1'), 'A1');

$writer = new PHPExcel_Writer_Excel2007($phpe);
$writer->save('./test.xlsx');
```

Expected result would be to have the worksheet saved to test.xlsx file. What happens instead is this:

```

PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/opensource/PHPExcel/Classes/PHPExcel.php on line 94
PHP Stack trace:
PHP 1. {main}() /var/www/opensource/PHPExcel/test.php:0
PHP 2. PHPExcel_Writer_Excel2007->save() /var/www/opensource/PHPExcel/test.php:15
PHP 3. PHPExcel_HashTable->addFromSource() /var/www/opensource/PHPExcel/Classes/PHPExcel/Writer/Excel2007.php:202
PHP 4. PHPExcel_HashTable->add() /var/www/opensource/PHPExcel/Classes/PHPExcel/HashTable.php:81
PHP 5. PHPExcel_Style->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/HashTable.php:92
PHP 6. PHPExcel_Style_Fill->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/Style.php:636
PHP 7. PHPExcel_Style_Fill->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/Style/Fill.php:310
PHP 8. PHPExcel_Style_Fill->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/Style/Fill.php:310
PHP 9. PHPExcel_Style_Fill->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/Style/Fill.php:310
PHP 10. PHPExcel_Style_Fill->getHashCode() /var/www/opensource/PHPExcel/Classes/PHPExcel/Style/Fill.php:310
...
```

This is because after performing such a duplication, we come to a situation in which `$this->getSharedComponent === $this` is true in PHPExcel_Style_Fill and a bunch of other objects

However it works just fine after removing this line:

```php
$sheet->duplicateStyle($sheet->getStyle('A1'), 'A1');
```

So I added a necessary `$this !== $this->getSharedComponent()` check in every appropriate place, and it works just fine afterwards.