szepeviktor/phpstan-wordpress

Deprecation Warnings of missing return types in WP stubs

j-manu opened this issue · 9 comments

When running analyze I get the following deprecation warnings. I'm using PHPStan using docker.

Deprecated: Return type of Requests_Utility_FilteredIterator::unserialize($serialized) should either be compatible with ArrayIterator::unserialize(string $data): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 21346
Deprecated: Return type of Requests_Utility_FilteredIterator::__unserialize($serialized) should either be compatible with ArrayIterator::__unserialize(array $data): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 21354
Deprecated: Return type of Requests_Utility_FilteredIterator::current() should either be compatible with ArrayIterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 21340
Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 18582
Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 18591
Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 18602
Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 18610
Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 18618
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 20573
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 20582
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 20593
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 20601
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 20609
Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31174
Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31196
Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31186
Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31206
Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31162
Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31114
Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31127
Deprecated: Return type of WP_Block_List::offsetSet($index, $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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31140
Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31152
Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 31218
Deprecated: Return type of WP_Hook::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39085
Deprecated: Return type of WP_Hook::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39097
Deprecated: Return type of WP_Hook::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39109
Deprecated: Return type of WP_Hook::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39121
Deprecated: Return type of WP_Hook::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39131
Deprecated: Return type of WP_Hook::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39035
Deprecated: Return type of WP_Hook::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39048
Deprecated: Return type of WP_Hook::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39061
Deprecated: Return type of WP_Hook::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 39073
Deprecated: Return type of WP_Theme::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 50086
Deprecated: Return type of WP_Theme::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 50104
Deprecated: Return type of WP_Theme::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 50065
Deprecated: Return type of WP_Theme::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 50075
Deprecated: Return type of WP_REST_Request::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 59361
Deprecated: Return type of WP_REST_Request::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 59372
Deprecated: Return type of WP_REST_Request::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 59383
Deprecated: Return type of WP_REST_Request::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 /composer/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 59393

phpstan.neon

parameters:
	level: 0
	paths:
		- plugin.php
includes:
    - /composer/vendor/szepeviktor/phpstan-wordpress/extension.neon

Hello @j-manu! 👋
Could it be that you somehow analyze WP stubs?
What is your PHP version?

What directory to you map to /app?
https://phpstan.org/user-guide/docker#usage
The one that contains plugin.php?

@szepeviktor Wow. That was a quick response :)

I have created a minimal reproduction repo - https://github.com/j-manu/phpstan-wp-poc

phpstan run which shows the deprecations - https://github.com/j-manu/phpstan-wp-poc/runs/4779013038?check_suite_focus=true

That container runs on PHP 8.1 I suspected that!
https://github.com/szepeviktor/phpstan-wp-poc/runs/4779346248?check_suite_focus=true#step:4:6

This project is not yet PHP 8.1 compatible - much like WordPress core :)

@ondrejmirtes Do you have a Docker image that runs on PHP 8.0?

@ondrejmirtes Thank you.
Seems like Alpine upgraded to PHP 8.1
kép

@szepeviktor Thank you! For the WP extension for phpstan and for the prompt response to the issue.

@ondrejmirtes Do you mind pinning the PHP version in docker to 8.0? i.e use FROM php:8.0-cli-alpine here https://github.com/phpstan/phpstan/blob/master/docker/Dockerfile#L1 You can even create tagged releases just like PHP to cater to both 8.0 and 8.1 at the same time.

@j-manu Please do open a PR for that.