Skip to content

Commit 226b38d

Browse files
author
Robin Chalas
committed
Add scalar typehints/return types on final/internal/private code
1 parent ca01c22 commit 226b38d

31 files changed

+77
-259
lines changed

Node/AbstractNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class AbstractNode implements NodeInterface
3131
/**
3232
* @return string
3333
*/
34-
public function getNodeName()
34+
public function getNodeName(): string
3535
{
3636
if (null === $this->nodeName) {
3737
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', get_called_class());

Node/AttributeNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ public function getValue()
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function getSpecificity()
110+
public function getSpecificity(): Specificity
111111
{
112112
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
113113
}
114114

115115
/**
116116
* {@inheritdoc}
117117
*/
118-
public function __toString()
118+
public function __toString(): string
119119
{
120120
$attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute;
121121

Node/ClassNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function getName()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getSpecificity()
65+
public function getSpecificity(): Specificity
6666
{
6767
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function __toString()
73+
public function __toString(): string
7474
{
7575
return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name);
7676
}

Node/CombinedSelectorNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ public function getSubSelector()
7777
/**
7878
* {@inheritdoc}
7979
*/
80-
public function getSpecificity()
80+
public function getSpecificity(): Specificity
8181
{
8282
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
8383
}
8484

8585
/**
8686
* {@inheritdoc}
8787
*/
88-
public function __toString()
88+
public function __toString(): string
8989
{
9090
$combinator = ' ' === $this->combinator ? '<followed>' : $this->combinator;
9191

Node/ElementNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function getElement()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getSpecificity()
65+
public function getSpecificity(): Specificity
6666
{
6767
return new Specificity(0, 0, $this->element ? 1 : 0);
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function __toString()
73+
public function __toString(): string
7474
{
7575
$element = $this->element ?: '*';
7676

Node/FunctionNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ public function getArguments()
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function getSpecificity()
82+
public function getSpecificity(): Specificity
8383
{
8484
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
8585
}
8686

8787
/**
8888
* {@inheritdoc}
8989
*/
90-
public function __toString()
90+
public function __toString(): string
9191
{
9292
$arguments = implode(', ', array_map(function (Token $token) {
9393
return "'".$token->getValue()."'";

Node/HashNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function getId()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getSpecificity()
65+
public function getSpecificity(): Specificity
6666
{
6767
return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0));
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function __toString()
73+
public function __toString(): string
7474
{
7575
return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id);
7676
}

Node/NegationNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function getSubSelector()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getSpecificity()
65+
public function getSpecificity(): Specificity
6666
{
6767
return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity());
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function __toString()
73+
public function __toString(): string
7474
{
7575
return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector);
7676
}

Node/NodeInterface.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,9 @@
2323
*/
2424
interface NodeInterface
2525
{
26-
/**
27-
* Returns node's name.
28-
*
29-
* @return string
30-
*/
31-
public function getNodeName();
26+
public function getNodeName(): string;
3227

33-
/**
34-
* Returns node's specificity.
35-
*
36-
* @return Specificity
37-
*/
38-
public function getSpecificity();
28+
public function getSpecificity(): Specificity;
3929

40-
/**
41-
* Returns node's string representation.
42-
*
43-
* @return string
44-
*/
45-
public function __toString();
30+
public function __toString(): string;
4631
}

Node/PseudoNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function getIdentifier()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getSpecificity()
65+
public function getSpecificity(): Specificity
6666
{
6767
return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0));
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function __toString()
73+
public function __toString(): string
7474
{
7575
return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier);
7676
}

0 commit comments

Comments
 (0)