simple-php-router icon indicating copy to clipboard operation
simple-php-router copied to clipboard

Problema con PHP 8.1.2

Open jorge-koki opened this issue 3 years ago • 2 comments

Deprecated: Return type of Pecee\Http\Input\InputItem::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\xampp\htdocs\apigastosreales\vendor\pecee\simple-router\src\Pecee\Http\Input\InputItem.php on line 84

Tal como lo indica agregue la linea #[\ReturnTypeWillChange] para quitar el aviso temporalmente

jorge-koki avatar Feb 19 '22 17:02 jorge-koki

Hello, first it would be great if you can write in english. We currently cannot add the #[\ReturnTypeWillChange] Attribute, because attributes were intoduced in PHP 8 and we are currently compatible with PHP 7.1. Also we cannot use the union type mixed, bacause that was also intoduced in PHP 8. Feel free to add the attribute in your code. Alternativly you can change your code from

foreach($inputitem as $value){
 echo $value;
}

to

foreach($inputitem->getValue() as $value){
 echo $value;
}

I currently don't know if not using the methods provided by ArrayAccess will suppress this notice, but I think it is worth a try. Please let me know if using getValue() suppresses the notice.

@skipperbent we have to update the project to PHP 7.3 or 7.4 soon. The version is not supported anymore, like I mentioned in PR #515 and PR #611. A temporary solution would be to remove the ArrayAccess interface from the InputItem class. What do you think @skipperbent?

~ Marius

DeveloperMarius avatar Feb 19 '22 17:02 DeveloperMarius

Hello, did this fix work for you?

~ Marius

DeveloperMarius avatar Mar 01 '22 15:03 DeveloperMarius