Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86773 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61685 invoked from network); 21 Jun 2015 22:04:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jun 2015 22:04:59 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:36024] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 78/B0-57034-90537855 for ; Sun, 21 Jun 2015 18:04:58 -0400 Received: by wicnd19 with SMTP id nd19so60623556wic.1 for ; Sun, 21 Jun 2015 15:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NzReSFBaN5McxeUb0YSXxBz0pDwogV9xQ4DDYkMnU48=; b=tj8khKIorBj9dADDRY3UUT7wkwQgv7B4gae5Rf27N1b5QW9VAf7w6DQT/1EmZs+9NT xAjaew06oW/swO6pp7xmEvowAJDOWqC19AUAPs002C7m9nW2kMk7ZEglCc7UBeY8c3sT dxlzJaMeRZlVTFlFbGOzThfe3bL9EuJk5ZNYVVZ2+C2ScwAiLRrwN4T+7+FUfYY4Wj4P r0PdShgmr3SWpLPiMUIwntyuSmR9Ye5MIEwufNQvcRX1feIA7tJ3+jFRCVGwKsAx/jLI 1QbvekzfYhl118uglg+EjUKmvI/Yw2Tl0xhGKuFnqjYTY7Ju7/XdwxHxB+lgrOImLjyu TJkg== MIME-Version: 1.0 X-Received: by 10.194.82.38 with SMTP id f6mr32176144wjy.16.1434924294717; Sun, 21 Jun 2015 15:04:54 -0700 (PDT) Received: by 10.27.179.96 with HTTP; Sun, 21 Jun 2015 15:04:54 -0700 (PDT) In-Reply-To: <5587334C.2080401@lerdorf.com> References: <5586E5D1.4010901@lerdorf.com> <55870947.4060304@lerdorf.com> <5587334C.2080401@lerdorf.com> Date: Mon, 22 Jun 2015 00:04:54 +0200 Message-ID: To: Rasmus Lerdorf Cc: Kalle Sommer Nielsen , PHP internals Content-Type: multipart/alternative; boundary=047d7bf0bfc2ddc84e05190e583c Subject: Re: [PHP-DEV] hasType() for internal function parameters? From: nikita.ppv@gmail.com (Nikita Popov) --047d7bf0bfc2ddc84e05190e583c Content-Type: text/plain; charset=UTF-8 On Sun, Jun 21, 2015 at 11:57 PM, Rasmus Lerdorf wrote: > On 06/21/2015 03:40 PM, Kalle Sommer Nielsen wrote: > > Hi > > > > 2015-06-21 20:58 GMT+02:00 Rasmus Lerdorf : > >> Or we bite the bullet and fix the arginfo everywhere to make it > >> consistent. It wouldn't be that hard to write a script to generate the > >> bulk of it. > > > > I think fixing arginfo sounds like the right solution, writing a > > script for it should not be so trival. > > Even the ones that have some arginfo aren't all correct. > > For example: > > > https://github.com/php/php-src/blob/master/Zend/zend_builtin_functions.c#L132 > > which currently says: > > ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 3) > ZEND_ARG_INFO(0, constant_name) > ZEND_ARG_INFO(0, value) > ZEND_ARG_INFO(0, case_insensitive) > ZEND_END_ARG_INFO() > > That says there are 3 required params when it should clearly be 2. > > But really that block should be: > > ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_define, 0, 2, _IS_BOOL, > 0, 0) > ZEND_ARG_TYPE_INFO(0, constant_name, IS_STRING, 0) > ZEND_ARG_INFO(0, value) > ZEND_ARG_TYPE_INFO(0, case_insensitive, _IS_BOOL, 0) > ZEND_END_ARG_INFO() > > It seems way too lazy to not fix these before we release 7.0. Especially > the ones that are outright wrong. So, having called us lazy, I better > dig in and do something about it. I'll fix up all of the ones in > zend_builtin_functions.c today. And move on to others after. Definitely > a tedious task that we could use some extra hands on. > Before making more extensive use of arginfo types, I think we should first do some adjustments to the way they are handled. In particular adding types means that internal fcalls will take the branch in http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_vm_def.h#3669. As this is hot code, it is likely important to avoid doing those duplicate type checks (that will also happen in zpp anyway). As such I would suggest to make arginfo for internal functions reflection-only. Return type hints are already only enforced in debug mode. Nikita --047d7bf0bfc2ddc84e05190e583c--