-2

I found the following method and I don't know what the static keyword does at that point. The variable is initialized with [] so it's empty anytime the method is called anyways.

What does the static keyword do at this point?

public function getSomething($entity)
{
    static $collection = [];
    if (!$collection[$entity->getPrimaryKey()]) {
        $collection[$entity->getPrimaryKey()] = 'something';
    }

    return $this->doCollection($collection);
}
Daniel W.
  • 31,164
  • 13
  • 93
  • 151

1 Answers1

-2

declaring properties or methods as static allows you to access them without needing to instantiate the class.

Alaindeseine
  • 3,260
  • 1
  • 11
  • 21