Skip to content

Commit 15f7a93

Browse files
authored
[TASK] Drop redundant constructor code (#932)
- use default values for properties instead of setting them in the constructor - drop constructors that are redundant to the constructor of the parent class
1 parent e1fa3b6 commit 15f7a93

File tree

13 files changed

+15
-71
lines changed

13 files changed

+15
-71
lines changed

src/CSSList/CSSBlockList.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
*/
2121
abstract class CSSBlockList extends CSSList
2222
{
23-
/**
24-
* @param int<0, max> $lineNumber
25-
*/
26-
public function __construct($lineNumber = 0)
27-
{
28-
parent::__construct($lineNumber);
29-
}
30-
3123
/**
3224
* @param array<int, DeclarationBlock> $result
3325
*/

src/CSSList/CSSList.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ abstract class CSSList implements Renderable, Commentable
3838
*
3939
* @internal since 8.8.0
4040
*/
41-
protected $comments;
41+
protected $comments = [];
4242

4343
/**
4444
* @var array<int, RuleSet|CSSList|Import|Charset>
4545
*
4646
* @internal since 8.8.0
4747
*/
48-
protected $contents;
48+
protected $contents = [];
4949

5050
/**
5151
* @var int<0, max>
@@ -59,8 +59,6 @@ abstract class CSSList implements Renderable, Commentable
5959
*/
6060
public function __construct($lineNumber = 0)
6161
{
62-
$this->comments = [];
63-
$this->contents = [];
6462
$this->lineNumber = $lineNumber;
6563
}
6664

src/CSSList/Document.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
*/
1919
class Document extends CSSBlockList
2020
{
21-
/**
22-
* @param int<0, max> $lineNumber
23-
*/
24-
public function __construct($lineNumber = 0)
25-
{
26-
parent::__construct($lineNumber);
27-
}
28-
2921
/**
3022
* @throws SourceException
3123
*

src/CSSList/KeyFrame.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ class KeyFrame extends CSSList implements AtRule
1919
*/
2020
private $animationName;
2121

22-
/**
23-
* @param int<0, max> $lineNumber
24-
*/
25-
public function __construct($lineNumber = 0)
26-
{
27-
parent::__construct($lineNumber);
28-
$this->vendorKeyFrame = null;
29-
$this->animationName = null;
30-
}
31-
3222
/**
3323
* @param string $vendorKeyFrame
3424
*/

src/OutputFormat.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ class OutputFormat
217217
/**
218218
* @var OutputFormatter|null
219219
*/
220-
private $oFormatter = null;
220+
private $oFormatter;
221221

222222
/**
223223
* @var OutputFormat|null
224224
*/
225-
private $oNextLevelFormat = null;
225+
private $oNextLevelFormat;
226226

227227
/**
228228
* @var int

src/Parsing/ParserState.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ParserState
3737
/**
3838
* @var int
3939
*/
40-
private $iCurrentPosition;
40+
private $iCurrentPosition = 0;
4141

4242
/**
4343
* will only be used if the CSS does not contain an `@charset` declaration
@@ -64,7 +64,6 @@ public function __construct($sText, Settings $oParserSettings, $lineNumber = 1)
6464
{
6565
$this->oParserSettings = $oParserSettings;
6666
$this->sText = $sText;
67-
$this->iCurrentPosition = 0;
6867
$this->lineNumber = $lineNumber;
6968
$this->setCharset($this->oParserSettings->sDefaultCharset);
7069
}

src/Property/CSSNamespace.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CSSNamespace implements AtRule
3232
*
3333
* @internal since 8.8.0
3434
*/
35-
protected $comments;
35+
protected $comments = [];
3636

3737
/**
3838
* @param string $mUrl
@@ -44,7 +44,6 @@ public function __construct($mUrl, $prefix = null, $lineNumber = 0)
4444
$this->mUrl = $mUrl;
4545
$this->prefix = $prefix;
4646
$this->lineNumber = $lineNumber;
47-
$this->comments = [];
4847
}
4948

5049
/**

src/Property/Charset.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Charset implements AtRule
3535
*
3636
* @internal since 8.8.0
3737
*/
38-
protected $comments;
38+
protected $comments = [];
3939

4040
/**
4141
* @param int<0, max> $lineNumber
@@ -44,7 +44,6 @@ public function __construct(CSSString $oCharset, $lineNumber = 0)
4444
{
4545
$this->oCharset = $oCharset;
4646
$this->lineNumber = $lineNumber;
47-
$this->comments = [];
4847
}
4948

5049
/**

src/Property/Import.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Import implements AtRule
3535
*
3636
* @internal since 8.8.0
3737
*/
38-
protected $comments;
38+
protected $comments = [];
3939

4040
/**
4141
* @param string $mediaQuery
@@ -46,7 +46,6 @@ public function __construct(URL $location, $mediaQuery, $lineNumber = 0)
4646
$this->location = $location;
4747
$this->mediaQuery = $mediaQuery;
4848
$this->lineNumber = $lineNumber;
49-
$this->comments = [];
5049
}
5150

5251
/**

src/Rule/Rule.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class Rule implements Renderable, Commentable
3434
/**
3535
* @var bool
3636
*/
37-
private $bIsImportant;
37+
private $bIsImportant = false;
3838

3939
/**
4040
* @var array<int, int>
4141
*/
42-
private $aIeHack;
42+
private $aIeHack = [];
4343

4444
/**
4545
* @var int
@@ -58,7 +58,7 @@ class Rule implements Renderable, Commentable
5858
*
5959
* @internal since 8.8.0
6060
*/
61-
protected $comments;
61+
protected $comments = [];
6262

6363
/**
6464
* @param string $sRule
@@ -68,12 +68,8 @@ class Rule implements Renderable, Commentable
6868
public function __construct($sRule, $lineNumber = 0, $iColNo = 0)
6969
{
7070
$this->sRule = $sRule;
71-
$this->mValue = null;
72-
$this->bIsImportant = false;
73-
$this->aIeHack = [];
7471
$this->lineNumber = $lineNumber;
7572
$this->iColNo = $iColNo;
76-
$this->comments = [];
7773
}
7874

7975
/**

src/RuleSet/DeclarationBlock.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ class DeclarationBlock extends RuleSet
2727
/**
2828
* @var array<int, Selector|string>
2929
*/
30-
private $aSelectors;
31-
32-
/**
33-
* @param int<0, max> $lineNumber
34-
*/
35-
public function __construct($lineNumber = 0)
36-
{
37-
parent::__construct($lineNumber);
38-
$this->aSelectors = [];
39-
}
30+
private $aSelectors = [];
4031

4132
/**
4233
* @param CSSList|null $list

src/RuleSet/RuleSet.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class RuleSet implements Renderable, Commentable
2727
/**
2828
* @var array<string, Rule>
2929
*/
30-
private $aRules;
30+
private $aRules = [];
3131

3232
/**
3333
* @var int<0, max>
@@ -41,16 +41,14 @@ abstract class RuleSet implements Renderable, Commentable
4141
*
4242
* @internal since 8.8.0
4343
*/
44-
protected $comments;
44+
protected $comments = [];
4545

4646
/**
4747
* @param int<0, max> $lineNumber
4848
*/
4949
public function __construct($lineNumber = 0)
5050
{
51-
$this->aRules = [];
5251
$this->lineNumber = $lineNumber;
53-
$this->comments = [];
5452
}
5553

5654
/**

src/Value/PrimitiveValue.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,4 @@
44

55
namespace Sabberworm\CSS\Value;
66

7-
abstract class PrimitiveValue extends Value
8-
{
9-
/**
10-
* @param int<0, max> $lineNumber
11-
*/
12-
public function __construct($lineNumber = 0)
13-
{
14-
parent::__construct($lineNumber);
15-
}
16-
}
7+
abstract class PrimitiveValue extends Value {}

0 commit comments

Comments
 (0)