Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53178 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85772 invoked from network); 7 Jun 2011 19:37:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2011 19:37:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:41765] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/D6-50253-20E7EED4 for ; Tue, 07 Jun 2011 15:37:39 -0400 Received: by pzk37 with SMTP id 37so2881783pzk.29 for ; Tue, 07 Jun 2011 12:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Na5/exCYepigSzfamuWiDAzFHpQRzQJCIxZQguEyYAc=; b=nt6pC7+oYGdY95ipZzhhcvj+DD3Gv8v6rDvMuFF+NjZ+8BTPHindfv/OCza7mZR9cr gfCR5SmF33GOpC7wEw1CExbDSyLkUQkSzKs/PcKAJqsdMlB03WO1c/5qeYoLw7IKiVCS bXyWfa7daujOL6PrEkViubehheh662HiWK2Ag= 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=hpBYpHq2WaWE3Um550CZlkRIRR3wzKSDqD26cxcd+Ok4kS0MwvR4wVMvg6J6TG5aM4 MziEobfggcK2QQu9PSxv9l3UPvWB9b74IcE7JW3OJARxPHT98DKs/90s8J9iTKPccs7W nCwSH8vncgojvby+lYOJnQetv6ZgWWipnXHfg= MIME-Version: 1.0 Received: by 10.68.65.114 with SMTP id w18mr375239pbs.355.1307475455083; Tue, 07 Jun 2011 12:37:35 -0700 (PDT) Received: by 10.68.58.100 with HTTP; Tue, 7 Jun 2011 12:37:35 -0700 (PDT) In-Reply-To: <4DEE782E.1020605@sugarcrm.com> References: <4DED3D5B.6030307@oracle.com> <4DEE782E.1020605@sugarcrm.com> Date: Tue, 7 Jun 2011 15:37:35 -0400 Message-ID: To: Stas Malyshev Cc: "Matthew Weier O'Phinney" , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Callable type From: ircmaxell@gmail.com (Anthony Ferrara) > For me personally it makes zero sense that having just removed strict typing > we are introducing it back through back door, but if everybody likes it so > be it. It's strict typing to have a type-hint that can be matched by 4 different constructs (string function names, arrays, closures, invokable classes)? Basically anything that would succeed in call_user_func would be allowed to pass...? There's no "dynamic typing" that I'm aware of that this would prevent. Either it's callable, or it's not. No casting or silent type conversion is going to change that. So it's not making typing stricter at all. All it does is allow you to say "I want this parameter to be able to be directly called". *What* form of call you give it doesn't matter one bit. So in a sense, it's like having a String type-hint that casts if it can, but throws an error if it can't (Ex: an object without __toString). This will allow if there's a way to call it, and throw an error if not. I'm all for this addition. +1 On Tue, Jun 7, 2011 at 3:12 PM, Stas Malyshev wrote: > Hi! > >> https://wiki.php.net/rfc/callable > > It is good there's an RFC. However it seems to lack code examples. I > understand it may be obvious to the proposers how it looks like, but it'd be > nice to have the actual example there as it is done nearly everywhere else. > > The patch introduces new zval type IS_CALLABLE but zval functions weren't > updated for it - IIRC at least dtor may end up being called on IS_CALLABLE > value produced in the parser. > > Note also that this pseudo-type is called "callback" in all of our > documentation, which means we have now documentation that says: > > bool array_walk ( array &$array , callback $funcname [, mixed $userdata ] ) > > and type check that says "callable". > > Also, it is not clear what would happen if this type check is made against > method which is not accessible (e.g. private out of scope). Would it say > that the argument is invalid (which would be really confusing since it'd say > something like "callable expected, array given" which it technically correct > but doesn't explain why this array is not callable) or would allow it? If > not, then zend_is_callable error information should be used and displayed. > And the tests need to cover these cases, along with __call and __callStatic. > > > For me personally it makes zero sense that having just removed strict typing > we are introducing it back through back door, but if everybody likes it so > be it. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >