Skip to content

Commit

Permalink
feat: support simple class (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Mar 13, 2019
1 parent f338ca1 commit 9df494a
Show file tree
Hide file tree
Showing 9 changed files with 462 additions and 348 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ts2php

> under development
typescript 转 php

## usage
Expand Down Expand Up @@ -149,6 +151,47 @@ do {
} while (!$a);
```

#### `Class`/

```javascript
class Article {

public title: string;
id: number;

private _x: number;

static published = [];

constructor(options: {title: string}) {
this.title = options.title;
this.publish(1);
}

private publish(id) {
Article.published.push(id);
}
}
```

output

```php
class Article {
public $title;
$id;
private $_x;
static $published = array();
constructor($options) {
$this->title = $options["title"];
$this->publish(1);
}
private publish($id) {
array_push(Article::$published, $id);
}
}
```

#### `typeof`

> 由于 php 中没有 `undefined` 关键字,故不支持返回 `undefined`
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts2php",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "dist/index.js",
"typings": "types/index.d.ts",
Expand Down
Loading

0 comments on commit 9df494a

Please sign in to comment.