Welcome Guest, Not a member yet? Register   Sign In
Config Static Variables Not Working
#18

Just to be clear: I have no problem with static properties and I use them quite frequently myself. I personally wouldn’t use them on a Config, since the shared instance is already ensuring your file is only loaded once, but that’s up to you.

What I meant was I don’t like *accessing static properties from an instance*. Notice the difference with this from my example above:

$config = config('My_config');
// intermediate code here
echo $config::$users_array[0];

This is allowed in PHP but it adds a layer of uncertainty because it isn’t apparent which class you are accessing. My example above explicitly references the class so you’re certain. Instance access adds nothing except guaranteeing hat your constructor has been run, but there are already better ways to verify the static properties have been filled (like a static accessor method to private properties).
Reply


Messages In This Thread
Config Static Variables Not Working - by myo - 08-03-2021, 06:08 AM
RE: Config Static Variables Not Working - by myo - 08-03-2021, 08:08 PM
RE: Config Static Variables Not Working - by myo - 08-03-2021, 09:56 PM
RE: Config Static Variables Not Working - by myo - 08-03-2021, 10:37 PM
RE: Config Static Variables Not Working - by myo - 08-04-2021, 02:52 AM
RE: Config Static Variables Not Working - by myo - 08-04-2021, 09:03 AM
RE: Config Static Variables Not Working - by myo - 08-05-2021, 03:57 AM
RE: Config Static Variables Not Working - by myo - 08-06-2021, 06:43 AM
RE: Config Static Variables Not Working - by MGatner - 08-07-2021, 04:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB