Closed dicrtarasov closed 2 years ago
Hm.. I'm test it and can't find any problems https://3v4l.org/7ldOG#v8.1.6
This is the syntax error, it can not be no problem definitely.
@dicrtarasov no syntax or any other errors are not detected. Extended class can omit parent's types.
Yes, generally children method can make return type narrow, but not wider. When no return type specified, it assume "mixed", which is widelly, then Iterator.
You can test it :) Parent -> child: mixed -> Iterator - Ok Iterator -> mixed - Error
Child can return only subclass of parent type compatibility.
As you can see, Error in this report is real. Try to google it.
PHP 8.1
@dicrtarasov can you add tests to detect your error?
When no return type specified, it assume "mixed", which is widelly, then Iterator.
Большинство неокончательных внутренних методов теперь требуют переопределяющих методов для объявления совместимого возвращаемого типа, в противном случае во время проверки наследования выдаётся уведомление об устаревании возможности. В случае, если тип возвращаемого значения не может быть объявлен для метода переопределения из-за проблем совместимости версий PHP, можно добавить атрибут #[ReturnTypeWillChange], чтобы заглушить уведомление об устаревании. https://www.php.net/manual/ru/migration81.incompatible.php
Атрибут #[ReturnTypeWillChange] решит эту проблему.
@dicrtarasov думаю тебе стоит обновится https://github.com/yiisoft/yii2/blob/6599713d2bcf4440190cec2b950b1738d7ddfae4/framework/web/SessionIterator.php#L62
Yii 2.0.45
@bizley can be close, already fixed
Great.
Additional info
This is because of missed return types of
SessionIterator implements \Iterator
:But
\Iterator
declare: