diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-12-27 22:47:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-27 22:47:57 +0300 |
commit | 5ec276fb5123cf6b85c37fcb9024fb9fec86f737 (patch) | |
tree | 211772ce18b59ee1968d4979ffdb373b3743a324 | |
parent | 4951c18c0d6a46a680e64bb57c797c947b71197b (diff) | |
parent | c6f6f847f06eec80f6cfd29c5b7384b19468861a (diff) |
Run onyl when required
-rw-r--r-- | src/Visitor/PublicFunctionVisitor.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Visitor/PublicFunctionVisitor.php b/src/Visitor/PublicFunctionVisitor.php index 72c8dd3..22c2e59 100644 --- a/src/Visitor/PublicFunctionVisitor.php +++ b/src/Visitor/PublicFunctionVisitor.php @@ -74,14 +74,15 @@ class PublicFunctionVisitor extends NodeVisitorAbstract { if($className === 'JSONResponse') { $args = new Node\Arg(new Node\Expr\FuncCall(new Node\Name('json_encode'), $newNode->args)); $node->stmts[$key] = new Node\Stmt\Echo_([$args]); + + $arg = new Node\Arg(new Node\Scalar\String_('Content-Type:application/json; charset=utf-8')); + $header = new Node\Expr\FuncCall(new Node\Name('header'), [$arg]); + $node->stmts = $this->insertBeforeKey($node->stmts, $header, $key); + $arg = new Node\Arg(new Node\Scalar\String_('X-Content-Type-Options: nosniff')); + $header = new Node\Expr\FuncCall(new Node\Name('header'), [$arg]); + $node->stmts = $this->insertBeforeKey($node->stmts, $header, $key + 1); } - $arg = new Node\Arg(new Node\Scalar\String_('Content-Type:application/json; charset=utf-8')); - $header = new Node\Expr\FuncCall(new Node\Name('header'), [$arg]); - $node->stmts = $this->insertBeforeKey($node->stmts, $header, $key); - $arg = new Node\Arg(new Node\Scalar\String_('X-Content-Type-Options: nosniff')); - $header = new Node\Expr\FuncCall(new Node\Name('header'), [$arg]); - $node->stmts = $this->insertBeforeKey($node->stmts, $header, $key + 1); } } |