Skip to content

Commit

Permalink
better example
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis committed Jun 10, 2018
1 parent a571b8d commit 6ed2a55
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@ hack2php is a project which aims to implement a compiler to translate Hack files
This ability becomes useful when you have no control over the environment in which your code is supposed to run, but you still want to write your code in Hack.
An example might be the development of WordPress plugins or themes.

This Hack code:
E.g. this Hack code:
```php
<?hh //strict

Expand All @@ -15,6 +15,14 @@ use codeneric\phmm\legacy\blub;
function blub(string $v): ?string {
return null;
}

function ano(): void {
$a = 42;
$arr = [1, 2, 3, 42, 5, 6];
$f = ($e) ==> {
return \in_array($a, $arr);
};
}
```

is transpiled to this PHP code:
Expand All @@ -27,6 +35,15 @@ use \codeneric\phmm\legacy\blub;
function blub($v){
return null;
}


function ano(){
$a = 42;
$arr = [1, 2, 3, 42, 5, 6];
$f = function ($e) use($a,$arr) {
return \in_array($a, $arr);
};
}
```


Expand Down

0 comments on commit 6ed2a55

Please sign in to comment.