Subversion Repositories oidplus

Rev

Rev 1127 | Rev 1133 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1127 Rev 1130
Line 156... Line 156...
156
        echo "Attention: No language plugins found!\n";
156
        echo "Attention: No language plugins found!\n";
157
}
157
}
158
 
158
 
159
# ---
159
# ---
160
 
160
 
-
 
161
/**
-
 
162
 * @param string $cont
-
 
163
 * @return string[]
-
 
164
 */
161
function get_js_L_strings($cont) {
165
function get_js_L_strings(string $cont): array {
162
        // Works with JavaScript and PHP
166
        // Works with JavaScript and PHP
163
        $cont = preg_replace('@/\\*.+\\*/@ismU', '', $cont);
167
        $cont = preg_replace('@/\\*.+\\*/@ismU', '', $cont);
164
        $cont = str_replace('\\"', chr(1), $cont);
168
        $cont = str_replace('\\"', chr(1), $cont);
165
        $cont = str_replace("\\'", chr(2), $cont);
169
        $cont = str_replace("\\'", chr(2), $cont);
166
        $cont = str_replace("\\\\", "\\", $cont);
170
        $cont = str_replace("\\\\", "\\", $cont);
Line 171... Line 175...
171
                $x = str_replace(chr(2), "'", $x);
175
                $x = str_replace(chr(2), "'", $x);
172
        }
176
        }
173
        return $m[3];
177
        return $m[3];
174
}
178
}
175
 
179
 
-
 
180
/**
-
 
181
 * @param string $cont
-
 
182
 * @return string[]
-
 
183
 */
176
function get_php_L_strings($cont) {
184
function get_php_L_strings(string $cont): array {
177
        // Works only with PHP
185
        // Works only with PHP
178
        $out = array();
186
        $out = array();
179
        $tokens = token_get_all($cont);
187
        $tokens = token_get_all($cont);
180
        $activated = 0;
188
        $activated = 0;
181
        foreach ($tokens as $token) {
189
        foreach ($tokens as $token) {
Line 190... Line 198...
190
                }
198
                }
191
        }
199
        }
192
        return $out;
200
        return $out;
193
}
201
}
194
 
202
 
-
 
203
/**
-
 
204
 * @param string $test
-
 
205
 * @return void
-
 
206
 */
195
function test_missing_placeholder($test) {
207
function test_missing_placeholder(string $test) {
196
        $max = -1;
208
        $max = -1;
197
        for ($i=99; $i>=1; $i--) {
209
        for ($i=99; $i>=1; $i--) {
198
                if (strpos($test, '%'.$i) !== false) {
210
                if (strpos($test, '%'.$i) !== false) {
199
                        $max = $i;
211
                        $max = $i;
200
                        break;
212
                        break;
Line 215... Line 227...
215
        }
227
        }
216
}
228
}
217
 
229
 
218
# ---
230
# ---
219
 
231
 
-
 
232
/**
-
 
233
 * @param string $fileStr
-
 
234
 * @return string
-
 
235
 */
220
function phpRemoveComments($fileStr) {
236
function phpRemoveComments(string $fileStr): string {
221
 
237
 
222
        // https://stackoverflow.com/questions/503871/best-way-to-automatically-remove-comments-from-php-code
238
        // https://stackoverflow.com/questions/503871/best-way-to-automatically-remove-comments-from-php-code
223
 
239
 
224
        $newStr  = '';
240
        $newStr  = '';
225
 
241