Req #72548 [Csd->Wfx]: Limit for number of lines in foreach loop

From: Date: Tue, 05 Jul 2016 15:03:56 +0000
Subject: Req #72548 [Csd->Wfx]: Limit for number of lines in foreach loop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202076@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72548&edit=1 ID: 72548 Updated by: nikic@php.net Reported by: nanovim at gmail dot com Summary: Limit for number of lines in foreach loop -Status: Closed +Status: Wont fix Type: Feature/Change Request Package: *General Issues Operating System: Any PHP Version: Irrelevant Assigned To: gooh Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2016-07-05 14:51:47] gooh@php.net Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Consider using a static analyzer (PHP_CodeSniffer, PHPMD or PDepend, …) and implement one or more rules that would warn about such things instead. This is nothing that needs to be addressed at the interpreter/compiler level. ------------------------------------------------------------------------ [2016-07-05 14:12:37] nanovim at gmail dot com Description: ------------ I would suggest that the php interpreter/compiler would have an option to set a maximal number of lines for a foreach loop. We PHP Programmers love the foreach loops and they are quite usefully, but it seems this love seems often unconditional and often projects have foreach loops with hundred lines of code. This foreach loops might even complex if/then/else constructs, which may have itself foreach loops. I think we should give the project maintainer an option to limit the number of lines of code of the foreach loops of a project. Let's say an option in the php.ini like: foreach-limit: -1 which can be set to any Integer and -1 indicating no limit at all. Test script: --------------- foreach($arrray as $line)[ //200 lines and a limit of 50 } Expected result: ---------------- Parser error: limit of lines succeeded Actual result: -------------- it compiles ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72548&edit=1

« previous php.bugs (#202076) next »