Ah, you're right... stupid statics that don't behave normally... argh.
Magic methods are the bomb, and statics are handy too, but when they
don't play nice together it makes me sad :( .

Another possibility that comes to mind is making all our objects
extend a base Object that holds the config inside of itself, then
$this->conf->url() works everywhere without having to pass around the
config as we're constructing objects. I don't foresee it being
something that I'd use a lot without copying it into a local-scope
variable when I'm going to be using it a bunch.

Mac

On Mon, Nov 7, 2011 at 11:24 AM, Steve Meyers <[email protected]> wrote:
> On 11/7/11 11:16 AM, Mac Newbold wrote:
>>
>> The idea of using static class methods kind of appeals to me, so I can
>> use Conf::url() anywhere without having to pass around variables or
>> instantiate a Config class all over. Using a magic method like
>> __call() the Conf class could even be set up so that it returns the
>> value of the corresponding class variable when an unknown function is
>> called, so you wouldn't have to set up a function for every config
>> variable you wanted to be able to retrieve.
>
> I like this approach, but there are some negatives.  First, you're calling a
> dynamic function every time you need a config variable. Depending on how
> much you do this, it has the potential to slow down your code, so just be
> aware of the tradeoff.
>
> Second, and more importantly, it doesn't work: "Property overloading only
> works in object context. These magic methods will not be triggered in static
> context."
>
> I wish there was a way to declare a property to be publicly read-only.
> Public, private, and protected are not good enough in some cases.
>
> Steve
>



-- 
Mac Newbold
[email protected]
801-694-6334

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to