-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
19 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* * | ||
* Future CallableWrapper for php 5.3+ * | ||
* * | ||
* LastModified: Jul 11, 2016 * | ||
* LastModified: Mar 7, 2017 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
|
@@ -25,6 +25,9 @@ class CallableWrapper extends Wrapper { | |
public function __invoke() { | ||
$obj = $this->obj; | ||
return all(func_get_args())->then(function($args) use ($obj) { | ||
if (class_exists("\\Generator")) { | ||
return co(call_user_func_array($obj, $args)); | ||
} | ||
return call_user_func_array($obj, $args); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* * | ||
* Future Wrapper for php 5.3+ * | ||
* * | ||
* LastModified: Dec 9, 2016 * | ||
* LastModified: Mar 7, 2017 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
|
@@ -32,10 +32,7 @@ public function __call($name, array $arguments) { | |
$method = array($this->obj, $name); | ||
return all($arguments)->then(function($args) use ($method, $name) { | ||
if (class_exists("\\Generator")) { | ||
$m = new ReflectionMethod($this->obj, $name); | ||
if ($m->isGenerator()) { | ||
return co(call_user_func_array($method, $args)); | ||
} | ||
return co(call_user_func_array($method, $args)); | ||
} | ||
return call_user_func_array($method, $args); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* * | ||
* some helper functions for php 5.3+ * | ||
* * | ||
* LastModified: Dec 22, 2016 * | ||
* LastModified: Mar 7, 2017 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
|
@@ -210,21 +210,18 @@ function($args) use ($handler) { | |
); | ||
} | ||
|
||
function wrap($handler, $check_gen = true) { | ||
if (class_exists("\\Generator") && is_callable($handler)) { | ||
if( $check_gen ) | ||
{ | ||
if (is_array($handler)) { | ||
$m = new ReflectionMethod($handler[0], $handler[1]); | ||
} | ||
else { | ||
$m = new ReflectionFunction($handler); | ||
} | ||
if ($m->isGenerator()) { | ||
$check_gen = false; | ||
function wrap($handler) { | ||
if (is_object($handler)) { | ||
if (is_callable($handler)) { | ||
if (class_exists("\\Generator") && ($handler instanceof \Generator)) { | ||
return co($handler); | ||
} | ||
return new CallableWrapper($handler); | ||
} | ||
if(!$check_gen) { | ||
return new Wrapper($handler); | ||
} | ||
if (is_callable($handler)) { | ||
if (class_exists("\\Generator")) { | ||
return function() use ($handler) { | ||
return all(func_get_args())->then( | ||
function($args) use ($handler) { | ||
|
@@ -233,14 +230,6 @@ function($args) use ($handler) { | |
); | ||
}; | ||
} | ||
} | ||
if (is_object($handler)) { | ||
if (is_callable($handler)) { | ||
return new CallableWrapper($handler); | ||
} | ||
return new Wrapper($handler); | ||
} | ||
if (is_callable($handler)) { | ||
return function() use ($handler) { | ||
return all(func_get_args())->then( | ||
function($args) use ($handler) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* * | ||
* hprose service class for php 5.3+ * | ||
* * | ||
* LastModified: Feb 16, 2017 * | ||
* LastModified: Mar 7, 2017 * | ||
* Author: Ma Bingyao <[email protected]> * | ||
* * | ||
\**********************************************************/ | ||
|
@@ -608,7 +608,7 @@ public function addFunction($func, $alias = '', array $options = array()) { | |
$this->names[] = $alias; | ||
} | ||
if (class_exists("\\Generator")) { | ||
$func = Future\wrap($func, false); | ||
$func = Future\wrap($func); | ||
} | ||
$call = new stdClass(); | ||
$call->method = $func; | ||
|