Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103297 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71970 invoked from network); 1 Oct 2018 17:20:48 -0000 Received: from unknown (HELO mail-oi1-f178.google.com) (209.85.167.178) by pb1.pair.com with SMTP; 1 Oct 2018 17:20:48 -0000 Received: by mail-oi1-f178.google.com with SMTP id j68-v6so11146822oib.7 for ; Mon, 01 Oct 2018 06:30:11 -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=MyCEv3wEh6a190/iFvx1guM+RUquga67JcImEKZt9q8=; b=KmtRUiPfmM1usYFRhuKzYM1pLr0fkmhUDQh94MUSnRrjair27SYky+FyVDD45vy4X0 thzsSW7GRyZfE3s6r4CJdXgS9PedIKqjE6vwu/Sfqx+AwsbL6lLp4wkQfja5xVQHI3ZP yVIzm3DdAAj4qIIG2gFwgwfYlKjghlIasZGAYSOJdlrviz0DUdpUCef3V6lZ9sIxLeYy VQ62Fq7eUAM0+ALl+hqW5sJYZe52Be73VypUzbyCp6dzSjUOvn9sIVNTZOwKwZjkb9p8 6oVbmBiJP9bfe4g8J0DA80IiRq1uVt/98JtjI5TEk27ECjQFaZlN/eTwhGu4Grq4bOx/ cJNA== 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=MyCEv3wEh6a190/iFvx1guM+RUquga67JcImEKZt9q8=; b=GZe42xmffvwvBsKJwAVrpcGQn1BymdNvPmuKrCk65z2AK5OICTIIRXWWm984bLS8Wl i4OU043ZzRzSJWsJ8Fd/PLArX/ui+d+HOZf+ebfhs/pxEaTZvMxK7FHSORXfSN2hv3oY 5f9qxJxWpGYv89zIj6YGDn7rwwLOVQDwPvMB8c2Z5PBWo/dP6/hknBEQoduSVJ8KxXB7 0xtiDKoo5sLa2gSIUPgs0aXOqhb34cTI6h0OCXlaKy0S/Sotkh5ptBmAY3cAxfU1ckSZ ETPIthw63+EROsf8tEusr8FJvt3itzz1BPG22X6KB1I9ozZeR10yPuXoGJm+dYlf3xqF 820w== X-Gm-Message-State: ABuFfog9rbk+gk4in/z4V98zNCG6DznnQaeem/5tMZ+s33yl95lazt6Y 0tQ6cP+O/w3+6NjiU1RPmNVvoZINm6Cx4eOyBAQ= X-Google-Smtp-Source: ACcGV60dgbUM5uIhk7MfFtRvlXHdaCg3ppVRbRFZZL9Mh3Vmf4ocNPLLSyNveeG5mq0dIcZ8a5IWBTVPnI0jwgW/Ung= X-Received: by 2002:aca:f4c2:: with SMTP id s185-v6mr5145707oih.245.1538400610267; Mon, 01 Oct 2018 06:30:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 1 Oct 2018 10:29:58 -0300 Message-ID: To: rowan.collins@gmail.com Cc: internals Content-Type: multipart/alternative; boundary="000000000000e5b75005772acd43" Subject: Re: [PHP-DEV] Class name resolution for \array::class From: marcospassos.com@gmail.com (Marcos Passos) --000000000000e5b75005772acd43 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sorry, it looks like I've replied to Marco only. About use case, we use it to specify types in standardized fashion: if (!$value instanceof Foo) { > throw InvalidArgumentException::unexpectedType($value, Foo::class); > } > if (!\is_int($value)) { > throw new InvalidArgumentException::unexpectedType($value, > \int::class); > } > > $converter->convert($value, \int::class); I also said that it might have some benefits for generic types: I don't disagree with you, but it's already supported right now, so what > I'm only proposing to make it consistent. > Looking forward, supporting name resolution for primitive may have some > benefits for generic types > > . Beside this, deprecating it now would represent a BC break, right? Em seg, 1 de out de 2018 =C3=A0s 10:15, Rowan Collins escreveu: > On Mon, 1 Oct 2018 at 13:24, Marcos Passos > wrote: > >> >> You can also see it as a language construct that expects a type at the >> left-hand side of the name resolution operator. In that sense, primitive >> types are perfectly valid. >> > > > While I can see that as an interpretation, it doesn't make a lot of sense= : > > - the keyword "class" implies that this will always return a class name; > it is the static equivalent of get_class(), which does not support > non-objects > - if instead it was resolving a "type", you might expect it to return the > same values as gettype(), which for any object is simply the string "obje= ct" > - the main purpose of the feature is to resolve namespace lookups and > aliases, but basic types are not subject to namespaces; in other words, > "int::class" can only ever return "int" > > As Marco says, if you have a use case where allowing this is helpful, > please share it, and we can discuss if this, or some new related feature > (e.g. "array::type"), would be worth supporting. > > Regards, > -- > Rowan Collins > [IMSoP] > --000000000000e5b75005772acd43--