Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79336 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5289 invoked from network); 1 Dec 2014 12:26:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2014 12:26:53 -0000 Authentication-Results: pb1.pair.com header.from=carlos@jp7.com.br; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=carlos@jp7.com.br; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain jp7.com.br does not designate 209.85.192.46 as permitted sender) X-PHP-List-Original-Sender: carlos@jp7.com.br X-Host-Fingerprint: 209.85.192.46 mail-qg0-f46.google.com Received: from [209.85.192.46] ([209.85.192.46:63723] helo=mail-qg0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/10-02899-C8E5C745 for ; Mon, 01 Dec 2014 07:26:53 -0500 Received: by mail-qg0-f46.google.com with SMTP id z107so7349336qgd.33 for ; Mon, 01 Dec 2014 04:26:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=xfnq8BQdduqQiG4NfRcZgJSeZ+oR+HqLfAW4Vyx4r9s=; b=aBfis+mbA+wp8ZIW3gY0zUJ/E7dpzaM4lmH38hqdYRGWKejjPZpg+RfUONrdPpBY8b u+TytUEq/vGaHUlibF7KiN5Bowg3oOVVNw4P2lSk+mNIA3uMdzuQJN4+viDdG8Cx1+nI QF+dYDdZzZLuWdzIYaDPN0q+Y1XzLEcXW1ZyM4FbLORk9nv/UIM3hEnIno7567SnDxnF mi2ODP7znuwBMx/DiOIJBLNMbqMIdb29CB4P8Kvi7NBDBKhO/aZdWwssgASj3zhomZp4 zrKYIxiq33YyRYb3C9OjUdCC70hFklgdfHNE6432nVOKjjjSCZZkmFnP2rXsCTXmlTYj xW3w== X-Gm-Message-State: ALoCoQlGRChg9ZxwoJx8vOAzP5VehD3H3XjN6LYIRn+GEqFl6AFuFiLpDTaQLCbGXXCQnt9s+b4y X-Received: by 10.229.215.137 with SMTP id he9mr37443878qcb.6.1417436809698; Mon, 01 Dec 2014 04:26:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.96.192.225 with HTTP; Mon, 1 Dec 2014 04:26:29 -0800 (PST) In-Reply-To: <5478FE5B.8050803@gmail.com> References: <5478FE5B.8050803@gmail.com> Date: Mon, 1 Dec 2014 10:26:29 -0200 Message-ID: To: Stanislav Malyshev Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a11348d8888b7b7050926b977 Subject: Re: [PHP-DEV] Static functions Vs Nonstatic functions From: carlos@jp7.com.br (Carlos Rodrigues) --001a11348d8888b7b7050926b977 Content-Type: text/plain; charset=UTF-8 Hi Stanislav. Thank you for replying. I agree that PHP can be different from other languages, but i think you agree that a code like this just feels wrong: class Cube { function weird() { echo Duck::foo(); } } class Duck { public function foo() { echo 'My class is: ' . get_class($this); } } $rubik = new Cube; $rubik->weird(); // Output: My class is: Cube One would never guess that $this inside a method of Duck could be an instance of Cube. It might look silly as an example. But in the real world someone could think a method is static when its not, and call it, introducing a bug on the application. I don't see any case where this behavior is useful. And even it there was one, it could be achieved using magic methods __call() and __callStatic(). Thank you all, *Carlos Rodrigues* carlos@jp7.com.br 2014-11-28 20:59 GMT-02:00 Stanislav Malyshev : > Hi! > > > It confuses programmers that came from other languages, prevent APIs from > > having meaningful names on static methods and have no other benefit than > > supporting PHP 4 code. > > I think this notion of "confuses programmers" sometimes goes too far, > and this is one of the examples. PHP prides itself about having low > barrier to entry, but that doesn't mean you can refuse to learn anything > at all about it and PHP should change to match that. > > There's nothing wrong in having static and non-static functions in the > same namespace, and many languages do the same. Some do not, so you > should just remember PHP is the one which does. > -- > Stas Malyshev > smalyshev@gmail.com > --001a11348d8888b7b7050926b977--