mirror of
https://github.com/danog/amp.git
synced 2025-01-22 13:21:16 +01:00
CallableFromMethod -> CallableMaker
This commit is contained in:
parent
448391531e
commit
0992eaea89
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Amp;
|
||||
|
||||
if (\PHP_VERSION_ID < 70100) {
|
||||
trait CallableFromMethod {
|
||||
trait CallableMaker {
|
||||
/** @var \ReflectionClass */
|
||||
private static $__reflectionClass;
|
||||
|
||||
@ -53,16 +53,16 @@ if (\PHP_VERSION_ID < 70100) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trait CallableFromMethod {
|
||||
trait CallableMaker {
|
||||
/**
|
||||
* @deprecated Use \Closure::fromCallable() directly instead of this method.
|
||||
* @deprecated Use \Closure::fromCallable() instead of this method in PHP 7.1.
|
||||
*/
|
||||
private function callableFromInstanceMethod(string $method): callable {
|
||||
return \Closure::fromCallable([$this, $method]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use \Closure::fromCallable() directly instead of this method.
|
||||
* @deprecated Use \Closure::fromCallable() instead of this method in PHP 7.1.
|
||||
*/
|
||||
private function callableFromStaticMethod(string $method): callable {
|
||||
return \Closure::fromCallable([self::class, $method]);
|
@ -5,7 +5,7 @@ namespace Amp;
|
||||
use Interop\Async\Loop;
|
||||
|
||||
final class Emitter implements Observable {
|
||||
use CallableFromMethod, Internal\Producer;
|
||||
use CallableMaker, Internal\Producer;
|
||||
|
||||
/**
|
||||
* @param callable(callable(mixed $value): Awaitable $emit): \Generator $emitter
|
||||
@ -13,7 +13,7 @@ final class Emitter implements Observable {
|
||||
* @throws \Error Thrown if the callable does not return a Generator.
|
||||
*/
|
||||
public function __construct(callable $emitter) {
|
||||
$result = $emitter($this->callableFromInstanceMethod('emit'));
|
||||
$result = $emitter($this->callableFromInstanceMethod("emit"));
|
||||
|
||||
if (!$result instanceof \Generator) {
|
||||
throw new \Error("The callable did not return a Generator");
|
||||
|
Loading…
x
Reference in New Issue
Block a user