nategood / httpful

A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.
MIT License
1.74k stars 298 forks source link

Warnings in PHP 8.1 #296

Closed qrtyzmng closed 1 month ago

qrtyzmng commented 2 years ago

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

giagara commented 2 years ago

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

tprochazka commented 2 years ago

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

WebDevTX commented 1 year ago

Any updates or solutions on this? :/

TommySlokky commented 1 year ago

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

tworems commented 1 year ago

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.

nategood commented 1 month ago

Issue resolved in latest build.