Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93822 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22470 invoked from network); 5 Jun 2016 20:26:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2016 20:26:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:36153] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/02-09778-7FA84575 for ; Sun, 05 Jun 2016 16:26:32 -0400 Received: by mail-wm0-f44.google.com with SMTP id n184so65082466wmn.1 for ; Sun, 05 Jun 2016 13:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sXu84xVICK+E6IhrJeV7Bj+EA18Cw/P4v3aOVHS6wfw=; b=OJpKLBANiRRAJNDHGQay3qYIjE9GpNlJ+zhJnnHI6sFZEhJ0UNYzXtvRLtlZYY/lcN 3yoTdig2r3H/RXKkBvs9OMwJp3nzXl5ilZLEDDq4CD8kEdJSh3VlRPryK4MZPxnosjcF S3Ak2a6+djzM8NmP3V4fIG3/z52cBRcR24CLivQM2r5ioDAuZwN1tEfKCPAuS969ZQVi IFsFu4RFcyaYmiwILZCQqsu6NnyF5SfHlivKT6GCBXny/LyU5A8ASQDbzeT4KOt63qIS 9JWfFo3xolqNd4CzbAP7pHgJQC29VNlKvSjXQFhSZhCjxI8gHSbl5qQ03sC0ccvIo3oT WeZA== 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=sXu84xVICK+E6IhrJeV7Bj+EA18Cw/P4v3aOVHS6wfw=; b=jQFgqlvRi4rHsWPDOCRPnYQTNI/596blysLgbpn01FsPu+cCSVgSHr4evL7Ev+OeuH RAs2yKPZnuZO16aQdEJIOWZekQlVrxZ4zuVAb8hUYHu+yPI5WISme91631lgQLQHjFh7 0qhAh/RVi5wGjDl308pGNU7GQJ9c8aTFk2TaW6LCB/jEcjEdtKwc2y8UBz9VS2DfA+F4 wuoF8MpK3TbecgAsZi1baozGSDgK3rB45TCttklJbPGY63j92Bn971aoxWSQ80rfggGP Z5ssMS/Pookgyb4YawayVGijQLWwFsqzCTT8Qo/gLPxrWtRkvX4o3FwGGiZoi+DnyBEP 2woQ== X-Gm-Message-State: ALyK8tKaelkZxYUvnTuPuV8E14zJ2Hpbm/bZtvPhxFhv5hGEKM6x1O/I1o/vz5Yv2JWk2AUtl+CRHN/JDOV/TA== X-Received: by 10.28.153.80 with SMTP id b77mr8631656wme.71.1465158388534; Sun, 05 Jun 2016 13:26:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.163.106 with HTTP; Sun, 5 Jun 2016 13:26:08 -0700 (PDT) In-Reply-To: References: Date: Sun, 5 Jun 2016 22:26:08 +0200 Message-ID: To: PHP Internals List Cc: Dan Ackroyd Content-Type: multipart/alternative; boundary=001a114b310049d59805348dc529 Subject: Re: [PHP-DEV] [RFC DISCUSSION] typeof From: ocramius@gmail.com (Marco Pivetta) --001a114b310049d59805348dc529 Content-Type: text/plain; charset=UTF-8 Hey Richard, On 4 June 2016 at 18:41, Fleshgrinder wrote: > On 6/4/2016 6:17 PM, Marco Pivetta wrote: > > It would be beneficial to not reduce this to stringly-typed programmer > > (again), as Dan mentioned. > > > > Returning something like a ReflectionType instance (which then implements > > __toString) would be much simpler, efficient and easy to use. > > > > Marco Pivetta > > > > Hey Marco, > > not sure if I like that approach for a procedural function. If we would > want that than it would be better to implement it as a named constructor > of the actual class. > > class ReflectionType { > > public static function from(mixed $var): ReflectionType; > > } > > But anyways, it would result in changing the purpose of that class: > Good point, probably not something you'd want to happen to pre-existing code. > > The ReflectionType class reports information about a function's > > return type. > > I'd argue that we would need a completely new reflection class to handle > this use case, e.g. ReflectionVariable. However, I cannot see that this > is actually required while looking at the usage patterns of the existing > gettype() function. The goal here is to continue supporting the existing > mode of operation and its usage in userland while updating it to reflect > the current state of the type system. Additionally, pretty much nobody > uses it to determine the type of a variable but merely to include the > resulting string in debug/error messages. > > The reflection class approach would mean that even more reflection code > ends up in production code, another thing I consider questionable. > I may have misunderstood the feature at first. By thinking about other languages with typeof support, I assumed this RFC was about a machine-friendly representation of a variable. I'd be "okay" with this if it was documented as "human friendly string representation of a variable's content", or something similar. It should be made 100% crystal clear that it is not for machine-consumption though. Returning a string will cause developers to rely on it for other things (besides meaningful exception messages), and that should be discouraged behavior. I also back Sara's concern, which is that a function like this one can be implemented, tested, improved and upgraded in userland, without the need for it to exist in core. I'd rather do a `composer require some-debug-utils-orga/type-of` than relying on another core function, which (and this will happen anyway), if bugged, cannot get fixes without a complete php installation upgrade. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a114b310049d59805348dc529--