lightncandy icon indicating copy to clipboard operation
lightncandy copied to clipboard

length with @root is causing parse error

Open Dahkon opened this issue 11 months ago • 0 comments

To reproduce the problem juste use this line of code : {{@root.datas.length}}

datas.length is working good but when you use @root in front is causing a Synthax Error in the generated php file.

As a workaround, I found in Compiler.php file in line 313 to replace code :

        if (!$spvar) {
            if (($levels === 0) && $p) {
                $checks[] = "isset($base$p)";
            }
            $checks[] = ("$base$p" == '$in') ? '$inary' : "is_array($base$p)";
        }

with the following :

        if ($spvar) {
            if ($p) {
                $checks[] = "isset($base$p)";
            }
        } else {
            if (($levels === 0) && $p) {
                $checks[] = "isset($base$p)";
            }
            $checks[] = ("$base$p" == '$in') ? '$inary' : "is_array($base$p)";
        }

Seems ok for me.

But I don't know any resulting bugs of this code.

Thanks,

Dahkon avatar Mar 13 '24 15:03 Dahkon