On Mon, Dec 11, 2017 at 4:46 PM, Sara Golemon <poll...@php.net> wrote:

> On Mon, Dec 11, 2017 at 8:43 AM, Nikita Popov <nikita....@gmail.com>
> wrote:
> > Some time ago I introduced the following proposal for namespace-scoped
> > declares:
> >
> >     https://wiki.php.net/rfc/namespace_scoped_declares
> >
> > The idea is to allow specifying declare directives for a whole library or
> > project using:
> >
> >     namespace_declare('Vendor\Lib', ['strict_types' => 1]);
> >
> > I've finally gotten around to implementing this proposal (
> > https://github.com/php/php-src/pull/2972) and would like to move forward
> > with it.
> >
> Being lazy here because I'm literally on my way out the door and don't
> have a moment to parse through the implementation, but can you clarify
> how this impact compile-time declares?
>
> <?php
>
> require('a.php");
> require('b.php"); // This file has a namespace declaration
> require('c.php");
>
> In this example, does a.php wind up getting compiled with a different
> set of declares than b.php and c.php?
>
> -Sara
>

Nope. The namespace_declare() call in this case will throw an Error,
because code using that namespace has already been loaded. The
implementation is careful to ensure that it's never possible to end up in a
situation where the used declare directives are inconsistent.

Nikita

Reply via email to