Пример #1
0
 /**
  * Gets the arity of a given callable.
  *
  * The arity of a callable is the min. number of required parameters.
  *
  * @param callable $callable
  * @return int
  */
 public static final function arity(callable $callable) : int
 {
     if ($callable instanceof AbstractCallable) {
         return $callable->getArity();
     }
     return Reflections::reflectionCallableOf($callable)->getNumberOfRequiredParameters();
 }
Пример #2
0
 /**
  * Constructs a new callable object from a given callable.
  *
  * @param callable $callable
  *            The given callable.
  */
 private function __construct(callable $callable, array $curryArgs = [])
 {
     if ($callable instanceof AbstractCallable) {
         $this->callable = $callable->getCallable();
         $this->reflector = Reflections::reflectionCallableOf($callable->getCallable());
     } else {
         $this->callable = $callable;
         $this->reflector = Reflections::reflectionCallableOf($callable);
     }
     $this->curryArgs = $curryArgs;
 }
Пример #3
0
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $predicate = NaryPredicate::create(self::getCallable());
     $this->assertEquals($reflector, $predicate->getReflector());
 }
Пример #4
0
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $functor = NaryFunktion::create(self::getCallable());
     $this->assertEquals($reflector, $functor->getReflector());
 }
Пример #5
0
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $consumer = UnaryConsumer::create(self::getCallable());
     $this->assertEquals($reflector, $consumer->getReflector());
 }
Пример #6
0
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $supplier = Supplier::create(self::getCallable());
     $this->assertEquals($reflector, $supplier->getReflector());
 }