Home Download Buy Blog Forum Support

Code Folding and PHP HEREDOC

Code Folding and PHP HEREDOC

Postby WetCoast on Sat Dec 15, 2012 1:42 am

I use a lot of HEREDOC statements in my PHP and noticed that this seems to severely get in the way of code folding in Sublime. E.g. try folding the example function, or the "then" portion of the if statement in this code to see what I mean:
Code: Select all
<?php
function example($a)
{
    if (1)
    {
        echo $a;
        $str = <<<HEREDOC
    line1
    line2
HEREDOC;
        echo $a;
    }
    else
    {
        echo $a;
        echo $a;
    }
}


In reading this recent post (http://www.sublimetext.com/forum/viewtopic.php?p=39663#p39663), it sounds like the folding logic is based on indent levels, which certainly doesn't work with PHP's HEREDOC requirement of having the ending marker in column 1. See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc.

Are there any workarounds in Sublime for this? Am I doing something wrong here?
WetCoast
 
Posts: 1
Joined: Sat Dec 15, 2012 1:26 am

Re: Code Folding and PHP HEREDOC

Postby bkdotcom on Fri Dec 13, 2013 6:30 am

I googled "sublime folding heredoc" and found this "thread"
seems like if there's a matching bracket, it should fold based on the matching bracket.
bkdotcom
 
Posts: 4
Joined: Fri Dec 13, 2013 6:26 am

Re: Code Folding and PHP HEREDOC

Postby Unopoo on Thu Jun 18, 2015 9:04 am

I'm troubled with the same problem, not only heredoc, even if I bad comment like this:
Code: Select all
function() doNothing($forever) {
    usleep($forever);
// bad comment
}

will break the code folding. I think this is too stupid.

searched a little and found one package called syntaxfold seems to fix this, but tried with no luck

if you found the solution, plz let me know.
Unopoo
 
Posts: 12
Joined: Wed Jun 04, 2014 4:10 pm


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests