Skip to content

Commit dbff8ef

Browse files
authored
Merge pull request #20 from phalcon/feature/env
Added support of _ENV global var
2 parents 97a3763 + 0f03e1a commit dbff8ef

File tree

5 files changed

+248
-1
lines changed

5 files changed

+248
-1
lines changed

parser/scanner.re

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
635635
token->opcode = XX_T_IDENTIFIER;
636636
return 0;
637637
}
638+
639+
if (!strcmp(token->value, "_ENV")) {
640+
token->opcode = XX_T_IDENTIFIER;
641+
return 0;
642+
}
638643
}
639644

640645
/* This is hack */

unit-tests/Data/globals/simple.zep

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Example;
2+
3+
class Test
4+
{
5+
public function all()
6+
{
7+
var _get = _GET;
8+
var _post = _POST;
9+
var _request = _REQUEST;
10+
var _cookie = _COOKIE;
11+
var _server = _SERVER;
12+
var _session = _SESSION;
13+
var _files = _FILES;
14+
var _env = _ENV;
15+
}
16+
}
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<?php
2+
3+
return [
4+
[
5+
'type' => 'namespace',
6+
'name' => 'Example',
7+
'file' => data_path('globals/simple.zep'),
8+
'line' => 3,
9+
'char' => 5,
10+
],
11+
[
12+
'type' => 'class',
13+
'name' => 'Test',
14+
'abstract' => 0,
15+
'final' => 0,
16+
'definition' => [
17+
'methods' => [
18+
[
19+
'visibility' => ['public'],
20+
'type' => 'method',
21+
'name' => 'all',
22+
'statements' => [
23+
[
24+
'type' => 'declare',
25+
'data-type' => 'variable',
26+
'variables' => [
27+
[
28+
'variable' => '_get',
29+
'expr' => [
30+
'type' => 'variable',
31+
'value' => '_GET',
32+
'file' => data_path('globals/simple.zep'),
33+
'line' => 7,
34+
'char' => 18,
35+
],
36+
'file' => data_path('globals/simple.zep'),
37+
'line' => 7,
38+
'char' => 18,
39+
],
40+
],
41+
'file' => data_path('globals/simple.zep'),
42+
'line' => 8,
43+
'char' => 5,
44+
],
45+
[
46+
'type' => 'declare',
47+
'data-type' => 'variable',
48+
'variables' => [
49+
[
50+
'variable' => '_post',
51+
'expr' => [
52+
'type' => 'variable',
53+
'value' => '_POST',
54+
'file' => data_path('globals/simple.zep'),
55+
'line' => 8,
56+
'char' => 20,
57+
],
58+
'file' => data_path('globals/simple.zep'),
59+
'line' => 8,
60+
'char' => 20,
61+
],
62+
],
63+
'file' => data_path('globals/simple.zep'),
64+
'line' => 9,
65+
'char' => 5,
66+
],
67+
[
68+
'type' => 'declare',
69+
'data-type' => 'variable',
70+
'variables' => [
71+
[
72+
'variable' => '_request',
73+
'expr' => [
74+
'type' => 'variable',
75+
'value' => '_REQUEST',
76+
'file' => data_path('globals/simple.zep'),
77+
'line' => 9,
78+
'char' => 26,
79+
],
80+
'file' => data_path('globals/simple.zep'),
81+
'line' => 9,
82+
'char' => 26,
83+
],
84+
],
85+
'file' => data_path('globals/simple.zep'),
86+
'line' => 10,
87+
'char' => 5,
88+
],
89+
[
90+
'type' => 'declare',
91+
'data-type' => 'variable',
92+
'variables' => [
93+
[
94+
'variable' => '_cookie',
95+
'expr' => [
96+
'type' => 'variable',
97+
'value' => '_COOKIE',
98+
'file' => data_path('globals/simple.zep'),
99+
'line' => 10,
100+
'char' => 24,
101+
],
102+
'file' => data_path('globals/simple.zep'),
103+
'line' => 10,
104+
'char' => 24,
105+
],
106+
],
107+
'file' => data_path('globals/simple.zep'),
108+
'line' => 11,
109+
'char' => 5,
110+
],
111+
[
112+
'type' => 'declare',
113+
'data-type' => 'variable',
114+
'variables' => [
115+
[
116+
'variable' => '_server',
117+
'expr' => [
118+
'type' => 'variable',
119+
'value' => '_SERVER',
120+
'file' => data_path('globals/simple.zep'),
121+
'line' => 11,
122+
'char' => 24,
123+
],
124+
'file' => data_path('globals/simple.zep'),
125+
'line' => 11,
126+
'char' => 24,
127+
],
128+
],
129+
'file' => data_path('globals/simple.zep'),
130+
'line' => 12,
131+
'char' => 5,
132+
],
133+
[
134+
'type' => 'declare',
135+
'data-type' => 'variable',
136+
'variables' => [
137+
[
138+
'variable' => '_session',
139+
'expr' => [
140+
'type' => 'variable',
141+
'value' => '_SESSION',
142+
'file' => data_path('globals/simple.zep'),
143+
'line' => 12,
144+
'char' => 26,
145+
],
146+
'file' => data_path('globals/simple.zep'),
147+
'line' => 12,
148+
'char' => 26,
149+
],
150+
],
151+
'file' => data_path('globals/simple.zep'),
152+
'line' => 13,
153+
'char' => 5,
154+
],
155+
[
156+
'type' => 'declare',
157+
'data-type' => 'variable',
158+
'variables' => [
159+
[
160+
'variable' => '_files',
161+
'expr' => [
162+
'type' => 'variable',
163+
'value' => '_FILES',
164+
'file' => data_path('globals/simple.zep'),
165+
'line' => 13,
166+
'char' => 22,
167+
],
168+
'file' => data_path('globals/simple.zep'),
169+
'line' => 13,
170+
'char' => 22,
171+
],
172+
],
173+
'file' => data_path('globals/simple.zep'),
174+
'line' => 14,
175+
'char' => 5,
176+
],
177+
[
178+
'type' => 'declare',
179+
'data-type' => 'variable',
180+
'variables' => [
181+
[
182+
'variable' => '_env',
183+
'expr' => [
184+
'type' => 'variable',
185+
'value' => '_ENV',
186+
'file' => data_path('globals/simple.zep'),
187+
'line' => 14,
188+
'char' => 18,
189+
],
190+
'file' => data_path('globals/simple.zep'),
191+
'line' => 14,
192+
'char' => 18,
193+
],
194+
],
195+
'file' => data_path('globals/simple.zep'),
196+
'line' => 15,
197+
'char' => 2,
198+
],
199+
],
200+
'file' => data_path('globals/simple.zep'),
201+
'line' => 5,
202+
'last-line' => 16,
203+
'char' => 16,
204+
],
205+
],
206+
'file' => data_path('globals/simple.zep'),
207+
'line' => 3,
208+
'char' => 5,
209+
],
210+
'file' => data_path('globals/simple.zep'),
211+
'line' => 3,
212+
'char' => 5,
213+
],
214+
];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Zephir\Parser\Tests;
4+
5+
class ParserGlobalsTest extends TestCase
6+
{
7+
/** @test */
8+
public function shouldProperlyParseGlobals()
9+
{
10+
$this->assertSame(expected('globals/simple.php'), $this->parseFile('globals/simple.zep'));
11+
}
12+
}

unit-tests/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| This source file is subject the MIT license, that is bundled with |
1010
| this package in the file LICENSE, and is available through the |
1111
| world-wide-web at the following url: |
12-
| http://zephir-lang.com/license.html |
12+
| https://zephir-lang.com/license.html |
1313
| |
1414
| If you did not receive a copy of the MIT license and are unable |
1515
| to obtain it through the world-wide-web, please send a note to |

0 commit comments

Comments
 (0)