[php-src] Issue #8074: Value inside foreach is empty when doing maths with it (only with php-cgi and opcache activated)

From: Date: Thu, 10 Feb 2022 16:10:40 +0000
Subject: [php-src] Issue #8074: Value inside foreach is empty when doing maths with it (only with php-cgi and opcache activated)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239611@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8074 Author: MGlaus ### Description I got a strange one :) There is an inconsistency between php-cgi and php-cli if following conditions are meet. - Generate an array with range() where one argument is a string - Use this array in a foreach-Loop inside a function - Do maths with the value of an array entry inside the foreach-Loop - Extension opcache installed and enabled If the code is run with php-cgi, the value is empty in the math expression. The cli version seems to work as intended. The following code: ```php <?php function test() { $array = range(1,"2"); foreach ($array as $i) { var_dump($i + 1); } } test(); ``` Resulted in this output (only for php-cgi): ``` float(1) float(1) ``` But I expected this output instead: ``` int(2) int(3) ``` ### PHP Version PHP 8.0.15, PHP 8.1.2 ### Operating System _No response_

« previous php.bugs (#239611) next »