Tags: nikic/iter
Tags
Make phpdoc types more precise (#93) Improve type annotations by making use of templates, callable signatures and other type system features supported by psalm and phpstan. Additionally, this makes the following changes: * Fix CI to work on PHP 7.1 again. * Add psalm and phpstan to require-dev for validation. * Handle IteratorAggregate returning a non-Iterator in isEmpty(). * In functions that take a `$levels = INF` parameter or similar, changed `INF` to `PHP_INT_MAX` as `INF` is a float type and not int as declared. In these cases, `$levels` can never exceed the `PHP_INT_MAX` anyhow. * Split off RewindableGenerator from RewindableIterator. * Psalm does not have support for recursive types. Functions which use recursive types have had a note added to the docblock to explain this. * I've not added docblocks to the functions in the `\iter\rewindable` namespace, as that would necessarily mean that any changes to the regular function would also need to be reflected in the docblocks for these methods. This does mean that these functions do not benefit from the Psalm type annotations currently. Co-authored-by: Andrew Moyes <andrew.moyes@futurenet.com>
PHP 8.1: fix deprecation notices A run on PHP 8.1 currently shows: ``` PHP Deprecated: Return type of iter\rewindable\_RewindableGenerator::current() should either be compatible with Iterator::current(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/src/iter.rewindable.php on line 123 PHP Deprecated: Return type of iter\rewindable\_RewindableGenerator::next() should either be compatible with Iterator::next(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/src/iter.rewindable.php on line 108 PHP Deprecated: Return type of iter\rewindable\_RewindableGenerator::key() should either be compatible with Iterator::key(): mixed, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/src/iter.rewindable.php on line 118 PHP Deprecated: Return type of iter\rewindable\_RewindableGenerator::valid() should either be compatible with Iterator::valid(): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/src/iter.rewindable.php on line 113 PHP Deprecated: Return type of iter\rewindable\_RewindableGenerator::rewind() should either be compatible with Iterator::rewind(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/src/iter.rewindable.php on line 103 PHP Deprecated: Return type of iter\_CountableTestDummy::count() should either be compatible with Countable::count(): int, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/iter/iter/test/iterTest.php on line 625 ``` These deprecation notices relate to the [Return types for internal methods RFC](https://wiki.php.net/rfc/internal_method_return_types) in PHP 8.1. Using the attribute will silence the deprecation notices for now for those methods for which it cannot be added yet (PHP 8.0 `mixed`). For all other methods, the return type has now been added.
PreviousNext