Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106307 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34769 invoked from network); 28 Jul 2019 09:09:34 -0000 Received: from unknown (HELO smtpbg202.qq.com) (184.105.206.29) by pb1.pair.com with SMTP; 28 Jul 2019 09:09:34 -0000 X-QQ-mid:Yeas17t1564295627t586t54283 Received: from 14D73359B2E14ADDB4DDC3857AE32898 (me@jhdxr.com [220.255.44.152]) X-QQ-SSF:00000000000000F0F61000000000000 To: "'Mark Randall'" , References: In-Reply-To: Date: Sun, 28 Jul 2019 14:33:40 +0800 Message-ID: <001401d5450e$65228f00$2f67ad00$@jhdxr.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdVEzjFlrzLCTKNvRD2cgYUnNRH48wAPKCYw X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:jhdxr.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: RE: [PHP-DEV] Re: [RFC] Namespace-scoped declares, again From: me@jhdxr.com (=?utf-8?b?Q0hVIFpoYW93ZWk=?=) The introduction in this RFC says "A common complaint is that this = directive has to be specified in every single file.". I think people = will complain import_declares if we follow your design. Regards, CHU Zhaowei > -----Original Message----- > From: Mark Randall > Sent: Sunday, July 28, 2019 6:54 AM > To: internals@lists.php.net > Subject: Re: [PHP-DEV] Re: [RFC] Namespace-scoped declares, again >=20 > On 27/07/2019 09:33, Rasmus Schultz wrote: > > On Thu, Jul 25, 2019 at 3:34 PM Nikita Popov = wrote: > >> Based on the received feedback, I plan to change this proposal from > >> being "namespace-scoped" to being "directory-scoped" instead >=20 > Personally I'm not a huge fan of using implicit hierarchical = directories for > managing defines. >=20 > It's certainly better than global state functions, but in general I = don't feel > comfortable with the idea that an arbitrary file can effect the = behaviour of the > VM for particular files that does not directly reference it. >=20 > Obviously there's lots of functions that do that, set_error_handler = etc, but I > think it is best avoided wherever possible. >=20 > I think what the situation calls for is the PHP equivalent of #include = - we need to > be able to explicitly import the definitions from another file. >=20 > =3D=3D=3D=3D=3D=3D MyProject\Models\Test\SomeClass.php = =3D=3D=3D=3D=3D=3D=3D ``` import_declares(\MyProject); >=20 > namespace MyProject\Models\Test >=20 > class SomeClass { > public function action(&$ref) { ... } } ``` >=20 > =3D=3D=3D=3D=3D=3D MyProject\declares.inc =3D=3D=3D=3D=3D=3D=3D > ``` > declare(strict_types=3D1) > declare(call_site_references=3D1) > declare(global_function_fallback=3D0) > ``` >=20 > This forms an explicit link between the file and the declarations. >=20 > Clearly the question is "how to locate that file" as we don't want to = return to the > days of having to add relative file paths to every file. >=20 > An option which immediately comes to mind would be a new autoloader = routine > that maps namespaces to PSR4 physical directories. Sounds like a job = for > composer tbh so userland workload would be limited for projects using = modern > workflows. >=20 > This would of course be dependent on if the compiler stage has the = ability to > branch off and call an autoloader the first time it encounters the > import_declares. >=20 > Just my 2 pence worth. >=20 > -- > Mark Randall >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: > http://www.php.net/unsub.php >=20