Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Jun 26, 2015
2 parents 2158d51 + b2e5dfe commit bdaf23c
Show file tree
Hide file tree
Showing 65 changed files with 1,163 additions and 462 deletions.
16 changes: 16 additions & 0 deletions .php_cs
@@ -0,0 +1,16 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__);

return Symfony\CS\Config\Config::create()
->fixers(array(
'-concat_without_spaces',
'-empty_return',
'-new_with_braces',
'align_double_arrow',
'align_equals',
'ordered_use',
'short_array_syntax',
))
->finder($finder);
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,9 +1,9 @@
language: php

php: ["5.5", "5.6", "hhvm", "hhvm-nightly"]
php: ["5.5", "5.6", "7", "nightly", "hhvm", "hhvm-nightly"]

matrix:
allow_failures: [{"php": "hhvm"}, {"php": "hhvm-nightly"}]
allow_failures: [{"php": "nightly"}, {"php": "hhvm"}, {"php": "hhvm-nightly"}]
fast_finish: true

env:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Recoil Changelog

### 0.3.0 (2015-06-26)

* **[BC]** Removed `StrandInterface::resume()`
* **[NEW]** `return` statement can be used to return a value inside a coroutine (requires PHP 7)
* **[IMPROVED]** Improved method documentation on `Recoil` facade (thanks @rjkip)

### 0.2.1 (2014-10-16)

* **[IMPROVED]** Added support for cancellable promises
Expand Down
25 changes: 20 additions & 5 deletions README.md
Expand Up @@ -175,14 +175,15 @@ Recoil::run(

### Returning a value from a coroutine

Because PHP's `return` keyword can not be used to return a value inside a generator, the kernel API provides
`Recoil::return_()` to send a value to the calling coroutine. Just like `return`, execution of the coroutine stops when a
value is returned.
#### PHP 7

To return a value from a coroutine, simply use the `return` keyword as you would in a normal function.

```php
function multiply($a, $b)
{
yield Recoil::return_($a * $b);
yield Recoil::noop();
return $a * $b;
echo 'This code is never reached.';
}

Expand All @@ -194,6 +195,20 @@ Recoil::run(
);
```

#### PHP 5

Because the `return` keyword can not be used to return a value inside a generator before PHP version 7, the kernel API provides
`Recoil::return_()` to send a value to the calling coroutine. Just like `return`, execution of the coroutine stops when a
value is returned.

```php
function multiply($a, $b)
{
yield Recoil::return_($a * $b);
echo 'This code is never reached.';
}
```

### Throwing and catching exceptions

One of the major advantages made available by coroutines is that errors can be reported using familiar exception
Expand Down Expand Up @@ -305,4 +320,4 @@ $eventLoop->run();
<!-- references -->
[Build Status]: http://img.shields.io/travis/recoilphp/recoil/develop.svg?style=flat-square
[Test Coverage]: http://img.shields.io/coveralls/recoilphp/recoil/develop.svg?style=flat-square
[SemVer]: http://img.shields.io/:semver-0.2.1-yellow.svg?style=flat-square
[SemVer]: http://img.shields.io/:semver-0.3.0-yellow.svg?style=flat-square

0 comments on commit bdaf23c

Please sign in to comment.