Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77751 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74147 invoked from network); 2 Oct 2014 22:03:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2014 22:03:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:34456] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/07-33841-2ABCD245 for ; Thu, 02 Oct 2014 18:03:15 -0400 Received: by mail.experimentalworks.net (Postfix, from userid 1003) id 5A9FE4200D; Fri, 3 Oct 2014 00:03:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on km31408.keymachine.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.2 X-Spam-HAM-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Received: from [192.168.2.34] (ppp-93-104-24-6.dynamic.mnet-online.de [93.104.24.6]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 586BB41E8A; Fri, 3 Oct 2014 00:03:22 +0200 (CEST) Message-ID: <1412287370.2809.8.camel@kuechenschabe> To: Dominic Grostate Cc: internals@lists.php.net Date: Fri, 03 Oct 2014 00:02:50 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Concept: Custom Type Hinting From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Thu, 2014-10-02 at 19:33 +0100, Dominic Grostate wrote: > My concept can be found here: > https://gist.github.com/orolyn/9ff0756b3cb3cdfe454b > > Advantages: > - Methods expecting strict values would no longer need to use inline type > checking for scalar types. > - Users could define reusable type checking for almost any type of value. > - Since the definitions would be user defined, there would be no chance of > conflicts with existing classes. > > Disadvantages: > - Assertions would have to be static and stateless if you are using a good > dependency injection pattern. > - Users of libraries incorporating custom type hints may become confused as > to what an argument should be if not properly documented. > - Complications with IDE intellisense (primarily with type detection). > > I left out performance issues in the disadvantages because I truthfully > don't know what they would be. > > The example I provided is simply a concept. If the theory is desirable, > then the design is completely reworkable. This is missing basic information like relation to namespaces. By the dynamic nature of PHP this also most likely means that each use of this leads to anb additional function call for each parameter. Given the fact that function calls are one of the slowest parts in the engine this is a *massive* cost. I also foresee "clever" developers doing "clever" magic inside those type cheking routines and in the end creating an undebugabble mess. johannes