From 8255fc2f47cfca560051c00b4ff959d079d6d596 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Fri, 15 Aug 2014 17:54:43 +0100 Subject: [PATCH 01/25] Add test case checking for issue reported in schmittjoh/twig.js#85 --- .../Fixture/integration/tests/getterbug.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test new file mode 100644 index 0000000..dd3107e --- /dev/null +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -0,0 +1,16 @@ +--TEST-- +Getter bug from schmittjoh/twig.js#85 +--TEMPLATE-- +{{ user.getName }} +{{ user.name }} +--DATA-- +{ + user: { + getName: function() { + return "John Doe" + } + } +} +--EXPECT-- +John Doe +John Doe From 691dd43082f92aa3ff8b5afa426c936040777a3f Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sat, 16 Aug 2014 14:33:00 +0100 Subject: [PATCH 02/25] Extend dnode test suite to allow arbitrary JS I need this capability to test the Object.defineProperty getters described in schmittjoh/twig.js#85 --- tests-js/dnode.js | 3 ++- tests/TwigJs/Tests/Fixture/integration/expressions/array.test | 2 +- .../Tests/Fixture/integration/expressions/array_call.test | 2 +- .../TwigJs/Tests/Fixture/integration/expressions/bitwise.test | 2 +- .../Tests/Fixture/integration/expressions/comparison.test | 2 +- .../TwigJs/Tests/Fixture/integration/expressions/grouping.test | 2 +- .../TwigJs/Tests/Fixture/integration/expressions/literals.test | 2 +- .../integration/expressions/operators_as_variables.test | 2 +- .../TwigJs/Tests/Fixture/integration/expressions/strings.test | 2 +- .../Fixture/integration/expressions/ternary_operator.test | 2 +- .../integration/expressions/ternary_operator_noelse.test | 2 +- .../integration/expressions/ternary_operator_nothen.test | 2 +- tests/TwigJs/Tests/Fixture/integration/expressions/unary.test | 2 +- .../Fixture/integration/expressions/unary_precedence.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/abs.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/batch.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/first.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/join.test | 2 +- .../TwigJs/Tests/Fixture/integration/filters/json_encode.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/last.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/length.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/merge.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/nl2br.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/title.test | 2 +- tests/TwigJs/Tests/Fixture/integration/filters/trim.test | 2 +- .../Tests/Fixture/integration/functions/include/basic.test | 2 +- .../Tests/Fixture/integration/functions/include/only.test | 2 +- tests/TwigJs/Tests/Fixture/integration/functions/max.test | 2 +- tests/TwigJs/Tests/Fixture/integration/functions/min.test | 2 +- tests/TwigJs/Tests/Fixture/integration/functions/random.test | 2 +- tests/TwigJs/Tests/Fixture/integration/functions/range.test | 2 +- tests/TwigJs/Tests/Fixture/integration/reverse.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/array.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/counter.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/even.test | 2 +- .../Tests/Fixture/integration/tests/forloopscopebug.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/hello_foo.test | 2 +- .../TwigJs/Tests/Fixture/integration/tests/hello_johannes.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/hello_world.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/in.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/macro.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/macrobug.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/method_call.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/odd.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/scope.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/welcome.test | 2 +- tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax.test | 2 +- .../Tests/Fixture/integration/tests/welcome_ajax_noname.test | 2 +- 49 files changed, 50 insertions(+), 49 deletions(-) diff --git a/tests-js/dnode.js b/tests-js/dnode.js index efe75e1..a88c9e4 100644 --- a/tests-js/dnode.js +++ b/tests-js/dnode.js @@ -6,7 +6,8 @@ eval(twigSource); var server = dnode(function (remote, conn) { this.render = function (name, source, parameters, cb) { eval(source); - cb(window.Twig.render(eval(name), eval("(" + parameters + ")"))); + parameters = eval("(function (){" + parameters + "}());"); + cb(window.Twig.render(eval(name), parameters)); }; this.exit = function (cb) { cb(); diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/array.test b/tests/TwigJs/Tests/Fixture/integration/expressions/array.test index ce731b6..3eefe25 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/array.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/array.test @@ -38,7 +38,7 @@ Twig supports array notation {{ ary|keys|join(',') }} {{ ary|join(',') }} --DATA-- -{ bar: "bar", foo: { bar: "bar" } } +return { bar: "bar", foo: { bar: "bar" } } --EXPECT-- 1,2 foo,bar diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/array_call.test b/tests/TwigJs/Tests/Fixture/integration/expressions/array_call.test index 439a29f..3637d28 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/array_call.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/array_call.test @@ -6,7 +6,7 @@ Twig supports method calls {{ items[foo] }} {{ items[items[foo]] }} --DATA-- -{ foo: "bar", items: { foo: "bar", bar: "foo" } } +return { foo: "bar", items: { foo: "bar", bar: "foo" } } --EXPECT-- bar bar diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/bitwise.test b/tests/TwigJs/Tests/Fixture/integration/expressions/bitwise.test index 5c32f3b..888e4d5 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/bitwise.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/bitwise.test @@ -6,7 +6,7 @@ Twig supports bitwise operations {{ 1 b-xor 5 }} {{ (1 and 0 b-or 0) is sameas(1 and (0 b-or 0)) ? 'ok' : 'ko' }} --DATA-- -{} +return {} --EXPECT-- 1 5 diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/comparison.test b/tests/TwigJs/Tests/Fixture/integration/expressions/comparison.test index c0fd79a..61c0a60 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/comparison.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/comparison.test @@ -6,7 +6,7 @@ Twig supports comparison operators (==, !=, <, >, >=, <=) {{ 1 == 1 }}/{{ 1 == 2 }} {{ 1 != 1 }}/{{ 1 != 2 }} --DATA-- -{} +return {} --EXPECT-- false/false/false/true true/false/true/true diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/grouping.test b/tests/TwigJs/Tests/Fixture/integration/expressions/grouping.test index db1d5c2..22b1fe8 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/grouping.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/grouping.test @@ -3,6 +3,6 @@ Twig supports grouping of expressions --TEMPLATE-- {{ (2 + 2) / 2 }} --DATA-- -{} +return {} --EXPECT-- 2 diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/literals.test b/tests/TwigJs/Tests/Fixture/integration/expressions/literals.test index 50f42af..124ee8c 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/literals.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/literals.test @@ -10,7 +10,7 @@ Twig supports literals 7 {{ null }} 8 {{ NULL }} --DATA-- -{} +return {} --EXPECT-- 1 true 2 true diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/operators_as_variables.test b/tests/TwigJs/Tests/Fixture/integration/expressions/operators_as_variables.test index 60fe4d9..1e25837 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/operators_as_variables.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/operators_as_variables.test @@ -7,7 +7,7 @@ Twig allows to use named operators as variable names {{ in }} {{ is }} --DATA-- -{ matches: [1, 2, 3], in: "in", is: "is" } +return { matches: [1, 2, 3], in: "in", is: "is" } --EXPECT-- 1 2 diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/strings.test b/tests/TwigJs/Tests/Fixture/integration/expressions/strings.test index 02ea4fb..47c5a78 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/strings.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/strings.test @@ -4,7 +4,7 @@ Twig supports string interpolation {{ "foo #{"foo #{bar} baz"} baz" }} {{ "foo #{bar}#{bar} baz" }} --DATA-- -{ bar: "BAR" } +return { bar: "BAR" } --EXPECT-- foo foo BAR baz baz foo BARBAR baz diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator.test b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator.test index 8d7b447..b717c7a 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator.test @@ -8,7 +8,7 @@ Twig supports the ternary operator {{ 1 == 1 ? 'foo
':'' }} {{ foo ~ (bar ? ('-' ~ bar) : '') }} --DATA-- -{ foo: "foo", bar: "bar" } +return { foo: "foo", bar: "bar" } --EXPECT-- YES NO diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_noelse.test b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_noelse.test index 0421724..7211d93 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_noelse.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_noelse.test @@ -4,7 +4,7 @@ Twig supports the ternary operator {{ 1 ? 'YES' }} {{ 0 ? 'YES' }} --DATA-- -{} +return {} --EXPECT-- YES diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_nothen.test b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_nothen.test index e339641..5578cac 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_nothen.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/ternary_operator_nothen.test @@ -4,7 +4,7 @@ Twig supports the ternary operator {{ 'YES' ?: 'NO' }} {{ 0 ?: 'NO' }} --DATA-- -{} +return {} --EXPECT-- YES NO diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/unary.test b/tests/TwigJs/Tests/Fixture/integration/expressions/unary.test index 1c73800..5bbd961 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/unary.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/unary.test @@ -5,7 +5,7 @@ Twig supports unary operators (not, -, +) {{ +1 + 1 }}/{{ -1 - 1 }} {{ not (false or true) }} --DATA-- -{} +return {} --EXPECT-- false/true 2/-2 diff --git a/tests/TwigJs/Tests/Fixture/integration/expressions/unary_precedence.test b/tests/TwigJs/Tests/Fixture/integration/expressions/unary_precedence.test index 4416552..a5b08a3 100644 --- a/tests/TwigJs/Tests/Fixture/integration/expressions/unary_precedence.test +++ b/tests/TwigJs/Tests/Fixture/integration/expressions/unary_precedence.test @@ -6,7 +6,7 @@ Twig unary operators precedence {{ -1 * -1 }} {{ 4 / -1 * 5 }} --DATA-- -{} +return {} --EXPECT-- -2 0 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/abs.test b/tests/TwigJs/Tests/Fixture/integration/filters/abs.test index 46d9e0f..ee6da58 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/abs.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/abs.test @@ -4,6 +4,6 @@ {% set number = -5 %} {{ number | abs }} --DATA-- -{} +return {} --EXPECT-- 5 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/batch.test b/tests/TwigJs/Tests/Fixture/integration/filters/batch.test index 3bedfdd..29558a3 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/batch.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/batch.test @@ -11,7 +11,7 @@ {% endfor %} --DATA-- -{} +return {} --EXPECT-- diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/first.test b/tests/TwigJs/Tests/Fixture/integration/filters/first.test index e93334b..0e56b9c 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/first.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/first.test @@ -7,7 +7,7 @@ {{ arr|first }} {{ 'Ä€é'|first }} --DATA-- -{ arr: [1, 2, 3, 4] } +return { arr: [1, 2, 3, 4] } --EXPECT-- 1 1 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/join.test b/tests/TwigJs/Tests/Fixture/integration/filters/join.test index c0554eb..cd12be2 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/join.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/join.test @@ -5,7 +5,7 @@ {{ foo|join(', ') }} {{ bar|join(', ') }} --DATA-- -{ foo: [1, 2], bar: [3, 4] } +return { foo: [1, 2], bar: [3, 4] } --EXPECT-- foo, bar 1, 2 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/json_encode.test b/tests/TwigJs/Tests/Fixture/integration/filters/json_encode.test index 74749dd..a3d487f 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/json_encode.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/json_encode.test @@ -3,6 +3,6 @@ --TEMPLATE-- {{ [1, 2, 3] | json_encode }} --DATA-- -{} +return {} --EXPECT-- [1,2,3] diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/last.test b/tests/TwigJs/Tests/Fixture/integration/filters/last.test index afba917..a876989 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/last.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/last.test @@ -5,7 +5,7 @@ {{ { a:1, b:2, c:3 } | last }} {{ "1234" | last }} --DATA-- -{} +return {} --EXPECT-- 3 3 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/length.test b/tests/TwigJs/Tests/Fixture/integration/filters/length.test index cdd50f7..4e06af1 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/length.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/length.test @@ -5,7 +5,7 @@ {{ string|length }} {{ number|length }} --DATA-- -{ array: [1, 4], string: "foo", number: 1000 } +return { array: [1, 4], string: "foo", number: 1000 } --EXPECT-- 2 3 diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/merge.test b/tests/TwigJs/Tests/Fixture/integration/filters/merge.test index a63b955..bd7e313 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/merge.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/merge.test @@ -13,7 +13,7 @@ {{ merged | json_encode | raw }} --DATA-- -{} +return {} --EXPECT-- [1,2] [1,2,"apple","orange"] diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/nl2br.test b/tests/TwigJs/Tests/Fixture/integration/filters/nl2br.test index 6fac7f7..634a536 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/nl2br.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/nl2br.test @@ -4,7 +4,7 @@ {{ "I like Twig.\nYou will like it too.\n\nEverybody like it!"|nl2br }} {{ text|nl2br }} --DATA-- -{ text: "If you have some HTML\nit will be escaped." } +return { text: "If you have some HTML\nit will be escaped." } --EXPECT-- I like Twig.
You will like it too.

Everybody like it! If you have some <strong>HTML</strong>
it will be escaped. diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/title.test b/tests/TwigJs/Tests/Fixture/integration/filters/title.test index 170cfbe..c341a48 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/title.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/title.test @@ -5,7 +5,7 @@ d {{ "HELLO world" | title }} d --DATA-- -{} +return {} --EXPECT-- d Hello World diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/trim.test b/tests/TwigJs/Tests/Fixture/integration/filters/trim.test index 425fe65..d775033 100644 --- a/tests/TwigJs/Tests/Fixture/integration/filters/trim.test +++ b/tests/TwigJs/Tests/Fixture/integration/filters/trim.test @@ -4,7 +4,7 @@ {{ "hello " | trim }} world {{ "testing!!!!!" | trim("!") }} --DATA-- -{} +return {} --EXPECT-- hello world testing diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/include/basic.test b/tests/TwigJs/Tests/Fixture/integration/functions/include/basic.test index 0ef229c..b85586d 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/include/basic.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/include/basic.test @@ -8,7 +8,7 @@ BAR --TEMPLATE(foo.twig)-- FOOBAR --DATA-- -{} +return {} --EXPECT-- FOO diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/include/only.test b/tests/TwigJs/Tests/Fixture/integration/functions/include/only.test index 603f706..a40ed96 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/include/only.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/include/only.test @@ -6,6 +6,6 @@ --TEMPLATE(multiply.twig)-- {{ number * multiplier }} --DATA-- -{} +return {} --EXPECT-- 0 diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/max.test b/tests/TwigJs/Tests/Fixture/integration/functions/max.test index 5a5aa30..f7767fe 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/max.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/max.test @@ -5,7 +5,7 @@ {{ max([1, 2, 3]) }} {{ max({ a:1, b:2, c:3 }) }} --DATA-- -{} +return {} --EXPECT-- 3 3 diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/min.test b/tests/TwigJs/Tests/Fixture/integration/functions/min.test index 6c5956a..4781eeb 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/min.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/min.test @@ -5,7 +5,7 @@ {{ min([1, 2, 3]) }} {{ min({ a:1, b:2, c:3 }) }} --DATA-- -{} +return {} --EXPECT-- 1 1 diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/random.test b/tests/TwigJs/Tests/Fixture/integration/functions/random.test index 8841b21..6842682 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/random.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/random.test @@ -3,6 +3,6 @@ --TEMPLATE-- {{ random("A") }} --DATA-- -{} +return {} --EXPECT-- A diff --git a/tests/TwigJs/Tests/Fixture/integration/functions/range.test b/tests/TwigJs/Tests/Fixture/integration/functions/range.test index fdba7da..bbb0f2b 100644 --- a/tests/TwigJs/Tests/Fixture/integration/functions/range.test +++ b/tests/TwigJs/Tests/Fixture/integration/functions/range.test @@ -3,6 +3,6 @@ --TEMPLATE-- {{ range(low=0+1, high=10+0)|join(',') }} --DATA-- -{} +return {} --EXPECT-- 1,2,3,4,5,6,7,8,9,10 diff --git a/tests/TwigJs/Tests/Fixture/integration/reverse.test b/tests/TwigJs/Tests/Fixture/integration/reverse.test index 8241a97..1c4b7c4 100644 --- a/tests/TwigJs/Tests/Fixture/integration/reverse.test +++ b/tests/TwigJs/Tests/Fixture/integration/reverse.test @@ -11,7 +11,7 @@ {{ "abcdef" | reverse }} --DATA-- -{} +return {} --EXPECT-- 3 2 diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/array.test b/tests/TwigJs/Tests/Fixture/integration/tests/array.test index 0c16175..dfe5151 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/array.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/array.test @@ -5,7 +5,7 @@ array index test {{ key }} {% endfor %} --DATA-- -{ days: { +return { days: { 1 : { money : 9 }, 2 : { money : 21 }, 3 : { money : 38 }, diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/counter.test b/tests/TwigJs/Tests/Fixture/integration/tests/counter.test index 844219f..f752a36 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/counter.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/counter.test @@ -12,6 +12,6 @@ {% endfor %} --DATA-- -{} +return {} --EXPECT-- 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/even.test b/tests/TwigJs/Tests/Fixture/integration/tests/even.test index e8af344..752ba26 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/even.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/even.test @@ -6,7 +6,7 @@ {{ 1 is not even ? 'ok' : 'ko' }} {{ 2 is not even ? 'ko' : 'ok' }} --DATA-- -{} +return {} --EXPECT-- ok ok diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/forloopscopebug.test b/tests/TwigJs/Tests/Fixture/integration/tests/forloopscopebug.test index 831f7e8..94ebb9b 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/forloopscopebug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/forloopscopebug.test @@ -10,6 +10,6 @@ for loop scope bug regression test for schmittjoh/twig.js#64 {% endfor %} {{ minimum }} --DATA-- -{} +return {} --EXPECT-- 1 diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index dd3107e..92de440 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -4,7 +4,7 @@ Getter bug from schmittjoh/twig.js#85 {{ user.getName }} {{ user.name }} --DATA-- -{ +return { user: { getName: function() { return "John Doe" diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/hello_foo.test b/tests/TwigJs/Tests/Fixture/integration/tests/hello_foo.test index ff624b5..ba674ab 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/hello_foo.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/hello_foo.test @@ -3,6 +3,6 @@ Hello Foo test --TEMPLATE-- Hello {{ name|default("World") }}! --DATA-- -{ name: "Example diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/macrobug.test b/tests/TwigJs/Tests/Fixture/integration/tests/macrobug.test index c562cb7..83cd865 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/macrobug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/macrobug.test @@ -6,6 +6,6 @@ The value is {{ value }} {% endmacro %} {{ _self.show("Hello World!") }} --DATA-- -{} +return {} --EXPECT-- The value is Hello World! diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/method_call.test b/tests/TwigJs/Tests/Fixture/integration/tests/method_call.test index feac843..2ea3747 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/method_call.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/method_call.test @@ -6,7 +6,7 @@ Method call test for schmittjoh/twig.js#83 {{ object.get("attr") }} --DATA-- -{ +return { object: { getFoo: function() { return "foo"; diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/odd.test b/tests/TwigJs/Tests/Fixture/integration/tests/odd.test index 3f069a1..fef25ce 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/odd.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/odd.test @@ -4,7 +4,7 @@ {{ 1 is odd ? 'ok' : 'ko' }} {{ 2 is odd ? 'ko' : 'ok' }} --DATA-- -{} +return {} --EXPECT-- ok ok diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/scope.test b/tests/TwigJs/Tests/Fixture/integration/tests/scope.test index f48f677..97ab607 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/scope.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/scope.test @@ -3,6 +3,6 @@ scope test --TEMPLATE-- {% set example = 12345 %}{% if false %}{{ example }}{% endif %}{{ example }} --DATA-- -{} +return {} --EXPECT-- 12345 diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/welcome.test b/tests/TwigJs/Tests/Fixture/integration/tests/welcome.test index c4b4bcf..3ff1e20 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/welcome.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/welcome.test @@ -50,7 +50,7 @@ Welcome test --TEMPLATE(traitable.twig)-- {% block title %}foo{% endblock %} --DATA-- -{ name: "Johannes" } +return { name: "Johannes" } --EXPECT-- diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax.test b/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax.test index e3edff2..1ff9744 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax.test @@ -50,7 +50,7 @@ Welcome AJAX test --TEMPLATE(traitable.twig)-- {% block title %}foo{% endblock %} --DATA-- -{ name: "Johannes", ajax: true } +return { name: "Johannes", ajax: true } --EXPECT--

Welcome Johannes!

diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax_noname.test b/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax_noname.test index 4877724..259a780 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax_noname.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/welcome_ajax_noname.test @@ -50,7 +50,7 @@ Welcome AJAX noname test --TEMPLATE(traitable.twig)-- {% block title %}foo{% endblock %} --DATA-- -{ ajax: true } +return { ajax: true } --EXPECT--

Welcome World!

From 46f671f233643a6c9fb9dff9cfaa0f3168e5be2e Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sat, 16 Aug 2014 14:36:23 +0100 Subject: [PATCH 03/25] Add test for Object.defineProperty getter described in schmittjoh/twig.js#85 This seems to be working, so that only leaves the other type of getter to test. --- .../Fixture/integration/tests/getterbug.test | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index 92de440..35793e8 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -3,14 +3,18 @@ Getter bug from schmittjoh/twig.js#85 --TEMPLATE-- {{ user.getName }} {{ user.name }} +{{ user.age }} --DATA-- -return { - user: { - getName: function() { - return "John Doe" - } - } -} +var user = { + getName: function() { + return "John Doe" + }, +}; +Object.defineProperty(user, 'age', { + get: function() { return 21; } +}); +return { user: user }; --EXPECT-- John Doe John Doe +21 From 547a4f4ee39789f4084c7aa8c7f457d57e359d6a Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sat, 16 Aug 2014 14:38:58 +0100 Subject: [PATCH 04/25] Add test case for other type of getter mentioned in schmittjoh/twig.js#85 --- .../Tests/Fixture/integration/tests/getterbug.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index 35793e8..32b9214 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -4,11 +4,19 @@ Getter bug from schmittjoh/twig.js#85 {{ user.getName }} {{ user.name }} {{ user.age }} +{{ user.address }} --DATA-- var user = { + _address: "123 Test Road", getName: function() { return "John Doe" }, + get address () { + return this._address; + }, + set address (address) { + this._address = address; + } }; Object.defineProperty(user, 'age', { get: function() { return 21; } @@ -18,3 +26,4 @@ return { user: user }; John Doe John Doe 21 +123 Test Road From 11e8497bea8e3781d0f62e5ca38fd9045c9c3de3 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 17 Aug 2014 13:25:05 +0100 Subject: [PATCH 05/25] Add "is defined" checks to test for issue reported in schmittjoh/twig.js#85 --- tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index 32b9214..e175c37 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -1,10 +1,13 @@ --TEST-- Getter bug from schmittjoh/twig.js#85 --TEMPLATE-- -{{ user.getName }} {{ user.name }} +{% if user.age is defined %} {{ user.age }} +{% endif %} +{% if user.address is defined %} {{ user.address }} +{% endif %} --DATA-- var user = { _address: "123 Test Road", @@ -24,6 +27,5 @@ Object.defineProperty(user, 'age', { return { user: user }; --EXPECT-- John Doe -John Doe 21 123 Test Road From 2b1e158e81e92f0418d2c9e5d13f7883dc7cab65 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 17 Aug 2014 13:29:04 +0100 Subject: [PATCH 06/25] Add more tests checking for the issue from schmittjoh/twig.js#85 --- .../TwigJs/Tests/Fixture/integration/tests/getterbug.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index e175c37..d036a59 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -1,13 +1,18 @@ --TEST-- Getter bug from schmittjoh/twig.js#85 --TEMPLATE-- +{% if user.name is defined %} {{ user.name }} +{% endif %} {% if user.age is defined %} {{ user.age }} {% endif %} {% if user.address is defined %} {{ user.address }} {% endif %} +{{ user.name | default("Not defined") }} +{{ user.age | default("Not defined") }} +{{ user.address | default("Not defined") }} --DATA-- var user = { _address: "123 Test Road", @@ -29,3 +34,6 @@ return { user: user }; John Doe 21 123 Test Road +John Doe +21 +123 Test Road From 4a489d14451ed7f796aa908b550b4eca7973191c Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 17 Aug 2014 13:33:16 +0100 Subject: [PATCH 07/25] Tidy up getterbug test for readability's sake --- .../Tests/Fixture/integration/tests/getterbug.test | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test index d036a59..84d1d94 100644 --- a/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test +++ b/tests/TwigJs/Tests/Fixture/integration/tests/getterbug.test @@ -1,15 +1,9 @@ --TEST-- Getter bug from schmittjoh/twig.js#85 --TEMPLATE-- -{% if user.name is defined %} -{{ user.name }} -{% endif %} -{% if user.age is defined %} -{{ user.age }} -{% endif %} -{% if user.address is defined %} -{{ user.address }} -{% endif %} +{% if user.name is defined %}{{ user.name }}{% endif %}{{ "" }} +{% if user.age is defined %}{{ user.age }}{% endif %}{{ "" }} +{% if user.address is defined %}{{ user.address }}{% endif %}{{ "" }} {{ user.name | default("Not defined") }} {{ user.age | default("Not defined") }} {{ user.address | default("Not defined") }} From a99908e1a419d47e047eeca04b928282a1eedc29 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 24 Aug 2014 12:23:57 +0100 Subject: [PATCH 08/25] Confirm support for the raw filter --- README.md | 2 +- .../TwigJs/Tests/Fixture/integration/filters/raw.test | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/TwigJs/Tests/Fixture/integration/filters/raw.test diff --git a/README.md b/README.md index 0a3fd6a..523084b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ and functions described below. * `lower` * `merge` * `nl2br` +* `raw` * `replace` * `reverse` * `title` @@ -63,7 +64,6 @@ anybody hoping to make a contribution to the project. * `date_modify` * `format` * `number_format` -* `raw` * `round` * `slice` * `sort` diff --git a/tests/TwigJs/Tests/Fixture/integration/filters/raw.test b/tests/TwigJs/Tests/Fixture/integration/filters/raw.test new file mode 100644 index 0000000..3cd4217 --- /dev/null +++ b/tests/TwigJs/Tests/Fixture/integration/filters/raw.test @@ -0,0 +1,10 @@ +--TEST-- +"raw" filter +--TEMPLATE-- +{{ html }} +{{ html | raw }} +--DATA-- +return { html: "

test

" } +--EXPECT-- +<h1>test</h1> +

test

From e26fa78daef273a0d6c1d662bad638fac76fad72 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 24 Aug 2014 12:29:15 +0100 Subject: [PATCH 09/25] Add PR context link to mention of date filter in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 523084b..31a58f3 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ anybody hoping to make a contribution to the project. * `attribute` * `constant` * `cycle` -* `date` +* `date` (See [pull request #11]) * `dump` * `parent` * `source` @@ -103,3 +103,4 @@ Twig.js is released under the [Apache License], Version 2.0. [Build Status]: http://travis-ci.org/schmittjoh/twig.js [Scrutinizer Badge]: https://scrutinizer-ci.com/g/h2s/twig.js/badges/quality-score.png?b=master [Scrutinizer Code Quality]: https://scrutinizer-ci.com/g/h2s/twig.js/?branch=master +[pull request #11]: https://github.com/schmittjoh/twig.js/pull/11 From 7afbfb9a5414f7caaed5832d64d217a24628ca4f Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sun, 24 Aug 2014 12:32:12 +0100 Subject: [PATCH 10/25] Add PR link to date filter mention as well --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31a58f3..4ebdb98 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ anybody hoping to make a contribution to the project. #### Unsupported Filters * `convert_encoding` -* `date` +* `date` (See [pull request #11]) * `date_modify` * `format` * `number_format` From 0c9a655960cd8166e6e55beb882f63d2c9e2cff4 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Fri, 5 Sep 2014 16:18:09 +0100 Subject: [PATCH 11/25] Add failing test for schmittjoh#79 --- .../integration/tests/includechild.test | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/TwigJs/Tests/Fixture/integration/tests/includechild.test diff --git a/tests/TwigJs/Tests/Fixture/integration/tests/includechild.test b/tests/TwigJs/Tests/Fixture/integration/tests/includechild.test new file mode 100644 index 0000000..e6cbea3 --- /dev/null +++ b/tests/TwigJs/Tests/Fixture/integration/tests/includechild.test @@ -0,0 +1,19 @@ +--TEST-- +Test for bug reported in pull request #79 +--TEMPLATE-- +Template A start +{% include("b.twig") %} +Template A end +--TEMPLATE(b.twig)-- +{% extends "c.twig" %} +{% block example %}block b +{% endblock %} +--TEMPLATE(c.twig)-- +Template C's block says: {% block example %}C block{% endblock %} +--DATA-- +return {} +--EXPECT-- +Template A start + +Template C's block says: block b +Template A end From 075bcf3af2e8d9993558b15b0fe67bbae22748b3 Mon Sep 17 00:00:00 2001 From: Miroslav Braun Date: Fri, 5 Sep 2014 13:33:25 +0200 Subject: [PATCH 12/25] Fix for https://github.com/schmittjoh/twig.js/pull/79 --- src/TwigJs/Compiler/BlockCompiler.php | 1 + src/TwigJs/Compiler/ModuleCompiler.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/TwigJs/Compiler/BlockCompiler.php b/src/TwigJs/Compiler/BlockCompiler.php index ae09db2..224ff61 100644 --- a/src/TwigJs/Compiler/BlockCompiler.php +++ b/src/TwigJs/Compiler/BlockCompiler.php @@ -43,6 +43,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) ->write(" * @param {Object.} blocks\n", " */\n") ->write("{$compiler->templateFunctionName}.prototype.block_") ->raw($node->getAttribute('name').' = function(sb, context, blocks) {'."\n") + ->raw("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ->indent() ->enterScope() ->subcompile($node->getNode('body')) diff --git a/src/TwigJs/Compiler/ModuleCompiler.php b/src/TwigJs/Compiler/ModuleCompiler.php index 2c61e3a..c6eb36e 100644 --- a/src/TwigJs/Compiler/ModuleCompiler.php +++ b/src/TwigJs/Compiler/ModuleCompiler.php @@ -189,6 +189,7 @@ protected function compileDisplayHeader(JsCompiler $compiler, \Twig_NodeInterfac $compiler ->write("/**\n", " * @inheritDoc\n", " */\n") ->write($this->functionName.".prototype.render_ = function(sb, context, blocks) {\n") + ->write("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ->indent() ; } From e40631b76fc78cffb8c76bfe8485fecebcc71778 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Fri, 5 Sep 2014 16:25:50 +0100 Subject: [PATCH 13/25] Fix indentation of generated code The previous commit added the new line of code *before* the indent() call, which made the compiled line of code look wrongly indented. --- src/TwigJs/Compiler/BlockCompiler.php | 2 +- src/TwigJs/Compiler/ModuleCompiler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TwigJs/Compiler/BlockCompiler.php b/src/TwigJs/Compiler/BlockCompiler.php index 224ff61..891854e 100644 --- a/src/TwigJs/Compiler/BlockCompiler.php +++ b/src/TwigJs/Compiler/BlockCompiler.php @@ -43,9 +43,9 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) ->write(" * @param {Object.} blocks\n", " */\n") ->write("{$compiler->templateFunctionName}.prototype.block_") ->raw($node->getAttribute('name').' = function(sb, context, blocks) {'."\n") - ->raw("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ->indent() ->enterScope() + ->raw("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ->subcompile($node->getNode('body')) ->leaveScope() ->outdent() diff --git a/src/TwigJs/Compiler/ModuleCompiler.php b/src/TwigJs/Compiler/ModuleCompiler.php index c6eb36e..e16d664 100644 --- a/src/TwigJs/Compiler/ModuleCompiler.php +++ b/src/TwigJs/Compiler/ModuleCompiler.php @@ -189,8 +189,8 @@ protected function compileDisplayHeader(JsCompiler $compiler, \Twig_NodeInterfac $compiler ->write("/**\n", " * @inheritDoc\n", " */\n") ->write($this->functionName.".prototype.render_ = function(sb, context, blocks) {\n") - ->write("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ->indent() + ->write("blocks = typeof(blocks) == \"undefined\" ? {} : blocks;"."\n") ; } From 9cd0b95ba76924d85582c572653e0cdf8161a217 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Fri, 5 Sep 2014 16:28:06 +0100 Subject: [PATCH 14/25] Fix generated code comparison tests --- tests/TwigJs/Tests/Fixture/generated/custom_name.js | 1 + tests/TwigJs/Tests/Fixture/generated/custom_name_extended.js | 1 + tests/TwigJs/Tests/Fixture/generated/sameas.js | 1 + tests/TwigJs/Tests/Fixture/generated/simple_standalone.js | 1 + 4 files changed, 4 insertions(+) diff --git a/tests/TwigJs/Tests/Fixture/generated/custom_name.js b/tests/TwigJs/Tests/Fixture/generated/custom_name.js index 63be3ac..631282a 100644 --- a/tests/TwigJs/Tests/Fixture/generated/custom_name.js +++ b/tests/TwigJs/Tests/Fixture/generated/custom_name.js @@ -32,6 +32,7 @@ foo.prototype.getParent_ = function(context) { * @inheritDoc */ foo.prototype.render_ = function(sb, context, blocks) { + blocks = typeof(blocks) == "undefined" ? {} : blocks; // line 2 sb.append("Hello!\n"); }; diff --git a/tests/TwigJs/Tests/Fixture/generated/custom_name_extended.js b/tests/TwigJs/Tests/Fixture/generated/custom_name_extended.js index 82ecf73..8d72324 100644 --- a/tests/TwigJs/Tests/Fixture/generated/custom_name_extended.js +++ b/tests/TwigJs/Tests/Fixture/generated/custom_name_extended.js @@ -32,6 +32,7 @@ bar.prototype.getParent_ = function(context) { * @inheritDoc */ bar.prototype.render_ = function(sb, context, blocks) { + blocks = typeof(blocks) == "undefined" ? {} : blocks; this.getParent(context).render_(sb, context, twig.extend({}, this.getBlocks(), blocks)); }; diff --git a/tests/TwigJs/Tests/Fixture/generated/sameas.js b/tests/TwigJs/Tests/Fixture/generated/sameas.js index 44ffaf6..8d8cc3d 100644 --- a/tests/TwigJs/Tests/Fixture/generated/sameas.js +++ b/tests/TwigJs/Tests/Fixture/generated/sameas.js @@ -32,6 +32,7 @@ sameas.prototype.getParent_ = function(context) { * @inheritDoc */ sameas.prototype.render_ = function(sb, context, blocks) { + blocks = typeof(blocks) == "undefined" ? {} : blocks; // line 1 sb.append("This is a simple template.

\n\n"); // line 3 diff --git a/tests/TwigJs/Tests/Fixture/generated/simple_standalone.js b/tests/TwigJs/Tests/Fixture/generated/simple_standalone.js index 5d23e47..cff9d14 100644 --- a/tests/TwigJs/Tests/Fixture/generated/simple_standalone.js +++ b/tests/TwigJs/Tests/Fixture/generated/simple_standalone.js @@ -32,6 +32,7 @@ simple_standalone.prototype.getParent_ = function(context) { * @inheritDoc */ simple_standalone.prototype.render_ = function(sb, context, blocks) { + blocks = typeof(blocks) == "undefined" ? {} : blocks; // line 1 sb.append("This is a simple template.

\n\n"); // line 3 From 90313c9b05eff0895df804a1665c9bf88283dde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Klein?= Date: Fri, 8 May 2015 16:26:25 +0200 Subject: [PATCH 15/25] Ignore profiler nodes --- src/TwigJs/JsCompiler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/TwigJs/JsCompiler.php b/src/TwigJs/JsCompiler.php index 46bb8e7..2ce139e 100644 --- a/src/TwigJs/JsCompiler.php +++ b/src/TwigJs/JsCompiler.php @@ -332,6 +332,10 @@ public function compile(\Twig_NodeInterface $node, $indentation = 0) public function subcompile(\Twig_NodeInterface $node, $raw = true) { + if ($node instanceof \Twig_Profiler_Node_EnterProfile || $node instanceof \Twig_Profiler_Node_LeaveProfile) { + return $this; + } + if (false === $raw) { $this->addIndentation(); } From fe6877ff86ad15ee4747e6d4e434b2d29ac441df Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Sat, 9 May 2015 20:11:46 +0100 Subject: [PATCH 16/25] Fix the build --- tests/TwigJs/Tests/FullIntegrationTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TwigJs/Tests/FullIntegrationTest.php b/tests/TwigJs/Tests/FullIntegrationTest.php index 728a30c..714979a 100644 --- a/tests/TwigJs/Tests/FullIntegrationTest.php +++ b/tests/TwigJs/Tests/FullIntegrationTest.php @@ -90,6 +90,7 @@ public function loadTest($file) { $test = file_get_contents($file); + // @codingStandardsIgnoreStart if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { $message = $match[1]; $condition = $match[2]; @@ -105,6 +106,7 @@ public function loadTest($file) } else { throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', $file)); } + // @codingStandardsIgnoreStart return array( $file, From a461c57432459660c5ded394def2105640f55916 Mon Sep 17 00:00:00 2001 From: Petr Kotek Date: Thu, 1 Sep 2016 16:43:11 +0200 Subject: [PATCH 17/25] Travis: run tests on more recent versions of PHP (5.6, 7.0) --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5488a3a..866eff7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: php php: - 5.3 + - 5.6 + - 7.0 script: make test From d5cc537736d7e6fa8098f4e9938d40c2873124a1 Mon Sep 17 00:00:00 2001 From: Petr Kotek Date: Thu, 1 Sep 2016 16:43:39 +0200 Subject: [PATCH 18/25] Travis: run on new container infrastructure --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 866eff7..282b0aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,5 @@ php: - 5.3 - 5.6 - 7.0 +sudo: false script: make test From 36ad48d3dc2057fa9de3d86221af1a90aaca55aa Mon Sep 17 00:00:00 2001 From: martinr Date: Mon, 30 Jan 2017 13:44:02 +1300 Subject: [PATCH 19/25] Fixes #107 for twig up to v1.30.0 --- composer.json | 2 +- composer.lock | 176 +++++++++--------- .../Expression/Test/DefinedCompiler.php | 2 +- .../Compiler/Expression/Test/EvenCompiler.php | 2 +- .../Compiler/Expression/Test/OddCompiler.php | 2 +- src/TwigJs/Compiler/ForCompiler.php | 6 +- src/TwigJs/Compiler/IncludeCompiler.php | 2 +- src/TwigJs/Compiler/ModuleCompiler.php | 6 +- 8 files changed, 103 insertions(+), 95 deletions(-) mode change 100644 => 100755 composer.json mode change 100644 => 100755 src/TwigJs/Compiler/Expression/Test/DefinedCompiler.php mode change 100644 => 100755 src/TwigJs/Compiler/Expression/Test/EvenCompiler.php mode change 100644 => 100755 src/TwigJs/Compiler/Expression/Test/OddCompiler.php mode change 100644 => 100755 src/TwigJs/Compiler/ForCompiler.php mode change 100644 => 100755 src/TwigJs/Compiler/IncludeCompiler.php mode change 100644 => 100755 src/TwigJs/Compiler/ModuleCompiler.php diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index 49b1fa7..99ec61e --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": ">=5.3.2", - "twig/twig": ">=1.8,<2.0-dev" + "twig/twig": "1.25 - 1.30.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 6d85d38..a8c8e4d 100644 --- a/composer.lock +++ b/composer.lock @@ -1,31 +1,37 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], - "hash": "1a06686557bec9eff8b957d65bcf7c72", + "hash": "93cfbc86dd2041bb7c4dcf34fac20623", + "content-hash": "4a4cb5927fec50bdae01d0e7ce4806ec", "packages": [ { "name": "twig/twig", - "version": "dev-master", + "version": "v1.30.0", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23" + "url": "https://github.com/twigphp/Twig.git", + "reference": "c6ff71094fde15d12398eaba029434b013dc5e59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/b0ee99d6d69b30a512064c8b4fac536f862a0d23", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/c6ff71094fde15d12398eaba029434b013dc5e59", + "reference": "c6ff71094fde15d12398eaba029434b013dc5e59", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" + }, + "require-dev": { + "symfony/debug": "~2.7", + "symfony/phpunit-bridge": "~3.2@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.30-dev" } }, "autoload": { @@ -51,7 +57,7 @@ }, { "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "homepage": "http://twig.sensiolabs.org/contributors", "role": "Contributors" } ], @@ -60,7 +66,7 @@ "keywords": [ "templating" ], - "time": "2014-02-13 10:36:05" + "time": "2016-12-23 11:06:22" } ], "packages-dev": [ @@ -165,19 +171,19 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46" + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/61fed79803b6c75d461b909dfac05bbef5cd4f46", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", "shasum": "" }, "require": { "php": ">=5.3.3", "phpunit/php-file-iterator": ">=1.3.0@stable", "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3@stable" + "phpunit/php-token-stream": ">=1.1.3,<1.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.*@dev" @@ -218,35 +224,37 @@ "testing", "xunit" ], - "time": "2014-05-19 01:58:57" + "time": "2014-09-02 10:13:14" }, { "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, "autoload": { "classmap": [ - "File/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -263,20 +271,20 @@ "filesystem", "iterator" ], - "time": "2013-10-10 15:34:57" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-text-template", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { @@ -285,20 +293,17 @@ "type": "library", "autoload": { "classmap": [ - "Text/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -307,35 +312,35 @@ "keywords": [ "template" ], - "time": "2014-01-30 17:20:04" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", - "version": "1.0.5", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4|~5" + }, "type": "library", "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -351,20 +356,20 @@ "keywords": [ "timer" ], - "time": "2013-08-02 07:42:54" + "time": "2016-05-12 18:03:57" }, { "name": "phpunit/php-token-stream", - "version": "dev-master", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531" + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/955c24b708f8bfd6a05f303217a8dac3a443d531", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", "shasum": "" }, "require": { @@ -401,7 +406,7 @@ "keywords": [ "tokenizer" ], - "time": "2014-05-12 05:34:42" + "time": "2014-03-03 05:10:30" }, { "name": "phpunit/phpunit", @@ -409,12 +414,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", "shasum": "" }, "require": { @@ -474,7 +479,7 @@ "testing", "xunit" ], - "time": "2014-04-30 12:24:19" + "time": "2014-10-17 09:04:17" }, { "name": "phpunit/phpunit-mock-objects", @@ -540,12 +545,12 @@ "source": { "type": "git", "url": "https://github.com/reactphp/event-loop.git", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f" + "reference": "13e03b17e54ea864c6653a2cf6d146dad8464e91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/235cddfa999a392e7d63dc9bef2e042492608d9f", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/13e03b17e54ea864c6653a2cf6d146dad8464e91", + "reference": "13e03b17e54ea864c6653a2cf6d146dad8464e91", "shasum": "" }, "require": { @@ -574,7 +579,7 @@ "keywords": [ "event-loop" ], - "time": "2013-07-21 02:23:09" + "time": "2016-12-28 22:48:03" }, { "name": "react/socket", @@ -665,16 +670,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "1.5.2", + "version": "1.5.x-dev", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860" + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6f3e42d311b882b25b4d409d23a289f4d3b803d5", + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5", "shasum": "" }, "require": { @@ -688,6 +693,11 @@ "scripts/phpcs" ], "type": "library", + "extra": { + "branch-alias": { + "dev-phpcs-fixer": "2.0.x-dev" + } + }, "autoload": { "classmap": [ "CodeSniffer.php", @@ -731,36 +741,38 @@ "phpcs", "standards" ], - "time": "2014-02-04 23:49:58" + "time": "2014-12-04 22:32:15" }, { "name": "symfony/yaml", - "version": "dev-master", - "target-dir": "Symfony/Component/Yaml", + "version": "2.8.x-dev", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c" + "url": "https://github.com/symfony/yaml.git", + "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b01d366060f33e18fd98b0008c41a01b0d25c95c", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c", + "url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153", + "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -769,32 +781,28 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-06-04 06:43:44" + "homepage": "https://symfony.com", + "time": "2017-01-21 16:40:50" } ], - "aliases": [ - - ], + "aliases": [], "minimum-stability": "dev", "stability-flags": { "dnode/dnode": 20, "phpunit/phpunit": 20 }, + "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.3.2" }, - "platform-dev": [ - - ] + "platform-dev": [] } diff --git a/src/TwigJs/Compiler/Expression/Test/DefinedCompiler.php b/src/TwigJs/Compiler/Expression/Test/DefinedCompiler.php old mode 100644 new mode 100755 index 1d388e7..9e1f491 --- a/src/TwigJs/Compiler/Expression/Test/DefinedCompiler.php +++ b/src/TwigJs/Compiler/Expression/Test/DefinedCompiler.php @@ -27,7 +27,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) new \Twig_Node_Expression_Test( $node->getNode('node'), $node->getAttribute('name'), - $node->getNode('arguments'), + $node->hasNode('arguments') ? $node->getNode('arguments') : null, $node->getLine() ) ); diff --git a/src/TwigJs/Compiler/Expression/Test/EvenCompiler.php b/src/TwigJs/Compiler/Expression/Test/EvenCompiler.php old mode 100644 new mode 100755 index a763b43..ca96516 --- a/src/TwigJs/Compiler/Expression/Test/EvenCompiler.php +++ b/src/TwigJs/Compiler/Expression/Test/EvenCompiler.php @@ -27,7 +27,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) new \Twig_Node_Expression_Test( $node->getNode('node'), $node->getAttribute('name'), - $node->getNode('arguments'), + $node->hasNode('arguments') ? $node->getNode('arguments') : null, $node->getLine() ) ); diff --git a/src/TwigJs/Compiler/Expression/Test/OddCompiler.php b/src/TwigJs/Compiler/Expression/Test/OddCompiler.php old mode 100644 new mode 100755 index 05a201e..c3d47bb --- a/src/TwigJs/Compiler/Expression/Test/OddCompiler.php +++ b/src/TwigJs/Compiler/Expression/Test/OddCompiler.php @@ -27,7 +27,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) new \Twig_Node_Expression_Test( $node->getNode('node'), $node->getAttribute('name'), - $node->getNode('arguments'), + $node->hasNode('arguments') ? $node->getNode('arguments') : null, $node->getLine() ) ); diff --git a/src/TwigJs/Compiler/ForCompiler.php b/src/TwigJs/Compiler/ForCompiler.php old mode 100644 new mode 100755 index 58d48d0..ed3852a --- a/src/TwigJs/Compiler/ForCompiler.php +++ b/src/TwigJs/Compiler/ForCompiler.php @@ -73,7 +73,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) ->raw(";\n") ; - if (null !== $node->getNode('else')) { + if ($node->hasNode('else') && null !== $node->getNode('else')) { $compiler->write("var $iteratedName = false;\n"); } @@ -117,7 +117,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) $ref = new \ReflectionProperty($node, 'loop'); $ref->setAccessible(true); $loop = $ref->getValue($node); - $loop->setAttribute('else', null !== $node->getNode('else')); + $loop->setAttribute('else', $node->hasNode('else') && null !== $node->getNode('else')); $loop->setAttribute('with_loop', $node->getAttribute('with_loop')); $loop->setAttribute('ifexpr', $node->getAttribute('ifexpr')); @@ -135,7 +135,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) ->write("}, this);\n") ; - if (null !== $node->getNode('else')) { + if ($node->hasNode('else') && null !== $node->getNode('else')) { $compiler ->write("if (!$iteratedName) {\n") ->indent() diff --git a/src/TwigJs/Compiler/IncludeCompiler.php b/src/TwigJs/Compiler/IncludeCompiler.php old mode 100644 new mode 100755 index b18e2a2..0072714 --- a/src/TwigJs/Compiler/IncludeCompiler.php +++ b/src/TwigJs/Compiler/IncludeCompiler.php @@ -66,7 +66,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) $compiler->isTemplateName = false; if (false === $node->getAttribute('only')) { - if (null === $node->getNode('variables')) { + if (!$node->hasNode('variables') || null === $node->getNode('variables')) { $compiler->raw('context'); } else { $compiler diff --git a/src/TwigJs/Compiler/ModuleCompiler.php b/src/TwigJs/Compiler/ModuleCompiler.php old mode 100644 new mode 100755 index e16d664..ddc1704 --- a/src/TwigJs/Compiler/ModuleCompiler.php +++ b/src/TwigJs/Compiler/ModuleCompiler.php @@ -57,7 +57,7 @@ protected function compileGetParent(JsCompiler $compiler, \Twig_NodeInterface $n ->write('return ') ; - if (null === $node->getNode('parent')) { + if (!$node->hasNode('parent') || null === $node->getNode('parent')) { $compiler->repr(false); } else { $compiler @@ -82,7 +82,7 @@ protected function compileDisplayBody(JsCompiler $compiler, \Twig_NodeInterface ->leaveScope() ; - if (null !== $node->getNode('parent')) { + if ($node->hasNode('parent') && null !== $node->getNode('parent')) { $compiler ->write("this.getParent(context).render_(sb, context, twig.extend({}, this.getBlocks(), blocks));\n") ; @@ -228,7 +228,7 @@ protected function compileIsTraitable(JsCompiler $compiler, \Twig_NodeInterface // // Put another way, a template can be used as a trait if it // only contains blocks and use statements. - $traitable = null === $node->getNode('parent') && 0 === count($node->getNode('macros')); + $traitable = (!$node->hasNode('parent') || null === $node->getNode('parent')) && 0 === count($node->getNode('macros')); if ($traitable) { if (!count($nodes = $node->getNode('body'))) { $nodes = new Twig_Node(array($node->getNode('body'))); From fa866f88c44b87c5cd1878cc3db92bcd9eabbca6 Mon Sep 17 00:00:00 2001 From: martinr Date: Mon, 30 Jan 2017 13:54:38 +1300 Subject: [PATCH 20/25] Add composer flag: prefer-stable: true --- composer.json | 1 + composer.lock | 220 +++++++++++++++++++++++++------------------------- 2 files changed, 109 insertions(+), 112 deletions(-) diff --git a/composer.json b/composer.json index 49b1fa7..993e36c 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ }, "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-0": { "TwigJs": "src/" } }, diff --git a/composer.lock b/composer.lock index 6d85d38..d95751a 100644 --- a/composer.lock +++ b/composer.lock @@ -1,31 +1,37 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" ], - "hash": "1a06686557bec9eff8b957d65bcf7c72", + "hash": "f318993b65d12023d2f26cdf47f48f5c", + "content-hash": "b52b69b5ab67cfa2999e0a28fa3e7204", "packages": [ { "name": "twig/twig", - "version": "dev-master", + "version": "v1.31.0", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23" + "url": "https://github.com/twigphp/Twig.git", + "reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/b0ee99d6d69b30a512064c8b4fac536f862a0d23", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ddc9e3e20ee9c0b6908f401ac8353635b750eca7", + "reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" + }, + "require-dev": { + "symfony/debug": "~2.7", + "symfony/phpunit-bridge": "~3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "1.31-dev" } }, "autoload": { @@ -51,7 +57,7 @@ }, { "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "homepage": "http://twig.sensiolabs.org/contributors", "role": "Contributors" } ], @@ -60,7 +66,7 @@ "keywords": [ "templating" ], - "time": "2014-02-13 10:36:05" + "time": "2017-01-11 19:36:15" } ], "packages-dev": [ @@ -116,27 +122,22 @@ }, { "name": "evenement/evenement", - "version": "1.0.x-dev", + "version": "v1.0.0", "source": { "type": "git", "url": "https://github.com/igorw/evenement.git", - "reference": "8b0918f8374327dfed4408fe467980ab41d556dd" + "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/8b0918f8374327dfed4408fe467980ab41d556dd", - "reference": "8b0918f8374327dfed4408fe467980ab41d556dd", + "url": "https://api.github.com/repos/igorw/evenement/zipball/fa966683e7df3e5dd5929d984a44abfbd6bafe8d", + "reference": "fa966683e7df3e5dd5929d984a44abfbd6bafe8d", "shasum": "" }, "require": { "php": ">=5.3.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, "autoload": { "psr-0": { "Evenement": "src" @@ -157,27 +158,27 @@ "keywords": [ "event-dispatcher" ], - "time": "2012-12-29 17:04:52" + "time": "2012-05-30 15:01:08" }, { "name": "phpunit/php-code-coverage", - "version": "1.2.x-dev", + "version": "1.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46" + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/61fed79803b6c75d461b909dfac05bbef5cd4f46", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", + "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b", "shasum": "" }, "require": { "php": ">=5.3.3", "phpunit/php-file-iterator": ">=1.3.0@stable", "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3@stable" + "phpunit/php-token-stream": ">=1.1.3,<1.3.0" }, "require-dev": { "phpunit/phpunit": "3.7.*@dev" @@ -218,35 +219,37 @@ "testing", "xunit" ], - "time": "2014-05-19 01:58:57" + "time": "2014-09-02 10:13:14" }, { "name": "phpunit/php-file-iterator", - "version": "1.3.4", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { "php": ">=5.3.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, "autoload": { "classmap": [ - "File/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -263,20 +266,20 @@ "filesystem", "iterator" ], - "time": "2013-10-10 15:34:57" + "time": "2016-10-03 07:40:28" }, { "name": "phpunit/php-text-template", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", "shasum": "" }, "require": { @@ -285,20 +288,17 @@ "type": "library", "autoload": { "classmap": [ - "Text/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -307,35 +307,35 @@ "keywords": [ "template" ], - "time": "2014-01-30 17:20:04" + "time": "2015-06-21 13:50:34" }, { "name": "phpunit/php-timer", - "version": "1.0.5", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", + "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "phpunit/phpunit": "~4|~5" + }, "type": "library", "autoload": { "classmap": [ - "PHP/" + "src/" ] }, "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], "license": [ "BSD-3-Clause" ], @@ -351,20 +351,20 @@ "keywords": [ "timer" ], - "time": "2013-08-02 07:42:54" + "time": "2016-05-12 18:03:57" }, { "name": "phpunit/php-token-stream", - "version": "dev-master", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531" + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/955c24b708f8bfd6a05f303217a8dac3a443d531", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32", + "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32", "shasum": "" }, "require": { @@ -401,20 +401,20 @@ "keywords": [ "tokenizer" ], - "time": "2014-05-12 05:34:42" + "time": "2014-03-03 05:10:30" }, { "name": "phpunit/phpunit", - "version": "3.7.x-dev", + "version": "3.7.38", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6", + "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6", "shasum": "" }, "require": { @@ -474,38 +474,30 @@ "testing", "xunit" ], - "time": "2014-04-30 12:24:19" + "time": "2014-10-17 09:04:17" }, { "name": "phpunit/phpunit-mock-objects", - "version": "1.2.x-dev", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "c39c4511c3b007539eb170c32cbc2af49a07351a" + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c39c4511c3b007539eb170c32cbc2af49a07351a", - "reference": "c39c4511c3b007539eb170c32cbc2af49a07351a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875", + "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875", "shasum": "" }, "require": { "php": ">=5.3.3", "phpunit/php-text-template": ">=1.1.1@stable" }, - "require-dev": { - "phpunit/phpunit": "3.7.*@dev" - }, "suggest": { "ext-soap": "*" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "classmap": [ "PHPUnit/" @@ -531,21 +523,21 @@ "mock", "xunit" ], - "time": "2014-02-16 12:43:56" + "time": "2013-01-13 10:24:48" }, { "name": "react/event-loop", - "version": "0.3.x-dev", + "version": "v0.3.5", "target-dir": "React/EventLoop", "source": { "type": "git", "url": "https://github.com/reactphp/event-loop.git", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f" + "reference": "13e03b17e54ea864c6653a2cf6d146dad8464e91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/235cddfa999a392e7d63dc9bef2e042492608d9f", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/13e03b17e54ea864c6653a2cf6d146dad8464e91", + "reference": "13e03b17e54ea864c6653a2cf6d146dad8464e91", "shasum": "" }, "require": { @@ -574,11 +566,11 @@ "keywords": [ "event-loop" ], - "time": "2013-07-21 02:23:09" + "time": "2016-12-28 22:48:03" }, { "name": "react/socket", - "version": "0.3.x-dev", + "version": "v0.3.4", "target-dir": "React/Socket", "source": { "type": "git", @@ -620,7 +612,7 @@ }, { "name": "react/stream", - "version": "0.3.x-dev", + "version": "v0.3.4", "target-dir": "React/Stream", "source": { "type": "git", @@ -665,16 +657,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "1.5.2", + "version": "1.5.6", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860" + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6f3e42d311b882b25b4d409d23a289f4d3b803d5", + "reference": "6f3e42d311b882b25b4d409d23a289f4d3b803d5", "shasum": "" }, "require": { @@ -688,6 +680,11 @@ "scripts/phpcs" ], "type": "library", + "extra": { + "branch-alias": { + "dev-phpcs-fixer": "2.0.x-dev" + } + }, "autoload": { "classmap": [ "CodeSniffer.php", @@ -731,36 +728,38 @@ "phpcs", "standards" ], - "time": "2014-02-04 23:49:58" + "time": "2014-12-04 22:32:15" }, { "name": "symfony/yaml", - "version": "dev-master", - "target-dir": "Symfony/Component/Yaml", + "version": "v2.8.16", "source": { "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c" + "url": "https://github.com/symfony/yaml.git", + "reference": "dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b01d366060f33e18fd98b0008c41a01b0d25c95c", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c", + "url": "https://api.github.com/repos/symfony/yaml/zipball/dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2", + "reference": "dbe61fed9cd4a44c5b1d14e5e7b1a8640cfb2bf2", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -769,32 +768,29 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" + "email": "fabien@symfony.com" }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-06-04 06:43:44" + "homepage": "https://symfony.com", + "time": "2017-01-03 13:49:52" } ], - "aliases": [ - - ], + "aliases": [], "minimum-stability": "dev", "stability-flags": { + "twig/twig": 20, "dnode/dnode": 20, "phpunit/phpunit": 20 }, + "prefer-stable": true, + "prefer-lowest": false, "platform": { "php": ">=5.3.2" }, - "platform-dev": [ - - ] + "platform-dev": [] } From fdf567033b086c10b58d45eecb228fd70a01a34d Mon Sep 17 00:00:00 2001 From: martinr Date: Mon, 30 Jan 2017 13:56:44 +1300 Subject: [PATCH 21/25] Libraries should not include a composer.lock file --- composer.lock | 800 -------------------------------------------------- 1 file changed, 800 deletions(-) delete mode 100644 composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 6d85d38..0000000 --- a/composer.lock +++ /dev/null @@ -1,800 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" - ], - "hash": "1a06686557bec9eff8b957d65bcf7c72", - "packages": [ - { - "name": "twig/twig", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/fabpot/Twig.git", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/b0ee99d6d69b30a512064c8b4fac536f862a0d23", - "reference": "b0ee99d6d69b30a512064c8b4fac536f862a0d23", - "shasum": "" - }, - "require": { - "php": ">=5.2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ], - "time": "2014-02-13 10:36:05" - } - ], - "packages-dev": [ - { - "name": "dnode/dnode", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/bergie/dnode-php.git", - "reference": "048deef50afe95e21ef25c026bd79b2917920f3b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bergie/dnode-php/zipball/048deef50afe95e21ef25c026bd79b2917920f3b", - "reference": "048deef50afe95e21ef25c026bd79b2917920f3b", - "shasum": "" - }, - "require": { - "evenement/evenement": "~1.0", - "php": ">=5.3.0", - "react/socket": "0.3.*" - }, - "type": "library", - "autoload": { - "psr-0": { - "DNode": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch", - "homepage": "http://wiedler.ch/igor/" - }, - { - "name": "Henri Bergius", - "email": "henri.bergius@iki.fi", - "homepage": "http://bergie.iki.fi/" - } - ], - "description": "DNode RPC protocol for PHP 5.3", - "homepage": "https://github.com/bergie/dnode-php", - "keywords": [ - "dnode", - "nodejs", - "rpc" - ], - "time": "2014-01-31 09:12:55" - }, - { - "name": "evenement/evenement", - "version": "1.0.x-dev", - "source": { - "type": "git", - "url": "https://github.com/igorw/evenement.git", - "reference": "8b0918f8374327dfed4408fe467980ab41d556dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/8b0918f8374327dfed4408fe467980ab41d556dd", - "reference": "8b0918f8374327dfed4408fe467980ab41d556dd", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-0": { - "Evenement": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch", - "homepage": "http://wiedler.ch/igor/" - } - ], - "description": "Événement is a very simple event dispatching library for PHP 5.3", - "keywords": [ - "event-dispatcher" - ], - "time": "2012-12-29 17:04:52" - }, - { - "name": "phpunit/php-code-coverage", - "version": "1.2.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/61fed79803b6c75d461b909dfac05bbef5cd4f46", - "reference": "61fed79803b6c75d461b909dfac05bbef5cd4f46", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": ">=1.3.0@stable", - "phpunit/php-text-template": ">=1.2.0@stable", - "phpunit/php-token-stream": ">=1.1.3@stable" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*@dev" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.0.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2014-05-19 01:58:57" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.3.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", - "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "File/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2013-10-10 15:34:57" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "Text/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2014-01-30 17:20:04" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2013-08-02 07:42:54" - }, - { - "name": "phpunit/php-token-stream", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/955c24b708f8bfd6a05f303217a8dac3a443d531", - "reference": "955c24b708f8bfd6a05f303217a8dac3a443d531", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "classmap": [ - "PHP/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2014-05-12 05:34:42" - }, - { - "name": "phpunit/phpunit", - "version": "3.7.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "reference": "ae6cefd7cc84586a5ef27e04bae11ee940ec63dc", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpunit/php-code-coverage": "~1.2", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.1", - "phpunit/php-timer": "~1.0", - "phpunit/phpunit-mock-objects": "~1.2", - "symfony/yaml": "~2.0" - }, - "require-dev": { - "pear-pear.php.net/pear": "1.9.4" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "composer/bin/phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.7.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "", - "../../symfony/yaml/" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "http://www.phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2014-04-30 12:24:19" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "1.2.x-dev", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "c39c4511c3b007539eb170c32cbc2af49a07351a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c39c4511c3b007539eb170c32cbc2af49a07351a", - "reference": "c39c4511c3b007539eb170c32cbc2af49a07351a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-text-template": ">=1.1.1@stable" - }, - "require-dev": { - "phpunit/phpunit": "3.7.*@dev" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "PHPUnit/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "" - ], - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2014-02-16 12:43:56" - }, - { - "name": "react/event-loop", - "version": "0.3.x-dev", - "target-dir": "React/EventLoop", - "source": { - "type": "git", - "url": "https://github.com/reactphp/event-loop.git", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/235cddfa999a392e7d63dc9bef2e042492608d9f", - "reference": "235cddfa999a392e7d63dc9bef2e042492608d9f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-libev": "*", - "ext-libevent": ">=0.0.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "React\\EventLoop": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Event loop abstraction layer that libraries can use for evented I/O.", - "keywords": [ - "event-loop" - ], - "time": "2013-07-21 02:23:09" - }, - { - "name": "react/socket", - "version": "0.3.x-dev", - "target-dir": "React/Socket", - "source": { - "type": "git", - "url": "https://github.com/reactphp/socket.git", - "reference": "19bc0c4309243717396022ffb2e59be1cc784327" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/socket/zipball/19bc0c4309243717396022ffb2e59be1cc784327", - "reference": "19bc0c4309243717396022ffb2e59be1cc784327", - "shasum": "" - }, - "require": { - "evenement/evenement": "1.0.*", - "php": ">=5.3.3", - "react/event-loop": "0.3.*", - "react/stream": "0.3.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "React\\Socket": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Library for building an evented socket server.", - "keywords": [ - "Socket" - ], - "time": "2014-02-17 22:32:00" - }, - { - "name": "react/stream", - "version": "0.3.x-dev", - "target-dir": "React/Stream", - "source": { - "type": "git", - "url": "https://github.com/reactphp/stream.git", - "reference": "feef56628afe3fa861f0da5f92c909e029efceac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/feef56628afe3fa861f0da5f92c909e029efceac", - "reference": "feef56628afe3fa861f0da5f92c909e029efceac", - "shasum": "" - }, - "require": { - "evenement/evenement": "1.0.*", - "php": ">=5.3.3" - }, - "suggest": { - "react/event-loop": "0.3.*", - "react/promise": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "React\\Stream": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Basic readable and writable stream interfaces that support piping.", - "keywords": [ - "pipe", - "stream" - ], - "time": "2014-02-16 19:48:52" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "1.5.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860", - "reference": "a76a39b317ce8106abe6264daa505e24e1731860", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.1.2" - }, - "suggest": { - "phpunit/php-timer": "dev-master" - }, - "bin": [ - "scripts/phpcs" - ], - "type": "library", - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/CommentParser/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2014-02-04 23:49:58" - }, - { - "name": "symfony/yaml", - "version": "dev-master", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b01d366060f33e18fd98b0008c41a01b0d25c95c", - "reference": "b01d366060f33e18fd98b0008c41a01b0d25c95c", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2014-06-04 06:43:44" - } - ], - "aliases": [ - - ], - "minimum-stability": "dev", - "stability-flags": { - "dnode/dnode": 20, - "phpunit/phpunit": 20 - }, - "platform": { - "php": ">=5.3.2" - }, - "platform-dev": [ - - ] -} From 4995801553d68bdc0712110d2fe28d31f85612f1 Mon Sep 17 00:00:00 2001 From: martinr Date: Mon, 30 Jan 2017 13:58:07 +1300 Subject: [PATCH 22/25] Relax twig version requirements --- composer.json | 2 +- composer.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 99ec61e..73b11fd 100755 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": ">=5.3.2", - "twig/twig": "1.25 - 1.30.0" + "twig/twig": "^1.24" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a8c8e4d..521b44a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "93cfbc86dd2041bb7c4dcf34fac20623", - "content-hash": "4a4cb5927fec50bdae01d0e7ce4806ec", + "hash": "2a158a8c621c01ed3d1466c69100c97a", + "content-hash": "0c47660fe6d67445e77161bf6f3e4e23", "packages": [ { "name": "twig/twig", - "version": "v1.30.0", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "c6ff71094fde15d12398eaba029434b013dc5e59" + "reference": "a1c1f01eac45b68d6f17c3b499297b93e1a47321" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/c6ff71094fde15d12398eaba029434b013dc5e59", - "reference": "c6ff71094fde15d12398eaba029434b013dc5e59", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a1c1f01eac45b68d6f17c3b499297b93e1a47321", + "reference": "a1c1f01eac45b68d6f17c3b499297b93e1a47321", "shasum": "" }, "require": { @@ -26,12 +26,12 @@ }, "require-dev": { "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.2@dev" + "symfony/phpunit-bridge": "~3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.30-dev" + "dev-master": "1.31-dev" } }, "autoload": { @@ -66,7 +66,7 @@ "keywords": [ "templating" ], - "time": "2016-12-23 11:06:22" + "time": "2017-01-19 14:55:10" } ], "packages-dev": [ From 12f0f4a8a719189711051aa2b46de2962c2865fe Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Mon, 30 Jan 2017 14:06:57 +1300 Subject: [PATCH 23/25] Update composer.json Change twig dep to ^1.25 rather than ^1.24 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 73b11fd..da05aa6 100755 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": ">=5.3.2", - "twig/twig": "^1.24" + "twig/twig": "^1.25" }, "require-dev": { From 217369cecaa435eee6987a0568249de1b94b8b4f Mon Sep 17 00:00:00 2001 From: martinr Date: Wed, 1 Feb 2017 09:53:24 +1300 Subject: [PATCH 24/25] ignore composer.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index de4235f..2c2ea55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ bin/plovr phpunit.xml +composer.lock config.php vendor/ tmp/ From a83783fc3768f4fe2506b77b08e736200823f566 Mon Sep 17 00:00:00 2001 From: jstuhli Date: Thu, 10 Jan 2019 13:48:57 +0100 Subject: [PATCH 25/25] Additional patches for twig v1.25+ --- src/TwigJs/Compiler/Expression/GetAttrCompiler.php | 2 +- src/TwigJs/Compiler/Expression/Test/NullCompiler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TwigJs/Compiler/Expression/GetAttrCompiler.php b/src/TwigJs/Compiler/Expression/GetAttrCompiler.php index c4522ad..cf93801 100644 --- a/src/TwigJs/Compiler/Expression/GetAttrCompiler.php +++ b/src/TwigJs/Compiler/Expression/GetAttrCompiler.php @@ -57,7 +57,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) ->subcompile($node->getNode('attribute')) ; - $defaultArguments = 0 === count($node->getNode('arguments')); + $defaultArguments = 0 === ($node->hasNode('arguments') ? count($node->getNode('arguments')) : 0); $defaultAccess = \Twig_TemplateInterface::ANY_CALL === $node->getAttribute('type'); $defaultTest = false == $node->getAttribute('is_defined_test'); diff --git a/src/TwigJs/Compiler/Expression/Test/NullCompiler.php b/src/TwigJs/Compiler/Expression/Test/NullCompiler.php index 5489a28..3a3c89d 100644 --- a/src/TwigJs/Compiler/Expression/Test/NullCompiler.php +++ b/src/TwigJs/Compiler/Expression/Test/NullCompiler.php @@ -27,7 +27,7 @@ public function compile(JsCompiler $compiler, \Twig_NodeInterface $node) new \Twig_Node_Expression_Test( $node->getNode('node'), $node->getAttribute('name'), - $node->getNode('arguments'), + $node->hasNode('arguments') ? $node->getNode('arguments') : null, $node->getLine() ) );