The fact that your variable is called $this
means that it can't be an ordinary array - that variable name is reserved for the current instance of a class.
Using square brackets to access an object is a sign that the class implements that ArrayAccess
interface - that is, it can be accessed using the operators normally reserved for basic arrays.
Retrieving a value from a class that implements ArrayAccess
using square bracket notation invokes the class's offsetGet
method, with the provided key as the $offset
argument. The most common use is to allow access to a class's member variables, but the class itself can choose to perform any action in this method.
In your case, I think you're looking at the Laravel application class, which will result in the router item being returned from the dependency injection container.