On Apr 8, 2013, at 16:36 , Daniel Leech <dan...@dantleech.com> wrote:
> On Mon, Apr 08, 2013 at 01:41:55PM +0200, Fabien Potencier wrote: >> On 4/8/13 12:45 PM, Daniel Leech wrote: >>> On Mon, Apr 08, 2013 at 07:25:19AM +0200, Fabien Potencier wrote: >>>> On 4/6/13 12:16 PM, Daniel Leech wrote: >>>>> Hi all, >>>>> >>>>> Following a little discussion on a PR in the CMF, I notice that there >>>>> doesn't seem to be a coding standard for formatting exception message >>>>> strings. >>>>> >>>>> Within Symfony the majority of messages are formatted with sprintf, >>>>> whilst some are inline, e.g. >>>>> >>>>> sprintf >>>>> >>>>> throw new AclAlreadyExistsException(sprintf('%s is already associated >>>>> with an ACL.', $oid)); >>>>> >>>>> inline >>>>> >>>>> throw new \RuntimeException('Execution failed with return code: >>>>> '.$code.'.'); >>>>> >>>>> So, my question is: Should the coding standard be changed to say that >>>>> exception messages should be formatted with sprintf? >>>> >>>> Yes, using sprintf is what the coding standard should document. Can >>>> you submit a PR on the docs? And perhaps a PR on symfony/symfony to >>>> fix inlined exceptions? >>>> >>>> Thanks, >>>> Fabien >>> >>> Should apply to all string concatenations and not just exception >>> messages? >> >> I think it depends. Let's just do that for exceptions for now. >> > > Hmm.. I've created the PR for the docs, but there are at least 65 instances of > non-sprintf concatenating exceptions. > > grep -Rn 'throw ' | grep -v sprintf | grep "'\." | wc -l > > I can have a go at a small script to do the fixing, but it carries quite > a high risk factor if all the Exceptions are not unit tested. that is still a small enough number that it can be manually verified. regards, Lukas Kahwe Smith sm...@pooteeweet.org -- -- If you want to report a vulnerability issue on Symfony, please read the procedure on http://symfony.com/security You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to symfony-devs@googlegroups.com To unsubscribe from this group, send email to symfony-devs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en --- You received this message because you are subscribed to the Google Groups "Symfony developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to symfony-devs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.