| Subject | Details |
| :------------- | :---------------------------------------------------------------------------- |
| Issue type | Feature request |
| Plugin | Php Inspections (EA Extended) or Php Inspections (EA Ultimate), any version |
| Language level | e.g. PHP 5.4 |
no behaviour
if anonymous function doesn't use $this suggest to make it static, for example
from this
$this->app->bind($repository, function () use ($entity) {
return \EntityManager::getRepository($entity);
});
to this
$this->app->bind($repository, static function () use ($entity) {
return \EntityManager::getRepository($entity);
});
Wow! I even know that it is possible. haha
It have some performance advantage?
@rentalhost propaply yes, have not tested yet :smile:
I did a local test, and it speed up ~13%, which make this feature a good catch for me. 馃槃
Holy shit, how this possible at all. I mean since which PHP version?
@kalessil since php 5.4 see docs
Thank you, @vladyslavstartsev. Will check docs for side-effects.
Hello all! This is a neat idea, but keep in mind that static closures cannot be used in all the same situations that non-static closures can. E.g.:
$o = new \stdClass();
$c = static function () { };
$d = $c->bindTo($o);
This gives a warning: "Cannot bind an instance to a static closure", but this would be valid if $c were not marked static.
Implemented!
@kwvanderlinde: confirmed, let's wait for first bug-reports and only then handle the false-positive.
Most helpful comment
Hello all! This is a neat idea, but keep in mind that static closures cannot be used in all the same situations that non-static closures can. E.g.:
This gives a warning: "Cannot bind an instance to a static closure", but this would be valid if
$cwere not markedstatic.