Skip to content

Commit 8a7b08e

Browse files
Add return types - batch 2/n
1 parent 5fd56a0 commit 8a7b08e

File tree

7 files changed

+13
-30
lines changed

7 files changed

+13
-30
lines changed

CssSelectorConverter.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ public function __construct(bool $html = true)
5959
*
6060
* Optionally, a prefix can be added to the resulting XPath
6161
* expression with the $prefix parameter.
62-
*
63-
* @return string
6462
*/
65-
public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::')
63+
public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
6664
{
6765
return $this->cache[$prefix][$cssExpr] ?? $this->cache[$prefix][$cssExpr] = $this->translator->cssToXPath($cssExpr, $prefix);
6866
}

Exception/SyntaxErrorException.php

+5-20
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,27 @@
2323
*/
2424
class SyntaxErrorException extends ParseException
2525
{
26-
/**
27-
* @return self
28-
*/
29-
public static function unexpectedToken(string $expectedValue, Token $foundToken)
26+
public static function unexpectedToken(string $expectedValue, Token $foundToken): self
3027
{
3128
return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
3229
}
3330

34-
/**
35-
* @return self
36-
*/
37-
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation)
31+
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation): self
3832
{
3933
return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
4034
}
4135

42-
/**
43-
* @return self
44-
*/
45-
public static function unclosedString(int $position)
36+
public static function unclosedString(int $position): self
4637
{
4738
return new self(sprintf('Unclosed/invalid string at %s.', $position));
4839
}
4940

50-
/**
51-
* @return self
52-
*/
53-
public static function nestedNot()
41+
public static function nestedNot(): self
5442
{
5543
return new self('Got nested ::not().');
5644
}
5745

58-
/**
59-
* @return self
60-
*/
61-
public static function stringAsFunctionArgument()
46+
public static function stringAsFunctionArgument(): self
6247
{
6348
return new self('String not allowed as function argument.');
6449
}

Parser/Reader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getOffset(string $string)
6363
/**
6464
* @return array|false
6565
*/
66-
public function findPattern(string $pattern)
66+
public function findPattern(string $pattern): array|false
6767
{
6868
$source = substr($this->source, $this->position);
6969

Parser/TokenStream.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class TokenStream
4545
*
4646
* @return $this
4747
*/
48-
public function push(Token $token): self
48+
public function push(Token $token): static
4949
{
5050
$this->tokens[] = $token;
5151

@@ -57,7 +57,7 @@ public function push(Token $token): self
5757
*
5858
* @return $this
5959
*/
60-
public function freeze(): self
60+
public function freeze(): static
6161
{
6262
return $this;
6363
}

XPath/Extension/NodeExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(int $flags = 0)
4141
/**
4242
* @return $this
4343
*/
44-
public function setFlag(int $flag, bool $on): self
44+
public function setFlag(int $flag, bool $on): static
4545
{
4646
if ($on && !$this->hasFlag($flag)) {
4747
$this->flags += $flag;

XPath/Translator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function selectorToXPath(SelectorNode $selector, string $prefix = 'descen
117117
/**
118118
* @return $this
119119
*/
120-
public function registerExtension(Extension\ExtensionInterface $extension): self
120+
public function registerExtension(Extension\ExtensionInterface $extension): static
121121
{
122122
$this->extensions[$extension->getName()] = $extension;
123123

@@ -145,7 +145,7 @@ public function getExtension(string $name): Extension\ExtensionInterface
145145
/**
146146
* @return $this
147147
*/
148-
public function registerParserShortcut(ParserInterface $shortcut): self
148+
public function registerParserShortcut(ParserInterface $shortcut): static
149149
{
150150
$this->shortcutParsers[] = $shortcut;
151151

XPath/XPathExpr.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function addStarPrefix(): self
7777
*
7878
* @return $this
7979
*/
80-
public function join(string $combiner, self $expr): self
80+
public function join(string $combiner, self $expr): static
8181
{
8282
$path = $this->__toString().$combiner;
8383

0 commit comments

Comments
 (0)