Skip to content

Commit

Permalink
add global namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Feb 21, 2019
1 parent 727c196 commit 766f831
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ export function emitFile(sourceFile: SourceFile, state: CompilerState) {
}

function emitTypeOfExpression(node: ts.TypeOfExpression) {
writePunctuation('Ts2Php_Helper::typeof(');
writePunctuation('\\Ts2Php_Helper::typeof(');
emitExpression(node.expression);
writePunctuation(')');
}
Expand Down
4 changes: 2 additions & 2 deletions src/features/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const map = {
indexOf: method('array_search', false, 1, true),
join: method('join', false, 1, true),
filter: method('array_filter', true, 1),
slice: method('Ts2Php_Helper::arraySlice', true, 2)
slice: method('\\Ts2Php_Helper::arraySlice', true, 2)
};

const api = {
isArray: method('Ts2Php_Helper::isPlainArray', false, 1)
isArray: method('\\Ts2Php_Helper::isPlainArray', false, 1)
};

export default {
Expand Down
4 changes: 2 additions & 2 deletions src/features/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function replace(node: CallExpression, {getLiteralTextOfNode, emitExpressionList
const expNode = node.expression as PropertyAccessExpression;

let nodeList = [...node.arguments, expNode.expression];
let method = 'Ts2Php_Helper::str_replace_once';
let method = '\\Ts2Php_Helper::str_replace_once';

if (isRegularExpressionLiteral(node.arguments[0])) {
method = 'preg_replace';
Expand Down Expand Up @@ -59,7 +59,7 @@ const map = {
trimLeft: method('ltrim'),
toUpperCase: method('strtoupper'),
toLowerCase: method('strtolower'),
slice: method('Ts2Php_Helper::str_slice', true, 2),
slice: method('\\Ts2Php_Helper::str_slice', true, 2),
indexOf: method('strpos', true, 1),
substr: method('substr', true, 2),
substring: method('substr', true, 2),
Expand Down

0 comments on commit 766f831

Please sign in to comment.