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

[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

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

2015-02-15 Thread Patrick Schaaf
Am 15.02.2015 21:05 schrieb Rowan Collins rowan.coll...@gmail.com: 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 =

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

2015-02-15 Thread S.A.N
2015-02-15 21:04 GMT+02:00 Patrick Schaaf p...@bof.de: 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

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

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 rowan.coll...@gmail.com mailto:rowan.coll...@gmail.com: 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

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 Christoph Becker
Patrick Schaaf wrote: Am 15.02.2015 21:05 schrieb Rowan Collins rowan.coll...@gmail.com: // 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 =

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 Patrick Schaaf
Am 15.02.2015 23:34 schrieb Rowan Collins rowan.coll...@gmail.com: 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

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

2015-02-15 Thread Patrick Schaaf
Am 16.02.2015 02:40 schrieb Kris Craig kris.cr...@gmail.com: 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

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

2015-02-15 Thread Patrick Schaaf
Am 16.02.2015 00:05 schrieb Rowan Collins rowan.coll...@gmail.com: 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