1--TEST--
2Twig supports the in operator
3--TEMPLATE--
4{% if bar in foo %}
5TRUE
6{% endif %}
7{% if not (bar in foo) %}
8{% else %}
9TRUE
10{% endif %}
11{% if bar not in foo %}
12{% else %}
13TRUE
14{% endif %}
15{% if 'a' in bar %}
16TRUE
17{% endif %}
18{% if 'c' not in bar %}
19TRUE
20{% endif %}
21{% if '' in bar %}
22TRUE
23{% endif %}
24{% if '' in '' %}
25TRUE
26{% endif %}
27{% if '0' not in '' %}
28TRUE
29{% endif %}
30{% if 'a' not in '0' %}
31TRUE
32{% endif %}
33{% if '0' in '0' %}
34TRUE
35{% endif %}
36
37{{ false in [0, 1] ? 'TRUE' : 'FALSE' }}
38{{ true in [0, 1] ? 'TRUE' : 'FALSE' }}
39{{ '0' in [0, 1] ? 'TRUE' : 'FALSE' }}
40{{ '' in [0, 1] ? 'TRUE' : 'FALSE' }}
41{{ 0 in ['', 1] ? 'TRUE' : 'FALSE' }}
42
43{{ '' in 'foo' ? 'TRUE' : 'FALSE' }}
44{{ 0 in 'foo' ? 'TRUE' : 'FALSE' }}
45{{ false in 'foo' ? 'TRUE' : 'FALSE' }}
46{{ false in '100' ? 'TRUE' : 'FALSE' }}
47{{ true in '100' ? 'TRUE' : 'FALSE' }}
48
49{{ [] in [true, false] ? 'TRUE' : 'FALSE' }}
50{{ [] in [true, ''] ? 'TRUE' : 'FALSE' }}
51{{ [] in [true, []] ? 'TRUE' : 'FALSE' }}
52
53{{ resource ? 'TRUE' : 'FALSE' }}
54{{ resource in 'foo'~resource ? 'TRUE' : 'FALSE' }}
55{{ object in 'stdClass' ? 'TRUE' : 'FALSE' }}
56{{ [] in 'Array' ? 'TRUE' : 'FALSE' }}
57{{ dir_object in 'foo'~dir_object ? 'TRUE' : 'FALSE' }}
58
59{{ ''~resource in resource ? 'TRUE' : 'FALSE' }}
60{{ 'stdClass' in object ? 'TRUE' : 'FALSE' }}
61{{ 'Array' in [] ? 'TRUE' : 'FALSE' }}
62{{ ''~dir_object in dir_object ? 'TRUE' : 'FALSE' }}
63
64{{ resource in [''~resource] ? 'TRUE' : 'FALSE' }}
65{{ resource in [resource + 1 - 1] ? 'TRUE' : 'FALSE' }}
66{{ dir_object in [''~dir_object] ? 'TRUE' : 'FALSE' }}
67
68{{ 5 in 125 ? 'TRUE' : 'FALSE' }}
69{{ 5 in '125' ? 'TRUE' : 'FALSE' }}
70{{ '5' in 125 ? 'TRUE' : 'FALSE' }}
71{{ '5' in '125' ? 'TRUE' : 'FALSE' }}
72
73{{ 5.5 in 125.5 ? 'TRUE' : 'FALSE' }}
74{{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }}
75{{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }}
76--DATA--
77return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new \SplFileInfo(dirname(__FILE__)), 'object' => new \stdClass(), 'resource' => opendir(dirname(__FILE__))]
78--EXPECT--
79TRUE
80TRUE
81TRUE
82TRUE
83TRUE
84TRUE
85TRUE
86TRUE
87TRUE
88TRUE
89
90TRUE
91TRUE
92TRUE
93TRUE
94TRUE
95
96TRUE
97FALSE
98FALSE
99FALSE
100FALSE
101
102TRUE
103FALSE
104TRUE
105
106TRUE
107FALSE
108FALSE
109FALSE
110FALSE
111
112FALSE
113FALSE
114FALSE
115FALSE
116
117FALSE
118FALSE
119FALSE
120
121FALSE
122TRUE
123FALSE
124TRUE
125
126FALSE
127TRUE
128FALSE
129