Is there any way to get rid of this annoying PhpStorm warning:
Member has private access, but class has magic method __get
Thank you!
Magic methods are special methods in python that have double underscores (dunder) on both sides of the method name. Magic methods are predominantly used for operator overloading.
__get() is utilized for reading data from inaccessible properties.
The __invoke method is a way that PHP can accommodate pseudo-first-class functions. The __invoke method can be used to pass a class that can act as a closure or a continuation, or simply as a function that you can pass around. A lot of functional programming relies on first class functions.
Magic methods in PHP are special methods that are aimed to perform certain tasks. These methods are named with double underscore (__) as prefix. All these function names are reserved and can't be used for any purpose other than associated magical functionality. Magical method in a class must be declared public.
You can turn off warnings for magically accessing properties in the following way:
I am not entirely sure if this will also hide the warning in your case, for accessing private members. If not, you could also use the @property PHPDoc tag to describe which fields are accessible through your magic __get method.
Check this page for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With