Below the code which works as expected before I try to use key while iteration. As I do it, I see an error: "Allowed memory size of 1073741824 bytes exhausted (tried to allocate 9223372043239833600 bytes)". See at the required memory size, it looks monstrous.
The getModules returns an associative array, $id is a string.
Any idea about possible reasons?
foreach (Yii::$app->getModules() as $id => $module) { echo '<pre>'; var_dump(gettype($module)); if (gettype($module) =='array') { var_dump($module); } else if (gettype($module) =='object') { var_dump(get_class($module)); } //var_dump($id); // <-- We have problems when try to uncomment this echo '</pre>'; } php -v:
PHP 7.0.33-25+0~20200225.32+debian9~1.gbpa11893 (cli) (built: Feb 25 2020 13:16:41) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.33-25+0~20200225.32+debian9~1.gbpa11893, Copyright (c) 1999-2017, by Zend Technologies UPDATED: I just opened and saved the modules array via ssh and the bug disappears. I have no guess what it was. Looks like an SSD glitch.