Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82763 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42760 invoked from network); 15 Feb 2015 23:05:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2015 23:05:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.172 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.172 mail-we0-f172.google.com Received: from [74.125.82.172] ([74.125.82.172:56408] helo=mail-we0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/64-13857-12621E45 for ; Sun, 15 Feb 2015 18:05:06 -0500 Received: by mail-we0-f172.google.com with SMTP id k48so26160968wev.3 for ; Sun, 15 Feb 2015 15:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=8k0HlPRX31LwpFXMRdefgzL7mmU86br4/FdGDdi7TV0=; b=jxLgjx/uZdiq2Gn2sO4j/v1b7H8bvwuw7NZ8WJ+6fr/syeWcsu3n/5C4mj1bU1SGFV 8IxgXeJur+5FSuyilR964GqIFpf7YNmuMRBZtkhCmUq0fQfCXCqwShcX7rB2GCmoOevm Ml4Zl3oWW3/0RbsCPETHXswhpUX+nXL6GAN1NrJ/s944ZhMi5yNF7nmaZFeBv1Y2qgJs 0hmwrnX5Ej08NElkyUYceqfQhqkRegXqD9tqTA0ftp+iQ0UU7ARWXe+YeIQyM+GE2cLx oMxOe8BhDMXrO5kS2f/z2FQE+dMstZd/PtEMG5y9yNpdNPrKZVyibTn7bX33U0a5PMJl LgUA== X-Received: by 10.180.7.196 with SMTP id l4mr30897813wia.44.1424041502008; Sun, 15 Feb 2015 15:05:02 -0800 (PST) Received: from [192.168.0.2] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id ka1sm20173748wjc.2.2015.02.15.15.05.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Feb 2015 15:05:01 -0800 (PST) Message-ID: <54E1260F.2070101@gmail.com> Date: Sun, 15 Feb 2015 23:04:47 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] A modest proposal: __contructStatic From: rowan.collins@gmail.com (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" once. For a set of additional helper > methods (not present on the underlying phpredis) I additionally have a > special mapping array of real method names to internal implementation names. 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]: class MyRedis extends Redis { // extra instance methods here } class MyRedisFacade { private static $instance; public static function __callStatic($method, $params) { if ( is_null(self::$instance) ) { self::$instance = new MyRedis; } self::$instance->$method(...$params); } } This basically implements in userspace what you propose to add to the language, with the only caveat being that you must separate the concerns of adding extra functionality, and wrapping it in a static facade, into two separate classes. [1] http://laravel.com/docs/4.2/facades -- Rowan Collins [IMSoP]