Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102886 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95936 invoked from network); 17 Jul 2018 12:08:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jul 2018 12:08:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=mitke013@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mitke013@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.48 as permitted sender) X-PHP-List-Original-Sender: mitke013@gmail.com X-Host-Fingerprint: 209.85.218.48 mail-oi0-f48.google.com Received: from [209.85.218.48] ([209.85.218.48:37444] helo=mail-oi0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/28-37178-55CDD4B5 for ; Tue, 17 Jul 2018 08:08:53 -0400 Received: by mail-oi0-f48.google.com with SMTP id k81-v6so1534642oib.4 for ; Tue, 17 Jul 2018 05:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FRINvVTHtQK2RR4PZgpfR9/GNeSBzZODRZM8Gr/HQ9Q=; b=dzEHXa0yqUHmBTKtY0ymf9ezuaNPDY60t6jYamkqIzimXZ4ViFfMZVDyPXeyKpC154 RE6sEtRr8Ck/9occV1KVnn0BUy5Cbl7iougrljMI/CkPcitkhsvK+ymv8VD/+/fc31Rc 3QrXAJrNj7jvl8zzK9M2wa3g9Ib1T+N1DXALl2fOMR6Hcaz5V7Ti4poSVEHORNncQadY PWMXxIkniJEXMIvdORGFvZ9puuHztYTPIqLm+l7MgvAQb22ONRXKlUvJMi06Hs8odjwN 74LGlbAoNaIZUqAUDeZZLrNQYpjM8pcDAv8bQulfHc0k+j/IJC/ugd6nsDElpVEkqSRc uKiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FRINvVTHtQK2RR4PZgpfR9/GNeSBzZODRZM8Gr/HQ9Q=; b=NQ8nIDUBAOYRNSjtcHpekyrf/rkLhNUV6Sqf+kCs5MB+N0w8cnRL+r2vTWhJ9TcpLe Rajjh8thtsVlEawwLLqLDF8dEEa9Lzc23HczN872M9M68j0CUJ+9CeDxEcLMXirPis8c hXFR7We/mZqRPr+MU10QuRSqbdH6WPMEeAoP8ZeIfTJYs8FxfrpWEdFRZgd+PQjo2fmN VQ54xEUjnmYIeqvkgvrUw8TG4JPJjfW46+9+YvFekGK3Hnt+WOZcANm8qGx14Dek8xCG OzVlhEPJlgG8Q0ZHILC/zjD94ywfbC4AZPZ+FPOA5s4B6BX+7G706iDf7XUgshKw6GxW zyvg== X-Gm-Message-State: AOUpUlFYGIsv7FbPYt2HFS3MHiXr4qfEKu8/2V9H5z5udtgL1YmfG85M w6+f9WPWAkNNgkGFkzaSkkDB+8mc3+Eh16wqRYGDTg== X-Google-Smtp-Source: AAOMgpelkYTpf11wV0iJqh7Pa6N0qfkDbCz1WzKkJwYseDIzKmdxn0xNB5vibUFwNCgD0ZQz0vLBi305Isye4S1SkOE= X-Received: by 2002:aca:390a:: with SMTP id g10-v6mr1461884oia.145.1531829330792; Tue, 17 Jul 2018 05:08:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Jul 2018 14:08:39 +0200 Message-ID: To: danack@basereality.com Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000001e55f2057130cf21" Subject: Re: [PHP-DEV] [RFC] Optional typehint check for parameters From: mitke013@gmail.com (Zeljko Mitic) --0000000000001e55f2057130cf21 Content-Type: text/plain; charset="UTF-8" On Tue, Jul 17, 2018 at 1:18 PM Dan Ackroyd wrote: > On 15 July 2018 at 20:39, Zeljko Mitic wrote: > > PHP is dynamic language and each typed typehinted parameter has to be > > checked every time. > > If you think your code would benefit appreciably from having parameter > types removed, I would strongly recommend looking at > https://preprocess.io/ and similar libraries. > > Preprocessing is used in Javascript to quite radically change what is > possible to code in 'Javascript' and has allowed rapid development in > how 'Javascript' can be used. For example JSX is something that would > never have been approved by the ECMA committee.....but because it was > implemented a preprocessing step it never needed to be approved before > could get wide-scale usage. > > cheers > Dan > Ack > It won't help, preprocess.io doesn't remove typehints. But this is mostly intended for other features like generics/typed arrays for which I have read that speed is a big blocker. Anyway, if anyone is interested, I did some testing on parameter check. The code: --- class Customer {} function test(Customer $customer) {} $customer = new Customer(); $start = microtime(true); for ($i=1;$i<100000000;$i++) { // 100 million test($customer); } echo microtime(true) - $start; --- Tested 3 times, average time: 3.58s When I removed typehint from test() function, average time was: 2.76s Difference is 29.7% I know it is unrealistic scenario because there is nothing else in the code, I was just curios. --0000000000001e55f2057130cf21--