MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
Lexer.php
Ir para a documentação deste ficheiro.
1
<?php
2
/*
3
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
*
15
* This software consists of voluntary contributions made by many individuals
16
* and is licensed under the LGPL. For more information, see
17
* <http://www.doctrine-project.org>.
18
*/
19
20
namespace
Doctrine\Common\Annotations
;
21
36
class
Lexer
extends
\Doctrine\Common\Lexer
37
{
38
const
T_NONE
= 1;
39
const
T_IDENTIFIER
= 2;
40
const
T_INTEGER
= 3;
41
const
T_STRING
= 4;
42
const
T_FLOAT
= 5;
43
44
const
T_AT
= 101;
45
const
T_CLOSE_CURLY_BRACES
= 102;
46
const
T_CLOSE_PARENTHESIS
= 103;
47
const
T_COMMA
= 104;
48
const
T_EQUALS
= 105;
49
const
T_FALSE
= 106;
50
const
T_NAMESPACE_SEPARATOR
= 107;
51
const
T_OPEN_CURLY_BRACES
= 108;
52
const
T_OPEN_PARENTHESIS
= 109;
53
const
T_TRUE
= 110;
54
58
protected
function
getCatchablePatterns
()
59
{
60
return
array(
61
'[a-z_][a-z0-9_:]*'
,
62
'(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?'
,
63
'"(?:[^"]|"")*"'
64
);
65
}
66
70
protected
function
getNonCatchablePatterns
()
71
{
72
return
array(
'\s+'
,
'\*+'
,
'(.)'
);
73
}
74
78
protected
function
getType
(&$value)
79
{
80
$type =
self::T_NONE
;
81
$newVal = $this->getNumeric($value);
82
83
// Checking numeric value
84
if
($newVal !==
false
) {
85
$value = $newVal;
86
87
return
(strpos($value,
'.'
) !==
false
|| stripos($value,
'e'
) !==
false
)
88
?
self::T_FLOAT
:
self::T_INTEGER
;
89
}
90
91
if
($value[0] ===
'"'
) {
92
$value = str_replace(
'""'
,
'"'
, substr($value, 1, strlen($value) - 2));
93
94
return
self::T_STRING
;
95
}
else
{
96
switch
(strtolower($value)) {
97
case
'@'
:
98
return
self::T_AT
;
99
100
case
','
:
101
return
self::T_COMMA
;
102
103
case
'('
:
104
return
self::T_OPEN_PARENTHESIS
;
105
106
case
')'
:
107
return
self::T_CLOSE_PARENTHESIS
;
108
109
case
'{'
:
110
return
self::T_OPEN_CURLY_BRACES
;
111
112
case
'}'
:
return
self::T_CLOSE_CURLY_BRACES
;
113
case
'='
:
114
return
self::T_EQUALS
;
115
116
case
'\\'
:
117
return
self::T_NAMESPACE_SEPARATOR
;
118
119
case
'true'
:
120
return
self::T_TRUE
;
121
122
case
'false'
:
123
return
self::T_FALSE
;
124
125
default
:
126
if
(ctype_alpha($value[0]) || $value[0] ===
'_'
) {
127
return
self::T_IDENTIFIER
;
128
}
129
130
break
;
131
}
132
}
133
134
return
$type;
135
}
136
144
private
function
getNumeric($value)
145
{
146
if
( ! is_scalar($value)) {
147
return
false
;
148
}
149
150
// Checking for valid numeric numbers: 1.234, -1.234e-2
151
if
(is_numeric($value)) {
152
return
$value;
153
}
154
155
return
false
;
156
}
157
}
Doctrine\Common\Annotations\Lexer
Definição
Lexer.php:37
Doctrine\Common\Annotations\Lexer\T_TRUE
const T_TRUE
Definição
Lexer.php:53
Doctrine\Common\Annotations\Lexer\T_NAMESPACE_SEPARATOR
const T_NAMESPACE_SEPARATOR
Definição
Lexer.php:50
Doctrine\Common\Annotations\Lexer\T_CLOSE_CURLY_BRACES
const T_CLOSE_CURLY_BRACES
Definição
Lexer.php:45
Doctrine\Common\Annotations\Lexer\T_FALSE
const T_FALSE
Definição
Lexer.php:49
Doctrine\Common\Annotations\Lexer\T_IDENTIFIER
const T_IDENTIFIER
Definição
Lexer.php:39
Doctrine\Common\Annotations\Lexer\T_STRING
const T_STRING
Definição
Lexer.php:41
Doctrine\Common\Annotations\Lexer\T_AT
const T_AT
Definição
Lexer.php:44
Doctrine\Common\Annotations\Lexer\T_INTEGER
const T_INTEGER
Definição
Lexer.php:40
Doctrine\Common\Annotations\Lexer\T_OPEN_PARENTHESIS
const T_OPEN_PARENTHESIS
Definição
Lexer.php:52
Doctrine\Common\Annotations\Lexer\getNonCatchablePatterns
getNonCatchablePatterns()
Definição
Lexer.php:70
Doctrine\Common\Annotations\Lexer\T_OPEN_CURLY_BRACES
const T_OPEN_CURLY_BRACES
Definição
Lexer.php:51
Doctrine\Common\Annotations\Lexer\getType
getType(&$value)
Definição
Lexer.php:78
Doctrine\Common\Annotations\Lexer\T_EQUALS
const T_EQUALS
Definição
Lexer.php:48
Doctrine\Common\Annotations\Lexer\T_COMMA
const T_COMMA
Definição
Lexer.php:47
Doctrine\Common\Annotations\Lexer\T_FLOAT
const T_FLOAT
Definição
Lexer.php:42
Doctrine\Common\Annotations\Lexer\getCatchablePatterns
getCatchablePatterns()
Definição
Lexer.php:58
Doctrine\Common\Annotations\Lexer\T_NONE
const T_NONE
Definição
Lexer.php:38
Doctrine\Common\Annotations\Lexer\T_CLOSE_PARENTHESIS
const T_CLOSE_PARENTHESIS
Definição
Lexer.php:46
Doctrine\Common\Lexer
Definição
Lexer.php:32
Doctrine\Common\Annotations
Definição
Annotation.php:22
classes
extensions
doctrine-dbal
Doctrine
Common
Annotations
Lexer.php
Gerado por
1.10.0