|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-28 16:50 UTC] peehaa@php.net
-Status: Open
+Status: Feedback
[2018-02-28 16:50 UTC] peehaa@php.net
[2018-02-28 16:54 UTC] peehaa@php.net
[2018-02-28 17:14 UTC] mark dot scherer at gmx dot de
[2018-02-28 17:19 UTC] mark dot scherer at gmx dot de
[2018-02-28 22:01 UTC] nikic@php.net
[2018-03-01 13:50 UTC] mark dot scherer at gmx dot de
[2018-06-24 04:25 UTC] php-bugs at lists dot php dot net
[2018-06-24 09:25 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 01:00:02 2025 UTC |
Description: ------------ The recent changes in 7.2 must have introduced a major regression in foreach() looping and variable assignment. Test script: --------------- // BROKEN NOW IN PHP7.2 foreach ($productAttributeKeys as $type) { $isDefined = $this->attributeTransferCollection->has($type); $shouldBeTextArea = mb_strlen($value) > 255; if ($isDefined) { continue; } if ($shouldBeTextArea) { $inputType = self::TEXT_AREA_INPUT_TYPE; } ... } // FIXED WITH: Moving continue statement up foreach ($productAttributeKeys as $type) { $isDefined = $this->attributeTransferCollection->has($type); if ($isDefined) { continue; } $shouldBeTextArea = (mb_strlen($value) > 255); if ($shouldBeTextArea === true) { $inputType = self::TEXT_AREA_INPUT_TYPE; } ... } Expected result: ---------------- No notice/error on the most basic $shouldBeTextArea = mb_strlen($value) > 255; if ($isDefined) { continue; } if ($shouldBeTextArea) { $inputType = self::TEXT_AREA_INPUT_TYPE; } Actual result: -------------- When using continue, variables that must be assigned and fine are suddenly now throwing "Undefined variable: shouldBeTextArea" - this worked in all PHP versions until 7.1 incl.