Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108526 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19534 invoked from network); 13 Feb 2020 00:58:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 00:58:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC91218053C for ; Wed, 12 Feb 2020 15:12:50 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 12 Feb 2020 15:12:50 -0800 (PST) Received: by mail-lj1-f177.google.com with SMTP id v17so4362524ljg.4 for ; Wed, 12 Feb 2020 15:12:50 -0800 (PST) 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=GB/hPNr/Qfsp5PX0ghC7W7+3T7GiR/s/2TD8jrZ0hug=; b=tdzvOu7i/w1LUFhOy/5b1ebPMTIXebVZoHe9JWvEasIFYluBlt+K7z+GtTRkJyOI/M JAVeZ9MBmuGWhu3dnjhY8+J5zDGzBLsrJtaT+ksJ4XJTSABYyK4BNAnWpSUS1kUGxuxN mXXcRknFCEEJuRAca6717AgHUjrXnBSbCXgbbC/EfJgFKFu7sG5PfkZhOKR2mPlQh1as tqKOcWz4pBpw6d84QdH5/JtiCesCuo1ZJFJlLp0bhYfECZw4TDN2liimpaLK7am2qO/B 05Tup4m07zwyFpURF/yMHLdFIP5A6hMtDhoc8VFbaSqCOQbK/ievHG9WpeTYS/3YZZaz d6tg== 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=GB/hPNr/Qfsp5PX0ghC7W7+3T7GiR/s/2TD8jrZ0hug=; b=GrqCpwppp52pRgNtEaJQYu50yGIjWx4M97iPGZYe4d5S43uiJo77jbMnams0i++a66 oPIv1pKYU0xvsroY21gxMhuUnqZTGjmsYWhD4AxrKQmn93lyqqYUavaIjwRsdybEZ8ra tcw4/hGAnnCewySTqhdjtOHtsdddRAkNFuPYEIgyKqkgr7teAh8fL5+UtuUlqm2WwXOw de0Hpat8icnDMltifSSVbxypt7bFcVKUJUF7QQB1Q0ysMOmIo+b0AuD1e4pkRhUXbmF3 4bSBu6ftBlAE1K0LtD3xj4QSKSrxIZo31/E1WHb7t0tHc7tp1jKb3v/Bjs1T9lvliOST ReLg== X-Gm-Message-State: APjAAAUwk/wykeP1naDodFp/g1ZfSCGlXDE+h7+F3Eql1o0lOAzmPTcx UrseQEFIoGnv10Q/65QLUAGmuUc7u4qTmQNOSAM= X-Google-Smtp-Source: APXvYqw7UPrAfwBpJ1zswTM+j0Id8jBJx6pY+STNUaXvxfM5N+I0D0WDklE31tuqLOYiLae0MD8ErN325zYWq2ncL6c= X-Received: by 2002:a2e:a490:: with SMTP id h16mr1812705lji.115.1581549166572; Wed, 12 Feb 2020 15:12:46 -0800 (PST) MIME-Version: 1.0 References: <9829e5c9-9e32-9686-8ff2-ec7930dda709@gmail.com> <20d9da97-243a-a171-0412-7298b79e4dde@gmail.com> In-Reply-To: <20d9da97-243a-a171-0412-7298b79e4dde@gmail.com> Date: Thu, 13 Feb 2020 00:12:34 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000044b8c8059e691c39" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) --00000000000044b8c8059e691c39 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable El mi=C3=A9., 12 feb. 2020 23:01, Rowan Tommins escribi=C3=B3: > On 12/02/2020 21:47, Manuel Canga wrote: > > You is importing function and you are using different. It is the same > > case like: > > > > namespace MyProject; > > > > use Vendor/Controller; > > > > class Controller extends Controller { > > } > > > In that example, you're defining two things of the same type with the > same name, which would be an error; that's not what was happening in my > example. > > In a call like Acme\Global\I18N::translate, or a callable like > ['Acme\Global\I18N', 'translate'], the "translate" part never refers to > a function in the current namespace, or indeed any namespace, only to a > method of that particular class. > > But if you write ['Acme\Global\I18N', translate::function], there's no > way for the engine to know that you wanted a method name rather than a > function name, so it will try to resolve it in the current namespace and > import list. That will either give an error, because there is no > function called translate; or it will give you a fully-qualified name, > which isn't what you wanted, you just wanted the string 'translate' > You're right about my example. This is good example: namespace MyProject; use Vendor\Controller; class MyController extends Controller { ..... } This is an error, if Controller has actually MyProyect namespace. Then, you have two options: 1. Change import 2. Add namespace to class Controller In your example, you has the same options: > 1. Change import 2. Add namespace: ['Acme\Global\I18N',\translate::function] Explain: When you do: [ class, method ] or [ $object, method ]. Method has not namespace, you write it without namespace( like global functions ) then you do the same with ::function. This is [ class, \method::function ] or [ $object, \method::function ] Other example: $class =3D \MyClass::class; $method =3D \method::function; $obj =3D new $class(); $obj->$method(); and... $class =3D '\MyClass'; $method =3D 'method'; $obj =3D new $class(); $obj->$method(); Both are the same, but first is more semantic. --00000000000044b8c8059e691c39--