I can not understand the ::get
in thinkphp
and laravel
,I can find the Session::get
or the self::get
.So Is the ::get
is the function? I use the phpstorm
but I can not find the definition of that . it is the meaning of "::get
" but not the symbol of "::
"
Asked
Active
Viewed 74 times
0

bruceherring
- 35
- 6
-
Can you show an example of where it is used. – Nigel Ren Jun 28 '21 at 06:34
1 Answers
1
You'll have to educate yourself on Laravel's use of Facades when you call Session::get(), by default you Laravel will actually give you an instance of the Illuminate\Session\Store::class which is where you will find the ::get() method you are looking for.
When using PHPStorm it is only going to take you the Facade, not the concrete implementation that you are actually working with.
This is very common in Laravel, it'll take a bit of time for you to figure out which classes your actually working with, but diving into the framework will help you understand these things.
The Self::get() you are referring to looks to be Model class, which inherits the Illuminate\Database\Eloquent\Model::class

Azeame
- 2,322
- 2
- 14
- 30
-
2I think the point of confusion in the question as written (and comments) is not knowing what static methods are and how to call them; if you answer the question this should be addressed. – AD7six Jun 28 '21 at 06:42
-
I'd beg to differ, he's using PHPStorm and he's trying to click through the Session::get() to get it's implementation but it's only taking him the the Facade class which never mentions the actual class that Laravel instantiates during runtime. – Azeame Jun 28 '21 at 06:46
-
2There is for sure a Laravel element here but see for example [this comment](https://stackoverflow.com/questions/68158244/how-to-find-the-get-in-php-or-its-framwork/68158585?noredirect=1#comment120462289_68158325). If unclear, I’m suggesting you address this simply by pointing to any reference about static php methods in the answer. – AD7six Jun 28 '21 at 06:48