Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error PHP Deprecated: Return type of yii\web\Session::getIterator() #19107

Closed
Tracked by #19041
pamparam83 opened this issue Dec 22, 2021 · 4 comments
Closed
Tracked by #19041

error PHP Deprecated: Return type of yii\web\Session::getIterator() #19107

pamparam83 opened this issue Dec 22, 2021 · 4 comments
Labels
php8 status:ready for adoption Feel free to implement this issue.

Comments

@pamparam83
Copy link

FastCGI sent in stderr: "PHP message: PHP Deprecated:  Return type of yii\web\Session::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/yiisoft/yii2/web/Session.php on line 665PHP message: PHP Fatal error:  During inheritance of IteratorAggregate: Uncaught yii\base\ErrorException: Return type of yii\web\Session::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/yiisoft/yii2/web/Session.php:665
Stack trace:
#0 /app/vendor/yiisoft/yii2/web/Session.php(76): yii\base\ErrorHandler->handleError()
#1 /app/vendor/yiisoft/yii2/BaseYii.php(293): include('...')
#2 [internal function]: yii\BaseYii::autoload()
#3 /app/vendor/yiisoft/yii2/di/Container.php(508): ReflectionClass->__construct()
#4 /app/vendor/yiisoft/yii2/di/Container.php(386): yii\di\Container->getDependencies()
#5 /app/vendor/yiisoft/yii2/di/Container.php(171): yii\di\Container->build()
#6 /app/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#7 /app/vendor/yiisoft/yii2/di/ServiceLocator.php(137): yii\BaseYii::createObject()
#8 /app/vendor/yiisoft/yii2/base...PHP message: PHP Fatal error:  During inheritance of IteratorAggregate: Uncaught yii\base\ErrorException: Return type of yii\web\HeaderCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/yiisoft/yii2/web/HeaderCollection.php:37
Stack trace:
#0 /app/vendor/yiisoft/yii2/web/HeaderCollection.php(23): yii\base\ErrorHandler->handleError()
#1 /app/vendor/yiisoft/yii2/BaseYii.php(293): include('...')
#2 /app/vendor/yiisoft/yii2/web/Request.php(362): yii\BaseYii::autoload()
#3 /app/vendor/yiisoft/yii2
Q A
Yii version 2.0.43
PHP version 8.1
Operating system ubuntu 20.04
@samdark samdark added the php8 label Dec 22, 2021
@samdark samdark mentioned this issue Dec 22, 2021
20 tasks
@pamparam83
Copy link
Author

I install yii2 base template and add in file web/index.php error_reporting(E_ALL);
How to fix it?

@samdark
Copy link
Member

samdark commented Dec 25, 2021

By adding #[\ReturnTypeWillChange] annotation.

@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Dec 25, 2021
@pamparam83
Copy link
Author

I added this attribute in web/Seession, web/CookieCollection and base/Model
result
"PHP message: PHP Deprecated: Return type of yii\web\HeaderCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/yiisoft/yii2/web/HeaderCollection.php on line 37PHP message: PHP Stack trace:PHP message: PHP 1. yii\base\ErrorHandler->handleException($exception = class yii\base\ErrorException { protected $message = 'class_exists(): Passing null to parameter #1 ($class) of type string is deprecated'; private string ${Exception}string = ''; protected $code = 8192; protected string $file = '/app/vendor/yiisoft/yii2-debug/src/panels/UserPanel.php'; protected int $line = 91; private array ${Exception}trace = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...], 9 => [...], 10 => [...], 11 => [...], 12 => [...], 13 => [...], 14 => [...], 15 => [...], 16 => [...], 17 => [...], 18 => [...], 19 => [...], 20 => [...], 21 => [...]]; private ?Throwable ${Exception}previous = NULL; protected int $severity = 8192; public $xdebug_message = '<tr><th align=\'left\' bgcolor=\'#f57900\' colspan="5"><span style=\'background-color: #cc0000; color: #fce94f; font-size: x-large;\'>( ! )</span> yii\\base\\ErrorException: class_exists(): Passing null to p...PHP message: PHP 2. yii\web\ErrorHandler->renderException($exception = class yii\base\ErrorException { protected $message = 'class_exists(): Passing null to parameter #1 ($class) of type string is deprecated'; private string ${Exception}string = ''; protected $code = 8192; protected string $file = '/app/vendor/yiisoft/yii2-debug/src/panels/UserPanel.php';

I'm disabled debugger
got errors from web / HeaderCollection.php
added attribute #[\ReturnTypeWillChange]
index page opened,
error on the contact page and login page

PHP Deprecated Warning 'yii \ base \ ErrorException' with message 'htmlspecialchars (): Passing null to parameter # 1 ($ string) of type string is deprecated'

in /app/vendor/yiisoft/yii2/helpers/BaseHtml.php:111 

@samdark
Copy link
Member

samdark commented Dec 27, 2021

Yes, there are many things to check. See #19041 where we work on it. You may help with pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php8 status:ready for adoption Feel free to implement this issue.
Projects
None yet
Development

No branches or pull requests

2 participants