Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50410 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49667 invoked from network); 22 Nov 2010 12:47:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Nov 2010 12:47:21 -0000 Authentication-Results: pb1.pair.com header.from=simast@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=simast@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.45 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: simast@gmail.com X-Host-Fingerprint: 209.85.216.45 mail-qw0-f45.google.com Received: from [209.85.216.45] ([209.85.216.45:40711] helo=mail-qw0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/81-13423-8566AEC4 for ; Mon, 22 Nov 2010 07:47:20 -0500 Received: by qwb8 with SMTP id 8so1588305qwb.18 for ; Mon, 22 Nov 2010 04:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=0/A3E2uSoTZcoFf62L+O/UTKv/wMAOQlZWKOKC1Cutg=; b=LsqjU6AeR5yXheGkHndA4tzngtP8ieFEi7SGJjrXGC8u73o43tEJY8Bc2peOEWsHXR R0X68mSBz1yxJWJ2TSx86Uwo+ltFGckYLXrG0c2N9Vgu+4czBApWpH+nQCGeOLbP0C3e FcHvpzxaER7kfSymAt0F2tuPB63EkDcs56IXc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=VbM5yCzQvLMYlb3tNHQNyWhp45cuQxfUbP1JOZj5pRM0r1mO6DMLYnSs49x189ls9H 9ce/9j7MGZFS5j/H157vxfinRASfo7ewCXTI6VTaDlAvtv2tnvvz344DTB+MWN/A9xM6 wWkCbpDL5g2RjOFvxffpI2F/uxiOAvyIjs0y8= MIME-Version: 1.0 Received: by 10.229.232.205 with SMTP id jv13mr5002825qcb.68.1290430038277; Mon, 22 Nov 2010 04:47:18 -0800 (PST) Received: by 10.229.68.89 with HTTP; Mon, 22 Nov 2010 04:47:18 -0800 (PST) In-Reply-To: <4CEA596A.7010700@php.net> References: <4CEA596A.7010700@php.net> Date: Mon, 22 Nov 2010 14:47:18 +0200 Message-ID: To: Sebastian Bergmann Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016363b8d8409fdf30495a3a8e6 Subject: Re: [PHP-DEV] Traits and static methods From: simast@gmail.com (Simas Toleikis) --0016363b8d8409fdf30495a3a8e6 Content-Type: text/plain; charset=UTF-8 Hi Sebastian, This is not really a good example as the getInstance() method alone is > not sufficient for a reusable implementation of the Singleton pattern. > Yes, it was just a pseudo-code and not a true singleton implementation. > A trait for a reusable implementation of the Singleton pattern should > look more like > ... > which of course does not work as traits are stateless and > Would it work if instance is saved inside a local static var like: public static function getInstance() { static $instance = NULL; if (is_null($instance)) { $instance = new self(); } return $instance; } /Simas --0016363b8d8409fdf30495a3a8e6--