Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95391 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35736 invoked from network); 22 Aug 2016 20:56:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Aug 2016 20:56:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.217.181 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.217.181 mail-ua0-f181.google.com Received: from [209.85.217.181] ([209.85.217.181:34111] helo=mail-ua0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/56-33251-6E66BB75 for ; Mon, 22 Aug 2016 16:56:07 -0400 Received: by mail-ua0-f181.google.com with SMTP id k90so211500546uak.1 for ; Mon, 22 Aug 2016 13:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hIbxe/qYoVE+9jkXBbjaafSAVFo6bSqdDhyb1JTMnes=; b=VPDXXsRq71otc5GYcmXXaf8f9EoVKgUJA0QOqb/hf6dCn/B2+mo2RlzZjHsD6smR1t CntZZ3gfTwI/03Ow6JlCKULzabyyJFHa0LM0F1Tq7liFIBMi9aknO+ZmDgYPvjiV04bM ppWV7GPPPDZFJMyAj8iKfMxsNU2euGl3W80BI1KEQtaySSgIO1fAMX/u/XyT1e+gbw5u 9iz398GlUZcu1Qlhw73zrrH9hwW+qTYFo5RtiIL+r8u1Z8x9fFgIbNPAAntP1XsnR9LQ fGUNhjuU7L7Y6SB7/L+lBgSyU+DOEcT29BWsUFy2nh35lpxkgeU9xNJ/QOkqRssZ6IN7 d+YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hIbxe/qYoVE+9jkXBbjaafSAVFo6bSqdDhyb1JTMnes=; b=iSWj5b19FkVaxVtK1HJAFkcIlAatLdTOCGcPIY02cM7A3YyuhbgVZgpBzYBjuhtYsA uLrwy1J84FcaT5GKv1LxCHXdF7CJWbK5eSuXE2jbAvOmu1mZ5ClIJ78esENHGF5WSYxd RORLsz0pAQlX5srChMSxsAMzGkN5COPiQf2V0h+fvOs+aZb8WE37PS09YybuiDBPrN7u JTON+82MmoTZHtGvuZrIEIbNx25ff9HzIWfueXfj7L03GVRPfYMsOhG9Pd8q717KED1G dKP+KjqzHLqS9UG+Ak91g3kjNQsA0Ie1cEgKGEqdYZNhdQ+FW3xRjfrqogFnuFXeYu8U +Psg== X-Gm-Message-State: AEkooutWwfgHMEhsybz86F2LWlLMFFczUfCQOM0YYRpznhj+vlOonpqYA5W2Ft+du6lI7UXxst6pWrcnlR+2yA== X-Received: by 10.31.165.136 with SMTP id o130mr12695085vke.9.1471899364000; Mon, 22 Aug 2016 13:56:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.69.4 with HTTP; Mon, 22 Aug 2016 13:56:03 -0700 (PDT) X-Originating-IP: [78.145.254.31] In-Reply-To: References: <0668D584-EE51-4932-85D7-01D8BF70E409@trowski.com> <15E198DD-FF66-475D-ABBC-54ECD2B6BF62@trowski.com> Date: Mon, 22 Aug 2016 21:56:03 +0100 Message-ID: To: Nikita Popov Cc: Marco Pivetta , Levi Morrison , Aaron Piotrowski , internals , Stanislav Malyshev Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] ReflectionType::__toString() prepending \ to class names From: danack@basereality.com (Dan Ackroyd) On 22 August 2016 at 06:33, Nikita Popov wrote: > > Hi. > > Now that we have made ReflectionType::__toString() be useless and not > represent the type, this method should be deprecated in favor of using > ReflectionNamedType::__toString(), ::allowsNull() and any further extensions > that will be introduced later. > If we want to go that route, doesn't it make sense to: * Leave ReflectionType::__toString() as it pre-7.1.0beta3 - i.e. not including the ?nullable marker or the slash. * Explain that ReflectionType::__toString() is a legacy function that isn't nullable aware and that people should use the other functions to get the full type information for anything that might contain functions that have nullable parameters. * Add a ReflectionType::isNullable() function so that can be reflected properly, exactly as the user wrote them rather than an approximation. Levi Morrison wrote: > You must attempt to generate exactly what was written in user code This is exactly why I don't think it's acceptable for the type information to be including a question mark to indicate nullable. I use reflection to take a function that has this signature: function foo(Bar $sc = null) {...} which is valid PHP 5.x and 7.0 code, and then generate a decorated function like: function loggingFoo(Bar $sc = null) { echo "before \n"; foo($sc); echo "after \n"; } If the type for the parameter suddenly starts having a ?nullable in it, it means I can't run the code generator to produce code that can be used on 5.x and 7.0 - even though the code being reflected on is valid 5.x and 7.0 code. We need to be able to generate exactly what was written in the user code from Reflection, not just an equivalent form that only works on 7.1+ cheers Dan Ack