Skip to content

Commit 5d2207f

Browse files
committed
Use a strict return type for getNonAssignableReason
1 parent 64c19e1 commit 5d2207f

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

.codeclimate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ engines:
2121
- eb746d53b9a8dabef2c1041d8e37158d
2222
- ef7cef7244578b6906e8785db37f6f48
2323
# Allow 'is' method
24-
- 2ea85a0da934bbb59152f07507296053
24+
- ace61d689ad3cd8ba10c4f88c6d33768
2525
# Allow eval in unit tests
2626
- a766751f59d0dda7f074443addea8e6f
2727
ratings:

src/JsPhpize/Nodes/Assignable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44

55
interface Assignable
66
{
7+
/**
8+
* Returns false if assignable or the reason it's not as a string.
9+
*
10+
* @return false|string
11+
*/
712
public function getNonAssignableReason();
813
}

src/JsPhpize/Nodes/Assignation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class Assignation extends Value
2323

2424
public function __construct($operator, Assignable $leftHand, Node $rightHand)
2525
{
26-
if ($reason = $leftHand->getNonAssignableReason()) {
26+
$reason = $leftHand->getNonAssignableReason();
27+
28+
if ($reason !== false) {
2729
throw new Exception($reason, 9);
2830
}
2931

src/JsPhpize/Nodes/Constant.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ public function getNonAssignableReason()
3636
if (substr($this->value, 0, 2) === 'M_') {
3737
return "'M_' prefix is reserved to mathematical constants.";
3838
}
39+
40+
return false;
3941
}
4042
}

src/JsPhpize/Nodes/Variable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ public function setScope(Block $block)
3232

3333
public function getNonAssignableReason()
3434
{
35+
return false;
3536
}
3637
}

0 commit comments

Comments
 (0)