When I’m working on ZendCodingStandard I was thinking about adding sniff which discourage
goto language construct.
Recently someone suggested to create this sniff in PHP_CodeSniffer:
and there is already the PR with that sniff:
I’ve checked where in zendframework org we are using
goto instruction and I have found it only in
zend-code (really old part of the library - scanners - and as I remember correctly, it is going to be removed with v4), and also in
(it could be easily eliminated there).
(I can see it also in ZF1 and some old libraries like ZendMarkup…)
I cannot see any valid example where
goto is better than refactor and split code into smaller functions which do simpler actions. IMHO we should then discourage of using
@mwop is against adding that rule, please see comments:
@mwop can you please provide some examples, where
goto is going to be better than code refactor and smaller functions?
What do you think, guys? Should we disallow using
goto or not?