httpful icon indicating copy to clipboard operation
httpful copied to clipboard

Warnings in PHP 8.1

Open qrtyzmng opened this issue 3 years ago • 5 comments

Can you add return types for PHP 8.1 to remove warnings?

In that line https://github.com/nategood/httpful/blob/master/src/Httpful/Response/Headers.php#L47 return type bool should be added to do that.

Now it ends up with:

Method "ArrayAccess::offsetUnset()" might add "void" as a native return type declaration in the future. Do the same in implementation "Httpful\Response\Headers" now to avoid errors or add an explicit @return annotation to suppress this message.

Return type of Httpful\Response\Headers::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Return type of Httpful\Response\Headers::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

  • Other methods defined in \ArrayAccess and \Countablealso should be fixed.

qrtyzmng avatar Jan 05 '22 14:01 qrtyzmng

can confirm. Also lines: https://github.com/nategood/httpful/blob/0cded3ea97ba905600de9ceb9ef13f3ab681587c/src/Httpful/Response/Headers.php#L56 https://github.com/nategood/httpful/blob/0cded3ea97ba905600de9ceb9ef13f3ab681587c/src/Httpful/Response/Headers.php#L66

and others has issues

giagara avatar Jul 14 '22 17:07 giagara

Why do I have this as a fatal error instead of a warning :-( Is there any fork that is fixing this already?

tprochazka avatar Aug 02 '22 01:08 tprochazka

Any updates or solutions on this? :/

WebDevTX avatar Nov 04 '22 03:11 WebDevTX

Current errors I get are:

Deprecated: Return type of Httpful\Response\Headers::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in c:\examplesite\vendor\httpful-master\src\Httpful\Response\Headers.php on line 47

Deprecated: Return type of Httpful\Response\Headers::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:\examplesite\vendor\httpful-master\src\Httpful\Response\Headers.php on line 56

Deprecated: Return type of Httpful\Response\Headers::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in c:\examplesite\vendor\httpful-master\src\Httpful\Response\Headers.php on line 66

Deprecated: Return type of Httpful\Response\Headers::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in c:\examplesite\vendor\httpful-master\src\Httpful\Response\Headers.php on line 75

Deprecated: Return type of Httpful\Response\Headers::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in c:\examplesite\vendor\httpful-master\src\Httpful\Response\Headers.php on line 83

TommySlokky avatar Dec 27 '22 00:12 TommySlokky

I'm also having this issue. Fixed it by adding #[\ReturnTypeWillChange] in the code a bunch of times but will keep an eye here for the definitive fix.

tworems avatar Jan 24 '23 16:01 tworems

Issue resolved in latest build.

nategood avatar Jul 31 '24 12:07 nategood