Skip to content

Commit 343a4bf

Browse files
derrabusfabpot
authored andcommitted
Add types to constructors and private/final/internal methods (Batch I)
1 parent f7ff943 commit 343a4bf

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Dotenv.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function parse(string $data, string $path = '.env'): array
216216
}
217217
}
218218

219-
private function lexVarname()
219+
private function lexVarname(): string
220220
{
221221
// var name + optional export
222222
if (!preg_match('/(export[ \t]++)?('.self::VARNAME_REGEX.')/A', $this->data, $matches, 0, $this->cursor)) {
@@ -244,7 +244,7 @@ private function lexVarname()
244244
return $matches[2];
245245
}
246246

247-
private function lexValue()
247+
private function lexValue(): string
248248
{
249249
if (preg_match('/[ \t]*+(?:#.*)?$/Am', $this->data, $matches, 0, $this->cursor)) {
250250
$this->moveCursor($matches[0]);
@@ -339,7 +339,7 @@ private function lexValue()
339339
return $v;
340340
}
341341

342-
private function lexNestedExpression()
342+
private function lexNestedExpression(): string
343343
{
344344
++$this->cursor;
345345
$value = '';
@@ -372,7 +372,7 @@ private function skipEmptyLines()
372372
}
373373
}
374374

375-
private function resolveCommands(string $value)
375+
private function resolveCommands(string $value): string
376376
{
377377
if (false === strpos($value, '$')) {
378378
return $value;
@@ -419,7 +419,7 @@ private function resolveCommands(string $value)
419419
}, $value);
420420
}
421421

422-
private function resolveVariables(string $value)
422+
private function resolveVariables(string $value): string
423423
{
424424
if (false === strpos($value, '$')) {
425425
return $value;
@@ -487,7 +487,7 @@ private function moveCursor(string $text)
487487
$this->lineno += substr_count($text, "\n");
488488
}
489489

490-
private function createFormatException(string $message)
490+
private function createFormatException(string $message): FormatException
491491
{
492492
return new FormatException($message, new FormatExceptionContext($this->data, $this->path, $this->lineno, $this->cursor));
493493
}

Exception/FormatException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(string $message, FormatExceptionContext $context, in
2727
parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
2828
}
2929

30-
public function getContext()
30+
public function getContext(): FormatExceptionContext
3131
{
3232
return $this->context;
3333
}

Exception/FormatExceptionContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public function __construct(string $data, string $path, int $lineno, int $cursor
2929
$this->cursor = $cursor;
3030
}
3131

32-
public function getPath()
32+
public function getPath(): string
3333
{
3434
return $this->path;
3535
}
3636

37-
public function getLineno()
37+
public function getLineno(): int
3838
{
3939
return $this->lineno;
4040
}
4141

42-
public function getDetails()
42+
public function getDetails(): string
4343
{
4444
$before = str_replace("\n", '\n', substr($this->data, max(0, $this->cursor - 20), min(20, $this->cursor)));
4545
$after = str_replace("\n", '\n', substr($this->data, $this->cursor, 20));

0 commit comments

Comments
 (0)