Skip to content

Commit

Permalink
fix: use -> namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Feb 21, 2019
1 parent 18505cd commit e51ee85
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function emitFile(sourceFile: SourceFile, state: CompilerState) {
state.sourceFile = sourceFile;

if (state.emitHeader) {
writer.write(`<?php\nuse ${state.namespace};\n`);
writer.write(`<?php\nnamespace ${state.namespace};\n`);
}

ts.forEachChild(sourceFile, (node: ts.Node) => {
Expand Down
6 changes: 3 additions & 3 deletions test/features/ArrayApi.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ArrayApi;
namespace test\ArrayApi;
$a = count(array(1));
$b = array(1, "a");
$c = count($b);
Expand All @@ -14,8 +14,8 @@
$g = array_filter($b, function ($value, $index) {
return $value;
});
$t = Ts2Php_Helper::isPlainArray($a);
$t = \Ts2Php_Helper::isPlainArray($a);
function process($x) {
Ts2Php_Helper::arraySlice($x["y"], 1);
\Ts2Php_Helper::arraySlice($x["y"], 1);
array_push($x["y"], 1);
}
2 changes: 1 addition & 1 deletion test/features/ArrayLiteralExpression.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
use test\ArrayLiteralExpression;
namespace test\ArrayLiteralExpression;
$b = 4;
$a = array(1, 2, 3, $b);
2 changes: 1 addition & 1 deletion test/features/ComputedPropertyName.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ComputedPropertyName;
namespace test\ComputedPropertyName;
$a = "aaa";
$b = "bbb";
$c = array(
Expand Down
2 changes: 1 addition & 1 deletion test/features/ConditionalExpression.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
use test\ConditionalExpression;
namespace test\ConditionalExpression;
$a = $b ? 1 : 2;
2 changes: 1 addition & 1 deletion test/features/ForStatement.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ForStatement;
namespace test\ForStatement;
$b = 1;
for ($i = 0; $i < 10; $i++) {
$b += 10;
Expand Down
2 changes: 1 addition & 1 deletion test/features/FunctionDeclaration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\FunctionDeclaration;
namespace test\FunctionDeclaration;
function aaa($a, $b, $c) {
$d = 123;
$e = $b . 123;
Expand Down
6 changes: 3 additions & 3 deletions test/features/GlobalApi.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
use test\GlobalApi;
namespace test\GlobalApi;
$a = intval("1.2");
$b = floatval("1.2");
$c = Ts2Php_Helper::typeof($a);
$d = Ts2Php_Helper::typeof($c) === "string";
$c = \Ts2Php_Helper::typeof($a);
$d = \Ts2Php_Helper::typeof($c) === "string";
$e = array( "a" => 1, "b" => 2 );
unset($e["a"]);
2 changes: 1 addition & 1 deletion test/features/IfStatement.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\IfStatement;
namespace test\IfStatement;
$a = true;
if ($a) {
$b = 456;
Expand Down
2 changes: 1 addition & 1 deletion test/features/Math.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
use test\Math;
namespace test\Math;
$a = max(1, 2);
2 changes: 1 addition & 1 deletion test/features/NumberApi.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\NumberApi;
namespace test\NumberApi;
$a = 12.44;
$b = round($a, 1);
$c = round(($a + 1), 1);
Expand Down
2 changes: 1 addition & 1 deletion test/features/ObjectJSON.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ObjectJSON;
namespace test\ObjectJSON;
$a = array_merge(array(), array( "a" => 1 ));
$b = array_keys($a);
$c = $a;
Expand Down
2 changes: 1 addition & 1 deletion test/features/ObjectLiteralExpression.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ObjectLiteralExpression;
namespace test\ObjectLiteralExpression;
$b = array(
"a" => 123,
"b" => "456"
Expand Down
2 changes: 1 addition & 1 deletion test/features/Rest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\Rest;
namespace test\Rest;
$tplData = array( "a" => 1 );
$difftime = isset($tplData["difftime"]) ? $tplData["difftime"] : 8;
$a = $tplData["a"];
Expand Down
2 changes: 1 addition & 1 deletion test/features/ShorthandPropertyAssignment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\ShorthandPropertyAssignment;
namespace test\ShorthandPropertyAssignment;
$b = 2;
$c = 1;
$a = array(
Expand Down
2 changes: 1 addition & 1 deletion test/features/SwitchStatement.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\SwitchStatement;
namespace test\SwitchStatement;
$b = 2;
$c = 1;
switch ($b) {
Expand Down
2 changes: 1 addition & 1 deletion test/features/WhileStatement.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\WhileStatement;
namespace test\WhileStatement;
while (!$a) {
$b = 2;
}
2 changes: 1 addition & 1 deletion test/features/addDollar.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\addDollar;
namespace test\addDollar;
$a = "123";
$b = array();
$b[$a] = 123;
2 changes: 1 addition & 1 deletion test/features/elementAccessExpression.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\elementAccessExpression;
namespace test\elementAccessExpression;
$a = "aaa";
$tplData[$a] = 123;
$tplData[$a . "123"] = 123;
2 changes: 1 addition & 1 deletion test/features/export.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\export;
namespace test\export;
function process($a) {
$a = "111";
var_dump($a);
Expand Down
2 changes: 1 addition & 1 deletion test/features/import.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\import;
namespace test\import;
require_once("/home/work/search/view-ui/atom/plugins/aladdin/Atom_Wise_Utils.php");
$tplData = array();
$tplData["src"] = \Atom_Wise_Utils::makeTcLink("url");
Expand Down
6 changes: 3 additions & 3 deletions test/features/stringProto.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
use test\stringProto;
namespace test\stringProto;
$a = "wwa";
$b = Ts2Php_Helper::str_replace_once("a", "b", $a);
$b = \Ts2Php_Helper::str_replace_once("a", "b", $a);
$c = array( "s" => "aaa" );
$d = Ts2Php_Helper::str_replace_once("a", "b", $c["s"]);
$d = \Ts2Php_Helper::str_replace_once("a", "b", $c["s"]);
$f = preg_replace("/w/", "b", $a);
$e = preg_replace("/w/", "b", $a, 1);
$g = trim($a);
Expand Down
2 changes: 1 addition & 1 deletion test/features/template.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
use test\template;
namespace test\template;
$b = "123";
$c = "0" . $b . "45'6'\"789\"";
$s = "1" . $b . "2" . $b . "3" . $b . "4";
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('features', () => {

it('compile code', function () {
let res = compileCode('var a = 1;');
assert.equal(res.phpCode, '<?php\nuse 509b568a;\n$a = 1;\n');
assert.equal(res.phpCode, '<?php\nnamespace 509b568a;\n$a = 1;\n');
});
});

0 comments on commit e51ee85

Please sign in to comment.