Php 不要将$this传递到匿名函数的作用域中

Php 不要将$this传递到匿名函数的作用域中,php,Php,有没有办法不将类传递给匿名函数 class Foo{ public function bar(){ $data = [ 'calculation' => function(){ // I don't want $this to be passed into here } ]; } } 我可以从该匿名函数中排除$this吗?如果您不需要$this的值,则需要一个 class Foo{ public f

有没有办法不将类传递给匿名函数

class Foo{

  public function bar(){
     $data = [
        'calculation' => function(){
           // I don't want $this to be passed into here
        }
     ];
  }
}

我可以从该匿名函数中排除$this吗?

如果您不需要
$this
的值,则需要一个

class Foo{

  public function bar(){
     $data = [
        'calculation' => function(){
           // I don't want $this to be passed into here
        }
     ];
  }
}
静态匿名函数没有自动绑定的
$this
值,以后也不能绑定其他值