Exemple #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();
 }
 /**
  * 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;
 }
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $predicate = NaryPredicate::create(self::getCallable());
     $this->assertEquals($reflector, $predicate->getReflector());
 }
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $functor = NaryFunktion::create(self::getCallable());
     $this->assertEquals($reflector, $functor->getReflector());
 }
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $consumer = UnaryConsumer::create(self::getCallable());
     $this->assertEquals($reflector, $consumer->getReflector());
 }
 public function testGetReflector()
 {
     $reflector = Reflections::reflectionCallableOf(self::getCallable());
     $supplier = Supplier::create(self::getCallable());
     $this->assertEquals($reflector, $supplier->getReflector());
 }