Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-16 Thread Rowan Collins
Kris Craig wrote on 16/02/2015 01:40: > create the static instance Isn't that essentially a contradiction in terms? I can't help but feel that blurring the line between static and non-static classes/methods would cause more harm than good. I've never really done any work with Redis before s

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Patrick Schaaf
Am 16.02.2015 02:40 schrieb "Kris Craig" : > > I've never really done any work with Redis before so I'm also having trouble understanding the use case for this given that everybody's talking about this solely in the context of Redis. Ahem, it's not everbody, just me :) And the issue comes up in th

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Patrick Schaaf
Am 16.02.2015 00:05 schrieb "Rowan Collins" : > > A quick thought - if you want to stick with the "magic static call" pattern, you can implement this much more simply by doing something similar to Laravel's "facades" [1]: >... > This basically implements in userspace what you propose to add to the

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Patrick Schaaf
Am 15.02.2015 23:34 schrieb "Rowan Collins" : > >> You can surely see how this is more readable / easier to write: >> >> $value = MyRedir::get($key); >> > Actually, no, I find that harder to read accurately - there is no clue there that there is actually a singleton under the hood, and that this is

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Kris Craig
> create the static instance Isn't that essentially a contradiction in terms? I can't help but feel that blurring the line between static and non-static classes/methods would cause more harm than good. I've never really done any work with Redis before so I'm also having trouble understanding the

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Christoph Becker
Patrick Schaaf wrote: > Am 15.02.2015 21:05 schrieb "Rowan Collins" : > >> // Now wherever in the code you want the default instance, just use this: >> $value = MyRedis::singleton()->get($key); > > You can surely see how this is more readable / easier to write: > > $value = MyRedir::get($key);

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Rowan Collins
On 15/02/2015 19:04, Patrick Schaaf wrote: By neccessity the implementation of this class set, must make use of both __call() and __callStatic() magic methods, with both then dispatching to a delegate phpredis instance, and in the case of __callStatic(), making up-front a singleton like "new self

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Rowan Collins
On 15/02/2015 20:20, Patrick Schaaf wrote: Am 15.02.2015 21:05 schrieb "Rowan Collins" >: > > This sounds to me like you should just be using the Singleton pattern, Of course this is singleton under the hood. > // Now wherever in the code you want the default

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Patrick Schaaf
Am 15.02.2015 21:05 schrieb "Rowan Collins" : > > This sounds to me like you should just be using the Singleton pattern, Of course this is singleton under the hood. > // Now wherever in the code you want the default instance, just use this: > $value = MyRedis::singleton()->get($key); You can sur

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Rowan Collins
On 15/02/2015 19:04, Patrick Schaaf wrote: In our codebase we have one set of classes where it was very useful to be able to call the same methods both statically and nonstatically: a set of wrapper classes over phpredis where subclasses "know" which set of redis servers to talk to (plus other co

Re: [PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread S.A.N
2015-02-15 21:04 GMT+02:00 Patrick Schaaf : > Hello Internals, > > seeing the static calling of instance methods being discussed again, I want > to ask whether the following idea would maybe have a chance? > > In our codebase we have one set of classes where it was very useful to be > able to call

[PHP-DEV] A modest proposal: __contructStatic

2015-02-15 Thread Patrick Schaaf
Hello Internals, seeing the static calling of instance methods being discussed again, I want to ask whether the following idea would maybe have a chance? In our codebase we have one set of classes where it was very useful to be able to call the same methods both statically and nonstatically: a se