Skip to content

Commit a653e09

Browse files
Jean85PowerKiKi
authored andcommitted
Remove duplicated code and call parent methods where possible
1 parent f246ad7 commit a653e09

File tree

8 files changed

+3
-401
lines changed

8 files changed

+3
-401
lines changed

src/PhpSpreadsheet/RichText/Run.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class Run extends TextElement implements ITextElement
2121
*/
2222
public function __construct($pText = '')
2323
{
24+
parent::__construct($pText);
2425
// Initialise variables
25-
$this->setText($pText);
2626
$this->font = new Font();
2727
}
2828

@@ -65,19 +65,4 @@ public function getHashCode()
6565
__CLASS__
6666
);
6767
}
68-
69-
/**
70-
* Implement PHP __clone to create a deep clone, not just a shallow copy.
71-
*/
72-
public function __clone()
73-
{
74-
$vars = get_object_vars($this);
75-
foreach ($vars as $key => $value) {
76-
if (is_object($value)) {
77-
$this->$key = clone $value;
78-
} else {
79-
$this->$key = $value;
80-
}
81-
}
82-
}
8368
}

src/PhpSpreadsheet/Shared/Trend/BestFit.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,9 @@ public function __construct($yValues, $xValues = [], $const = true)
411411
// Define X Values if necessary
412412
if ($nX == 0) {
413413
$xValues = range(1, $nY);
414-
$nX = $nY;
415414
} elseif ($nY != $nX) {
416415
// Ensure both arrays of points are the same size
417416
$this->error = true;
418-
419-
return false;
420417
}
421418

422419
$this->valueCount = $nY;

src/PhpSpreadsheet/Style/Style.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class Style extends Supervisor
8282
*/
8383
public function __construct($isSupervisor = false, $isConditional = false)
8484
{
85-
// Supervisor?
86-
$this->isSupervisor = $isSupervisor;
85+
parent::__construct($this->isSupervisor);
8786

8887
// Initialise values
8988
$this->conditionalStyles = [];

src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ public function __construct(Worksheet $subject = null, $columnIndex = 'A', $star
5252
$this->resetStart($startRow);
5353
}
5454

55-
/**
56-
* Destructor.
57-
*/
58-
public function __destruct()
59-
{
60-
unset($this->worksheet);
61-
}
62-
6355
/**
6456
* (Re)Set the start row and the current row pointer.
6557
*

src/PhpSpreadsheet/Worksheet/Drawing.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,4 @@ public function getHashCode()
113113
__CLASS__
114114
);
115115
}
116-
117-
/**
118-
* Implement PHP __clone to create a deep clone, not just a shallow copy.
119-
*/
120-
public function __clone()
121-
{
122-
$vars = get_object_vars($this);
123-
foreach ($vars as $key => $value) {
124-
if (is_object($value)) {
125-
$this->$key = clone $value;
126-
} else {
127-
$this->$key = $value;
128-
}
129-
}
130-
}
131116
}

0 commit comments

Comments
 (0)