Skip to content

Commit b2c60bd

Browse files
committed
Cleanup and coverage
1 parent 3b694c6 commit b2c60bd

File tree

14 files changed

+70
-60
lines changed

14 files changed

+70
-60
lines changed

examples/callback.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
a = b => b * 2;
2+
b = function (c, d, e) {
3+
return c + d(2) + e();
4+
};
5+
6+
return b(2, a, function () {
7+
return 8;
8+
});

examples/callback.return

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<testsuite name="badSyntaxes">
2626
<file>tests/badSyntaxes.php</file>
2727
<file>tests/badSwitchSyntaxes.php</file>
28+
<file>tests/badKeywordSyntaxes.php</file>
2829
<file>tests/unexpectedTokens.php</file>
2930
<file>tests/unexpectedTokensInBrackets.php</file>
3031
<file>tests/unexpectedTokensInHooks.php</file>

src/JsPhpize/Compiler/Compiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function ($pair) use ($visitNode, $indent) {
127127
)));
128128
}
129129

130-
protected function visitConstant(Constant $constant, $indent)
130+
protected function visitConstant(Constant $constant)
131131
{
132132
$value = $constant->value;
133133
if ($constant->type === 'string' && substr($constant->value, 0, 1) === '"') {

src/JsPhpize/Lexer/Scanner.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public function scanConstant($matches)
3838
return $this->token('constant', $constant);
3939
}
4040

41-
public function scanFunction($matches)
42-
{
43-
return $this->valueToken('function', $matches);
44-
}
45-
4641
public function scanKeyword($matches)
4742
{
4843
return $this->valueToken('keyword', $matches);

src/JsPhpize/Nodes/Assignation.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public function __construct($operator, Assignable $leftHand, Node $rightHand)
2727
throw new Exception($leftHand->getNonAssignableReason(), 9);
2828
}
2929

30-
$rightHand->mustBeAssignable();
31-
3230
$this->operator = $operator;
3331
$this->leftHand = $leftHand;
3432
$this->rightHand = $rightHand;

src/JsPhpize/Nodes/Block.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ public function needParenthesis()
8888

8989
public function addInstructions($instructions)
9090
{
91-
if (!$this->handleInstructions()) {
92-
throw new Exception($this->type . ' blocks cannot contains instructions.', 17);
93-
}
94-
9591
$instructions = is_array($instructions) ? $instructions : func_get_args();
9692
if (count($instructions)) {
9793
if (!$this->inInstruction) {
@@ -116,10 +112,6 @@ public function endInstruction()
116112

117113
public function setValue(Value $value)
118114
{
119-
if ($this->needParenthesis() && !($value instanceof Parenthesis)) {
120-
throw new Exception($this->type . ' blocks need to be followed by a parenthesis.', 18);
121-
}
122-
123115
if ($this->type === 'for') {
124116
$value->setSeparator(';');
125117
}

src/JsPhpize/Nodes/BracketsArray.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ class BracketsArray extends ArrayBase
66
{
77
public function addItem(Constant $key, Node $value)
88
{
9-
$value->mustBeAssignable();
10-
119
$this->data[] = array($key, $value);
1210
}
1311
}

src/JsPhpize/Nodes/Instruction.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ class Instruction extends Node
1313

1414
public function add($instruction)
1515
{
16-
if (!is_object($instruction)) {
17-
throw new Exception('An instance of Assignation or Value was expected, ' . gettype($instruction) . ' value type given.', 10);
18-
}
19-
20-
if (!$instruction instanceof Value
21-
&& !$instruction instanceof Block) {
22-
throw new Exception('An instance of Block or Value was expected, ' . get_class($instruction) . ' instance given.', 10);
23-
}
24-
2516
$this->instructions[] = $instruction;
2617
}
2718
}

src/JsPhpize/Nodes/Node.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,4 @@ public function __get($name)
1010
{
1111
return $this->$name;
1212
}
13-
14-
public function mustBeAssignable()
15-
{
16-
if (!($this instanceof Value) && (!($this instanceof Block) || $this->type !== 'function')) {
17-
throw new Exception('Only Value instance or Function block could be assigned.', 19);
18-
}
19-
}
2013
}

0 commit comments

Comments
 (0)