Skip to content

Commit 5be031a

Browse files
committed
Let Statement renders string with a comma at the end.
1 parent e2f87a9 commit 5be031a

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
lines changed

CHANGELOG.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ CHANGELOG
44
Version 2.0.x
55
-----------------
66

7-
MethodCall
7+
MethodCallExpr
88

9-
- Changed `MethodCall` default object name from `this` to `$this`. be sure to create MethodClass with '$this'
9+
- `MethodCall` is now removed.
10+
- Changed `MethodCallExpr` default object name from `this` to `$this`. be sure to create MethodClass with '$this'
1011
- Improve argument exporting.
12+
- Renamed `MethodCallExpr` to `MethodCallExpr`
13+
14+
Statement
15+
16+
- `Statement` class now render the content with a comma at the end.
17+
18+
Line
19+
20+
- `Line` class was added to provide indentation operation.
21+
1122

1223
Version 1.4.5
1324
-----------------

src/ClassTemplate/MethodCallExpr.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use ClassTemplate\Raw;
66
use LogicException;
77

8-
class MethodCall extends Statement implements Renderable
8+
class MethodCallExpr implements Renderable
99
{
1010
public $objectName;
1111

src/ClassTemplate/NewObjectExpr.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use ClassTemplate\Raw;
66
use LogicException;
77

8-
class NewObjectExpr extends Statement implements Renderable
8+
class NewObjectExpr implements Renderable
99
{
1010
public $className;
1111

src/ClassTemplate/Statement.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
namespace ClassTemplate;
33
use ClassTemplate\Renderable;
44

5-
abstract class Statement extends Line {
5+
class Statement extends Line
6+
{
7+
public $expr;
8+
9+
public function __construct(Renderable $expr) {
10+
$this->expr = $expr;
11+
}
12+
13+
public function render() {
14+
return $this->expr->render() . ';';
15+
}
616

717
}
818

Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
22
use ClassTemplate\Raw;
33

4-
class MethodCallTest extends PHPUnit_Framework_TestCase
4+
class MethodCallExprTest extends PHPUnit_Framework_TestCase
55
{
6-
function test()
6+
public function test()
77
{
8-
$call = new ClassTemplate\MethodCall;
8+
$call = new ClassTemplate\MethodCallExpr;
99
$call->method('doSomething');
1010
$call->addArgument(123);
1111
$call->addArgument('foo');
1212
$call->addArgument(new Raw('new SplObjectStorage'));
1313
$call->addArgument(array( 'name' => 'hack' ));
1414
$str = $call->render();
1515
ok($str);
16-
is("\$this->doSomething(123, 'foo', new SplObjectStorage, array (\n 'name' => 'hack',\n));",$str);
16+
is("\$this->doSomething(123, 'foo', new SplObjectStorage, array (\n 'name' => 'hack',\n))",$str);
1717
}
1818
}
1919

0 commit comments

Comments
 (0)