Skip to content

Commit

Permalink
fix: revert function parameter reference to avoid fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Jun 5, 2019
1 parent f5d71ae commit a9e201b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,13 @@ export function emitFile(
// emitModifiers(node, node.modifiers);
// emit(node.dotDotDotToken);

if (node.parent && [SyntaxKind.FunctionDeclaration, SyntaxKind.MethodDeclaration].includes(node.parent.kind)) {
const type = typeChecker.getTypeAtLocation(node.name);
const symbol = type.getSymbol();
if (type && type.flags === ts.TypeFlags.Object && symbol && !symbol.members.has('__call' as ts.__String)) {
write('&');
}
}
// if (node.parent && [SyntaxKind.FunctionDeclaration, SyntaxKind.MethodDeclaration].includes(node.parent.kind)) {
// const type = typeChecker.getTypeAtLocation(node.name);
// const symbol = type.getSymbol();
// if (type && type.flags === ts.TypeFlags.Object && symbol && !symbol.members.has('__call' as ts.__String)) {
// write('&');
// }
// }

emitNodeWithWriter(node.name, writeParameter);
// emit(node.questionToken);
Expand Down
2 changes: 1 addition & 1 deletion test/features/ArrayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$x = array( "u" => array() );
$v = count($x["u"]);
echo "<script>console.log(" . json_encode($x) . ");</script>";
function run(&$x) {
function run($x) {
\Ts2Php_Helper::arraySlice($x["y"], 1);
array_push($x["y"], 1);
}
2 changes: 1 addition & 1 deletion test/features/funcParamRefer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"a" => 1
);
$c = "123";
function aaa(&$m, &$n, $k, $d) {
function aaa($m, $n, $k, $d) {
array_push($m, 4);
$n["b"] = 2;
$k .= "4";
Expand Down

0 comments on commit a9e201b

Please sign in to comment.