-
-
Notifications
You must be signed in to change notification settings - Fork 467
/
Copy pathconstants.zep
145 lines (111 loc) · 2.7 KB
/
constants.zep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
namespace Stub;
class Constants extends ConstantsParent
{
const C1 = null;
const C2 = false;
const C3 = true;
const C4 = 10;
const C5 = 10.25;
const C5_SELF = self::C5;
const C5_BY_NAME = Constants::C5;
const C6 = "test";
const className = __CLASS__;
const STD_PROP_LIST = \ArrayObject::STD_PROP_LIST;
/** Test Issue 1571 */
const DEFAULT_PATH_DELIMITER = ".";
const PROPERTY_WITH_VARS = "$SOME/CSRF/KEY$";
/**
* Test property addSlashes for constants
*/
const ANNOTATION_REGEX = '/@(\w+)(?:\s*(?:\(\s*)?(.*?)(?:\s*\))?)??\s*(?:\n|\*\/)/';
const PARAMETER_REGEX = '/(\w+)\s*=\s*(\[[^\]]*\]|"[^"]*"|[^,)]*)\s*(?:,|$)/';
protected propWsVarsAssigned = "$SOME/CSRF/KEY$";
protected propWsVarsGet = self::PROPERTY_WITH_VARS {get};
protected propertyC1 = self::C1 {get};
protected propertyC2 = self::C2 {get};
protected propertyC3 = self::C3 {get};
protected propertyC4 = self::C4 {get};
protected propertyC5 = self::C5 {get};
protected propertyC6 = self::C6 {get};
protected propertyC7 = self::ANNOTATION_REGEX {get};
protected propertyC8 = self::PARAMETER_REGEX {get};
// Do not modify annotation bellow
// See:
// https://github.com/phalcon/php-zephir-parser/issues/13
// https://github.com/phalcon/cphalcon/pull/11212/files
/**
* @var \Phalcon\Cache\FrontendInterface
*/
protected propertyC9 = "some-value" {get};
public function testReadConstant()
{
return ENT_QUOTES;
}
public function testReadClassConstant1()
{
return Constants::C4;
}
public function testReadClassConstant2()
{
return self::C4;
}
public function testReadClassConstant3()
{
return parent::P4;
}
public function testPHPVersionEnvConstant()
{
return PHP_VERSION;
}
public function testClassMagicConstant()
{
return __CLASS__;
}
public function testMethodMagicConstant()
{
return __METHOD__;
}
public function testFunctionMagicConstant()
{
return __FUNCTION__;
}
public function testNamespaceMagicConstant()
{
return __NAMESPACE__;
}
public function testDirConstant()
{
return __DIR__;
}
public function testPHPVersionEnvConstantInExpValue()
{
var a;
let a = PHP_VERSION;
return a;
}
/**
* Test Delimiters as String Constants
*
* @link https://github.com/zephir-lang/zephir/issues/1571
*/
public function testStringDelimiterConstantDoubleQuoted()
{
var delimiter;
let delimiter = Constants::DEFAULT_PATH_DELIMITER;
return delimiter;
}
public function testStringConstantWithVars()
{
var property;
let property = Constants::PROPERTY_WITH_VARS;
return property;
}
public function testStringPropertyWithVarsAssigned()
{
return this->propWsVarsAssigned;
}
public function testStringPropertyWithVarsGet()
{
return this->propWsVarsGet;
}
}