Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35950 invoked from network); 19 Mar 2013 08:37:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2013 08:37:08 -0000 Authentication-Results: pb1.pair.com header.from=mrtreinis@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mrtreinis@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: mrtreinis@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-la0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:48284] helo=mail-la0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/61-28284-1B328415 for ; Tue, 19 Mar 2013 03:37:07 -0500 Received: by mail-la0-f43.google.com with SMTP id ek20so388038lab.30 for ; Tue, 19 Mar 2013 01:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=Pa62El4ykbFqlKImeNvxcfuYv1HBzkP+o4/cFi1sXsg=; b=kxIF57terC7LLqa+clLIS+dALhsldcIJbPqjCTTVi8XL2nGO8bzyF5w3nX+CCMB4VM NneVVIzmFjtKQaV8UUh79b16tjDvEMF4xtfUTyRI7ZRcB6xgyg1Z1tecBcwzuYUWAdsg 2aLWVZIcihlHMP11koPp+lSOXiY/kmRfH2dAcTNXQud+c4g1M6lp0BwRMnjxan+KQuIL fqR2LoH6AgdNRJFUr12+DFpHyBoAwQ0dhpTiEWIolg5GJKvvhYLk9VodvaElUb8XASdE 9w4R4n9O23OD/XPA4eSk4wYeD6RdjHiFsUVZCIr66bXKsYmJVgZ/P5S6trtPwAs58B0U iImg== MIME-Version: 1.0 X-Received: by 10.152.113.164 with SMTP id iz4mr1013514lab.50.1363682222589; Tue, 19 Mar 2013 01:37:02 -0700 (PDT) Received: by 10.114.14.131 with HTTP; Tue, 19 Mar 2013 01:37:02 -0700 (PDT) In-Reply-To: References: <20.05.17382.B0318415@pb1.pair.com> <4F.50.28284.AA918415@pb1.pair.com> Date: Tue, 19 Mar 2013 10:37:02 +0200 Message-ID: To: Pierre du Plessis Cc: Bruno CHALOPIN , PHP Development Content-Type: multipart/alternative; boundary=f46d0408930b76cfc204d84302d3 Subject: Re: [PHP-DEV] __invokeStatic() method From: mrtreinis@gmail.com (=?UTF-8?Q?Mat=C4=ABss_Roberts_Treinis?=) --f46d0408930b76cfc204d84302d3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Bruno, Poor or questionable design or language use is not what this discussion is about. PHP's greatest strength is its flexibility - PHP does allow to do silly and sometimes, questionable things. Trying to limit this flexibility is like trying to limit PHP, which is obviously bad thing to do. Example given by Pierre clearly shows possibility of such code, and in fact, I have seen such code myself in some applications where methods are shorthand's to specific functionality provided as the class with same name. I even approve such use and believe it can be quite handy for utility functions which does some specific task and where you do not want your function to be miles long, so you split it to handful of methods and wrap them in class. These proposed changes can potentially break a lot of peoples work without a real profit to the language or its users. By my opinion, syntax considering function and object calls should stay separated to ensure clean and convenient way to properly identify one from another. Also, there are no or never has been clear and unified standard by PHP for how to name things in PHP. If one chooses to name his functions with names similar or exactly like classes, he must be able to do so. 2013/3/19 Pierre du Plessis > > Le Tue, 19 Mar 2013 09:37:43 +0200, Pierre du Plessis a =C3=A9crit : > > > It would break existing software if you have a class and function wit= h > > > the same name. > > > Consider the following example: > > > > > > class foo { > > > } > > > > > > function foo() > > > { > > > > > > } > > > > > > Now what if you have several calls to foo() in your existing > > > application? With the new change, will those calls call the function, > or > > > invoke the __invokeStatic method if it is available? > > > > It will clearly technically lead to a problem. Now I don't see why in t= he > > world a class and a function could share the same name. Regarding > > conventions, a class name should begin with an uppercase character and = a > > function a lowercase one. I don't see any relevant use case where a cla= ss > > and a function should share the same name. > > > > > PHP doesn't care about uppercase or lowercase when it comes to function > names. > Have a look at http://3v4l.org/cePT5 for an example. > And not everybody uses conventions anyway (although they should) > > Although it is not common to have a class and function have the same name= , > it can happen. > Take the following code as an example. > > class Debug { > public static dump($var) > { > // some code to debug $var > } > } > > function debug($var) > { > return Debug::dump($var); > } > > The problem is clear if you have a __invokeStatic method in the debug > class, and you want to make a call to debug(). > --f46d0408930b76cfc204d84302d3--