title: How to pass argument in callback function in php?
body: <p>I have Repository class with a method as follows: </p>
  
  <pre><code>public function GetOne($id){
      $method = __METHOD__;
      $post = null;
  
  
      $post = $this-&gt;CacheManager($method, function($id) {
          return DB::select("select * from posts where id = ?", [$id]);
      });
  
      return $post;
  }
  </code></pre>
  
  <p>I want to cache the result, but in the closure/callback function the $id parameter is not working. The CacheManager is a trait where I'm using it in my repository. </p>
  
  <pre class="lang-php prettyprint-override"><code>public function CacheManager($method, $fn) {
    $obj = null;
  
    if(!$this-&gt;HasCache($method)){
      $obj = $fn();
    }else {
      $obj = $this-&gt;GetCache($method);
    }
  
    return $obj;
  }
  </code></pre>
  
  
  
  <p>I have some other methods without parameters and they're working as intended. </p>