Skip to content

Commit d57a7eb

Browse files
committed
Updated method signatures
1 parent 9b32cd1 commit d57a7eb

File tree

15 files changed

+238
-183
lines changed

15 files changed

+238
-183
lines changed

src/PHPHtmlParser/Content.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class Content
4343
/**
4444
* Content constructor.
4545
*
46-
* @param $content
46+
* @param string $content
4747
*/
48-
public function __construct($content)
48+
public function __construct(string $content = '')
4949
{
5050
$this->content = $content;
5151
$this->size = strlen($content);
@@ -57,7 +57,7 @@ public function __construct($content)
5757
*
5858
* @return int
5959
*/
60-
public function getPosition()
60+
public function getPosition(): int
6161
{
6262
return $this->pos;
6363
}
@@ -68,7 +68,7 @@ public function getPosition()
6868
* @param int $char
6969
* @return string
7070
*/
71-
public function char($char = null)
71+
public function char(int $char = null): string
7272
{
7373
$pos = $this->pos;
7474
if ( ! is_null($char)) {
@@ -86,9 +86,10 @@ public function char($char = null)
8686
* Moves the current position forward.
8787
*
8888
* @param int $count
89-
* @return $this
89+
* @return Content
90+
* @chainable
9091
*/
91-
public function fastForward($count)
92+
public function fastForward(int $count): Content
9293
{
9394
$this->pos += $count;
9495

@@ -99,9 +100,10 @@ public function fastForward($count)
99100
* Moves the current position backward.
100101
*
101102
* @param int $count
102-
* @return $this
103+
* @return Content
104+
* @chainable
103105
*/
104-
public function rewind($count)
106+
public function rewind(int $count): Content
105107
{
106108
$this->pos -= $count;
107109
if ($this->pos < 0) {
@@ -119,7 +121,7 @@ public function rewind($count)
119121
* @param bool $escape
120122
* @return string
121123
*/
122-
public function copyUntil($string, $char = false, $escape = false)
124+
public function copyUntil(string $string, bool $char = false, bool $escape = false): string
123125
{
124126
if ($this->pos >= $this->size) {
125127
// nothing left
@@ -180,7 +182,7 @@ public function copyUntil($string, $char = false, $escape = false)
180182
* @param string $unless
181183
* @return string
182184
*/
183-
public function copyUntilUnless($string, $unless)
185+
public function copyUntilUnless(string $string, string $unless)
184186
{
185187
$lastPos = $this->pos;
186188
$this->fastForward(1);
@@ -205,7 +207,7 @@ public function copyUntilUnless($string, $unless)
205207
* @return string
206208
* @uses $this->copyUntil()
207209
*/
208-
public function copyByToken($token, $char = false, $escape = false)
210+
public function copyByToken(string $token, bool $char = false, bool $escape = false)
209211
{
210212
$string = $this->$token;
211213

@@ -219,7 +221,7 @@ public function copyByToken($token, $char = false, $escape = false)
219221
* @param bool $copy
220222
* @return $this|string
221223
*/
222-
public function skip($string, $copy = false)
224+
public function skip(string $string, bool $copy = false)
223225
{
224226
$len = strspn($this->content, $string, $this->pos);
225227

@@ -243,7 +245,7 @@ public function skip($string, $copy = false)
243245
* @return null|string
244246
* @uses $this->skip()
245247
*/
246-
public function skipByToken($token, $copy = false)
248+
public function skipByToken(string $token, bool $copy = false)
247249
{
248250
$string = $this->$token;
249251

src/PHPHtmlParser/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Curl implements CurlInterface
1818
* @return string
1919
* @throws CurlException
2020
*/
21-
public function get($url)
21+
public function get(string $url): string
2222
{
2323
$ch = curl_init($url);
2424

src/PHPHtmlParser/CurlInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ interface CurlInterface
1515
* @param string $url
1616
* @return string
1717
*/
18-
public function get($url);
18+
public function get($url): string;
1919
}

0 commit comments

Comments
 (0)