zephir cannot support this and use in the closures

my php code is :

/**
  * 执行管道工序响应结果
  *
  * @param callable $calEnd
  * @since 2018.01.03
  * @return void
  */
 public function then(callable $calEnd = null)
 {
     $arrStage = $this->arrStage;
     if ($calEnd) {
         $arrStage[] = $calEnd;
     }
     $this->objGenerator = $this->stageGenerator($arrStage);

     $this->traverseGenerator(...$this->arrPassed);
 }

 /**
  * 遍历迭代器
  *
  * @since 2018.01.03
  * @return void
  */
 protected function traverseGenerator() {
     if(! $this->objGenerator->valid() || $this->objGenerator->next() || ! $this->objGenerator->valid()) {
        return;
     }

     $aArgs = func_get_args();
     array_unshift($aArgs, function() {
         $this->traverseGenerator(...func_get_args());
     });

     $this->objGenerator->current()(...$aArgs);
 }

 /**
  * 工序迭代器
  * 添加一个空的迭代器,第一次迭代 next 自动移除
 *
 * @param array $arrStage
  * @return \Generator
  */
 protected function stageGenerator(array $arrStage) {
    array_unshift($arrStage, null);

    foreach ($arrStage as $mixStage) {
       yield $this->stageCallback($mixStage);
    }
}

my zephir code is

/**
 * 执行管道工序响应结果
 *
 * @param callable $calEnd
 * @since 2018.01.03
 * @return void
 */
public function then(var calEnd = null)
{
    var arrStage;

    let arrStage = this->arrStage;
    if (calEnd) {
        if ! is_callable(calEnd) {
            throw new InvalidArgumentException("Pipeline then must be a callable.");
        }
        let arrStage[] = calEnd;
    } 
    let this->objGenerator = this->stageGenerator(arrStage);

    call_user_func_array([this, "traverseGenerator"], this->arrPassed);
}

/**
 * 遍历迭代器
 *
 * @since 2018.01.03
 * @return void
 */
public function traverseGenerator() {
    var aArgs, calCurrent;

    if ! this->objGenerator->valid() || this->objGenerator->next() || ! this->objGenerator->valid() {
       return;
    }

    let aArgs = func_get_args();

    // zephir 闭包不支持 this
    // 从服务容器中读取 pipeline,单一实例
    // 违背了面向对象,方法为 public 才能够访问到,但是找不到其它办法
    array_unshift(aArgs, function() {
        var thisPipeline;

        let thisPipeline = app("pipeline");

        call_user_func_array([thisPipeline, "traverseGenerator"], func_get_args());
    });

    let calCurrent = this->objGenerator->current();
    call_user_func_array(calCurrent, aArgs);
}

/**
 * 工序迭代器
 * 添加一个空的迭代器,第一次迭代 next 自动移除
 * zephir 不支持 yield,用集合替代
 *
 * @param array $arrStage
 * @return \queryyetsimple\support\collection
 */
protected function stageGenerator(array arrStage) {
    var mixStage;

    array arrTemp = [];
    array_unshift(arrStage, null);
    for mixStage in arrStage {
        let arrTemp[] = this->stageCallback(mixStage);
    }

    return new collection(arrTemp);
}

i want code is :

 array_unshift(aArgs, function() {
        call_user_func_array([this, "traverseGenerator"], func_get_args());
    });

or

    let objThis = this;
    array_unshift(aArgs, function() use(objThis) {
        call_user_func_array([objThis, "traverseGenerator"], func_get_args());
    });

Is there any plan to surpport this.

7.1 Closure::fromCallable is very useful

/**
 * 遍历迭代器
 *
 * @since 2018.01.03
 * @return void
 */
public function traverseGenerator() {
    var aArgs, calCurrent, calNext;

    if ! this->objGenerator->valid() || this->objGenerator->next() || ! this->objGenerator->valid() {
       return;
    }

    let aArgs = func_get_args();

    let calNext = Closure::fromCallable([this, "makeNextClosure"]);

    array_unshift(aArgs, calNext);

    let calCurrent = this->objGenerator->current();
    call_user_func_array(calCurrent, aArgs);
}

/**
 * 下一次迭代执行回调
 *
 * @since 2018.01.12
 * @return void
 */
protected function makeNextClosure() {
    call_user_func_array([this, "traverseGenerator"], func_get_args());
}
edited Jan '18

use : <?php

  class ClosureUse 
  {
      protected $closures;
      protected $args = [];

      public function __construct (Closure $closures, array $args = []) {
          $this->closures = $closures;
          $this->args = $args;
      }

      public function __invoke() {
          $args = func_get_args();

          if ($this->args) {
              foreach ($this->args as $item) {
                  $args[] = $item;
              }
          }

          return call_user_func_array($this->closures, $args);
      }
  }

  class foo {

        public function bar(Closure $closures)
        {  
              return Closure::fromCallable(new ClosureUse(function($container){
                  $args = func_get_args();
                  $closures = $args[1];  
              },[$closures]));

              //return function ($container) use($closures) {
              //};
        }
    }

class ClosureUse {

      protected closures;

      protected args = [];

      public function __construct (<Closure> closures, array args = []) -> void
      {
          let this->closures = closures;
          let this->args = args;
      }

      public static function make(<Closure> closures, array args = []) -> <Closure>
      {
          var newclosure;
          let newclosure = new self(closures, args);
          return Closure::fromCallable([newclosure, "invoke"]);
      }

      protected function invoke() 
      {
          var args = [], item;

          let args = func_get_args();

          if this->args {
              for item in this->args {
                  let args[] = item;
              }
          }

          return call_user_func_array(this->closures, args);
      }
  }

 return ClosureUse::make(function($container){
        $args = func_get_args();
        $closures = $args[1];  
        $closures($container);

    }, [$closures]);