Skip to content

Commit 2a62c24

Browse files
authored
Merge pull request #19 from Schleuse/fix-deprecation-messages-on-php-81
Fix deprecations messages due to type changes on PHP 8.1 & PHP 8.2
2 parents d22315f + 2d5c01b commit 2a62c24

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/StringTemplate/NestedKeyArray.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ public function __construct(array &$array, $keySeparator = '.')
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function getIterator()
31+
public function getIterator(): \Traversable
3232
{
3333
return new NestedKeyIterator(new RecursiveArrayOnlyIterator($this->array));
3434
}
3535

3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function offsetExists($offset)
39+
public function offsetExists($offset): bool
4040
{
4141
$keys = explode($this->keySeparator, $offset);
4242
$ary = &$this->array;
@@ -53,6 +53,7 @@ public function offsetExists($offset)
5353
/**
5454
* {@inheritdoc}
5555
*/
56+
#[\ReturnTypeWillChange]
5657
public function offsetGet($offset)
5758
{
5859
$keys = explode($this->keySeparator, $offset);
@@ -68,15 +69,15 @@ public function offsetGet($offset)
6869
/**
6970
* {@inheritdoc}
7071
*/
71-
public function offsetSet($offset, $value)
72+
public function offsetSet($offset, $value): void
7273
{
7374
$this->setNestedOffset($this->array, explode($this->keySeparator, $offset), $value);
7475
}
7576

7677
/**
7778
* {@inheritdoc}
7879
*/
79-
public function offsetUnset($offset)
80+
public function offsetUnset($offset): void
8081
{
8182
$this->unsetNestedOffset($this->array, explode($this->keySeparator, $offset));
8283
}

src/StringTemplate/NestedKeyIterator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct(\Traversable $iterator, $separator = '.', $mode = \R
5757
/**
5858
* {@inheritdoc}
5959
*/
60-
public function callGetChildren()
60+
public function callGetChildren(): ?\RecursiveIterator
6161
{
6262
$this->stack[] = parent::key();
6363
return parent::callGetChildren();
@@ -66,7 +66,7 @@ public function callGetChildren()
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function endChildren()
69+
public function endChildren(): void
7070
{
7171
parent::endChildren();
7272
array_pop($this->stack);
@@ -75,11 +75,12 @@ public function endChildren()
7575
/**
7676
* {@inheritdoc}
7777
*/
78+
#[\ReturnTypeWillChange]
7879
public function key()
7980
{
8081
$keys = $this->stack;
8182
$keys[] = parent::key();
8283

8384
return implode($this->keySeparator, $keys);
8485
}
85-
}
86+
}

src/StringTemplate/RecursiveArrayOnlyIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RecursiveArrayOnlyIterator extends \RecursiveArrayIterator
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function hasChildren()
25+
public function hasChildren(): bool
2626
{
2727
return is_array($this->current()) || $this->current() instanceof \Traversable;
2828
}

0 commit comments

Comments
 (0)