You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP8.1 (at least - did not test with PHP8.0) logs deprecated issues because the 5 inherited methods from the Iterator base class in VCardParser do not declare the return type:
[20-Oct-2022 12:29:54 Europe/Vienna] PHP Deprecated: Return type of JeroenDesloovere\VCard\VCardParser::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .\VCardParser.php on line 72
[20-Oct-2022 12:29:54 Europe/Vienna] PHP Deprecated: Return type of JeroenDesloovere\VCard\VCardParser::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .\VCardParser.php on line 84
[20-Oct-2022 12:29:54 Europe/Vienna] PHP Deprecated: Return type of JeroenDesloovere\VCard\VCardParser::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .\VCardParser.php on line 79
[20-Oct-2022 12:29:54 Europe/Vienna] PHP Deprecated: Return type of JeroenDesloovere\VCard\VCardParser::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .\VCardParser.php on line 89
[20-Oct-2022 12:29:54 Europe/Vienna] PHP Deprecated: Return type of JeroenDesloovere\VCard\VCardParser::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in .\VCardParser.php on line 67
Fix:
Add return type :mixed to methods current() and key(),
add return type :bool to method valid(),
add return type :void to methods rewind(), next().
The text was updated successfully, but these errors were encountered:
I was able to fix the problem by naming the type of the functions public (void, mixed, bool).
No more deprecation messages.
Change in class : VCardParser.php
...
public function rewind(): void {
$this->position = 0;
}
public function current(): mixed {
if ($this->valid()) {
return $this->getCardAtIndex($this->position);
}
}
public function key(): mixed {
return $this->position;
}
public function next(): void {
$this->position++;
}
public function valid(): bool {
return !empty($this->vcardObjects[$this->position]);
}
...
I just saw that the answer was already there, by [codeflow-biz].
But I didn't understand.
PHP8.1 (at least - did not test with PHP8.0) logs deprecated issues because the 5 inherited methods from the Iterator base class in VCardParser do not declare the return type:
Fix:
Add return type :mixed to methods current() and key(),
add return type :bool to method valid(),
add return type :void to methods rewind(), next().
The text was updated successfully, but these errors were encountered: