Page 1 of 1

PHP 8.1

Posted: Thu Mar 10, 2022 6:00 pm
by Schachberg
Ich habe die neueste Version xampp (mit php 8.1) als Testbereich installiert und festgestellt, das 8.1 eine Warnung mit sich bringt.
Ich denke ich habe die neuste CMSimple-XH Version 1.7.5 Released: 2021-10-03
Warnund DEPRECATED:
Return type of XH\PluginConfig::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Es geht um diese codes:

cmsimple\classes\PluginConfig.php:

52 public function offsetExists($offset)
67 public function offsetGet($offset)
83 public function offsetSet($offset, $value)
98 public function offsetUnset($offset)

Ein wenig googeln ergab dann Folgendes. Es liegt offensichtlich speziell an PHP 8.1
#[\ReturnTypeWillChange]
public function offsetExists($offset)

#[\ReturnTypeWillChange] is a new attribute introduced in PHP 8.1, which signals that a mismatching tentative return type should not emit a deprecation notice.

PHP versions prior to 8.0 parses the attribute syntax as a code comment, and does not cause any syntax errors. Adding #[\ReturnTypeWillChange] attribute to a class method does not cause any issues, but omits the deprecation notice in PHP 8.1.

This is the first built-in attribute added to PHP.

class Foo implements ArrayAccess {
#[\ReturnTypeWillChange]
public function offsetGet(mixed $offset) {}
// ...
}
zu finden: https://php.watch/versions/8.1/ReturnTypeWillChange
Ich bin kein php Programmierer, denke aber jemand kann das leicht anpassen kann.

Re: PHP 8.1

Posted: Thu Mar 10, 2022 6:30 pm
by olape

Re: PHP 8.1

Posted: Thu Mar 10, 2022 9:34 pm
by Schachberg
Danke olape, hatte ich nicht gesehen.
Ich glaube in der geänderten Datei fehlt in der Zeile 100 ein "\" #[\ReturnTypeWillChange]

Re: PHP 8.1

Posted: Fri Mar 11, 2022 6:50 am
by olape
Schachberg wrote:
Thu Mar 10, 2022 9:34 pm
Danke olape, hatte ich nicht gesehen.
Kein Problem, geht mir auch oft so.
Schachberg wrote:
Thu Mar 10, 2022 9:34 pm
Ich glaube in der geänderten Datei fehlt in der Zeile 100 ein "\"
Da hast du sicher recht.

Re: PHP 8.1

Posted: Fri Mar 11, 2022 11:24 am
by cmb
Schachberg wrote:
Thu Mar 10, 2022 9:34 pm
Ich glaube in der geänderten Datei fehlt in der Zeile 100 ein "\" #[\ReturnTypeWillChange]
Wurde inzwischen bereits erledigt.