@@ -41,17 +41,9 @@ public static function isReserved(
4141 $ reservedArray = [];
4242
4343 if (Reserved::isReservedPrecededByDotCharacter ($ previous )) {
44- if (Reserved::isReservedString ($ string , $ matches , $ reservedTopLevel , $ boundaries )) {
45- $ reservedArray = Reserved::getReservedTopLevelString ($ string , $ matches );
46- }
47-
48- if (empty ($ reservedArray ) && Reserved::isReservedString ($ string , $ matches , $ reservedNewLine , $ boundaries )) {
49- $ reservedArray = Reserved::getReservedNewLineString ($ string , $ matches );
50- }
51-
52- if (empty ($ reservedArray ) && Reserved::isReservedString ($ string , $ matches , $ reserved , $ boundaries )) {
53- $ reservedArray = Reserved::getReservedString ($ string , $ matches );
54- }
44+ Reserved::getReservedTopLevelString ($ reservedArray , $ string , $ matches , $ reservedTopLevel , $ boundaries );
45+ Reserved::getReservedNewLineString ($ reservedArray , $ string , $ matches , $ reservedNewLine , $ boundaries );
46+ Reserved::getReservedString ($ reservedArray , $ string , $ matches , $ reserved , $ boundaries );
5547 }
5648
5749 return $ reservedArray ;
@@ -69,6 +61,27 @@ public static function isReservedPrecededByDotCharacter($previous)
6961 return !$ previous || !isset ($ previous [Tokenizer::TOKEN_VALUE ]) || $ previous [Tokenizer::TOKEN_VALUE ] !== '. ' ;
7062 }
7163
64+ /**
65+ * @param array $reservedArray
66+ * @param string $string
67+ * @param array $matches
68+ * @param $reservedTopLevel
69+ * @param $boundaries
70+ *
71+ * @return array
72+ */
73+ public static function getReservedTopLevelString (
74+ array &$ reservedArray ,
75+ $ string ,
76+ array &$ matches ,
77+ $ reservedTopLevel ,
78+ $ boundaries
79+ ) {
80+ if (empty ($ reservedArray ) && Reserved::isReservedString ($ string , $ matches , $ reservedTopLevel , $ boundaries )) {
81+ $ reservedArray = self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED_TOP_LEVEL , $ string , $ matches );
82+ }
83+ }
84+
7285 /**
7386 * @param string $upper
7487 * @param array $matches
@@ -86,17 +99,6 @@ public static function isReservedString($upper, array &$matches, $regexReserved,
8699 );
87100 }
88101
89- /**
90- * @param string $string
91- * @param array $matches
92- *
93- * @return array
94- */
95- public static function getReservedTopLevelString ($ string , array &$ matches )
96- {
97- return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED_TOP_LEVEL , $ string , $ matches );
98- }
99-
100102 /**
101103 * @param $type
102104 * @param string $string
@@ -113,24 +115,43 @@ protected static function getStringTypeArray($type, $string, array &$matches)
113115 }
114116
115117 /**
118+ * @param array $reservedArray
116119 * @param string $string
117120 * @param array $matches
121+ * @param $reservedNewLine
122+ * @param $boundaries
118123 *
119124 * @return array
120125 */
121- public static function getReservedNewLineString ($ string , array &$ matches )
122- {
123- return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED_NEWLINE , strtoupper ($ string ), $ matches );
126+ public static function getReservedNewLineString (
127+ array &$ reservedArray ,
128+ $ string ,
129+ array &$ matches ,
130+ $ reservedNewLine ,
131+ $ boundaries
132+ ) {
133+ if (empty ($ reservedArray ) && Reserved::isReservedString ($ string , $ matches , $ reservedNewLine , $ boundaries )) {
134+ $ reservedArray = self ::getStringTypeArray (
135+ Tokenizer::TOKEN_TYPE_RESERVED_NEWLINE ,
136+ strtoupper ($ string ),
137+ $ matches
138+ );
139+ }
124140 }
125141
126142 /**
127- * @param string $string
143+ * @param array $reservedArray
144+ * @param string $string
128145 * @param array $matches
146+ * @param $reserved
147+ * @param $boundaries
129148 *
130149 * @return array
131150 */
132- public static function getReservedString ($ string , array &$ matches )
151+ public static function getReservedString (array & $ reservedArray , $ string , array &$ matches, $ reserved , $ boundaries )
133152 {
134- return self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED , $ string , $ matches );
153+ if (empty ($ reservedArray ) && Reserved::isReservedString ($ string , $ matches , $ reserved , $ boundaries )) {
154+ $ reservedArray = self ::getStringTypeArray (Tokenizer::TOKEN_TYPE_RESERVED , $ string , $ matches );
155+ }
135156 }
136157}
0 commit comments