Repository navigation
fix(liquid)!: size, first and last pseudo-properties only with dot notation - #101
Conversation
PHPBench comparison (PHP 8.3)PHP 8.3 | Runner ubuntu24 | Base
|
PHPBench comparison (PHP 8.5)PHP 8.5 | Runner ubuntu24 | Base
|
PHPBench comparison (PHP 8.2)PHP 8.2 | Runner ubuntu24 | Base
|
PHPBench comparison (PHP 8.4)PHP 8.4 | Runner ubuntu24 | Base
|
…h dot notation Like Shopify Liquid, a["size"] is a plain key lookup. Bracket keys named size, first or last are parsed as BracketKey so lookup evaluation can tell them apart from dot notation.
20ef11c to
f789070
Compare
Summary
size,firstandlastresolve as pseudo-properties only with dot notation, like Shopify Liquid.{{ list.size }} → 3 (unchanged) -{{ list["size"] }} → 3 +{{ list["size"] }} → "" (undefined variable in strict mode) {{ hash["size"] }} → hash's "size" key (unchanged) {{ list[key] }} → "" (unchanged: dynamic keys never were pseudo-properties)BracketKeyis exportable, so compiled templates rebuild it asnew BracketKey('size').VariableLookup::toString()writes it back as["size"], soRenderContext::get((string) $lookup)round-trips.Evidence
{{ value["size"] }}|{{ value["first"] }}withvalue = "Hello"→5|HAfter:
|, like Shopify Liquid 5.13. In Shopify'svariable_lookup.rb, command flags are set only for non-bracket lookups.sizekey, dynamic keys and theRenderContext::get()round-trip. Parsed, compiled and strict variants all run. 3,818 tests pass.a = {size: "original"}andset('a.size', 'override'),a["size"]→original, whilea.size→override.After: both →
override. Covered bydotted keys override bracket pseudo-property keys.{{ v["size"] }}|{{ v.size }}|{{ h["size"] }}as|2|9.laravel-cmsuses["size"],["first"]or["last"].main(measured before the rebase on fix(context)!: path overrides instead of outer-scope lookup fallback #100): about −1% on ThemeBench render and stream; OperationBench ranges from −1.3% to 0%.Merge Danger
Door: two-way
Blast Radius: templates
Templates using
a["size"],a["first"]ora["last"]on arrays or strings now get an empty value instead of the pseudo-property. Replace them with dot notation. The README entry documenting the old difference is removed.Rebased on
mainafter #100: the changelog conflict is resolved andfindPathOverride()treats aBracketKeylookup as its plain value.