Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106295 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89061 invoked from network); 25 Jul 2019 16:10:46 -0000 Received: from unknown (HELO mail-lf1-f51.google.com) (209.85.167.51) by pb1.pair.com with SMTP; 25 Jul 2019 16:10:46 -0000 Received: by mail-lf1-f51.google.com with SMTP id b29so27309531lfq.1 for ; Thu, 25 Jul 2019 06:34:25 -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; bh=cg5Nkdr21LGeU9R36rCt7tY0smhXE/0ekxMnUwlNn0A=; b=P4gASWh/zO5YXOLcy8UJvzSu14Q3KGDx0IBHNB9oXZOcYcw8yaZFr8GO8eBmqkSSBQ lTbD1e4gseqwqHK5wEzhKlF/1xnn5ncqtn1ythg2IlSN/Ok23FdyTWRxBPmB+h3A1pqX UmCEnZFh5L3QQR4xiqzj0etMFdkINtgqHWVRICWXllJicWtkNsSWR0dfffcR9zS+8wWz I/cBumPVgrK/AiaN/rQLcVQCbnrbDkJO4w/kzaMQi6hRTS23uuH/Q2FpzctwKALW1oXm GeUN4VitzbmAXIXHANYTk8r/DkafBlEjTKKsO1Mr953K+QqoubD1gHG5akt3SjoYvuQV Xbgw== 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; bh=cg5Nkdr21LGeU9R36rCt7tY0smhXE/0ekxMnUwlNn0A=; b=EnUkpL1yvPtEkfusFkV87CnAOBHxZJ/MewJ2U5po9Zp8bqJVAJwL2vyjopuIDCPRFi qmADPZ50vnq46PTrITwBdWQREZvDCNoGve4wnpoSBCN9cdRB1pf1eFxLcCnTwCcPBgL4 C47JGQeYzfmPv0jXQWti5TUHPOpWX0itqTm0HAUyu6Q+ELPKmWRuBlarWxAJ1oa2hZXM O5HU4gJ+q2vLRAzlB95gjYjbqLJwY2qkzs5SdfIryClRSXKl/9BKsWRZs6zcqspLE4Qf 0oCyccBTw58//0z8Dq43qalfpHsm8eZQEbuywNjty1GX38PinsEp3SAEC2RbwDaqLO7q tShQ== X-Gm-Message-State: APjAAAVe1McZsDJTLqL3J4xO16TjXn8CU63rSr+lK+jRBEj5usFGB8Mk rBfMls2hGI3qmFUcpbHuZ2znD5734yl2xvwoR8Qby4i06vU= X-Google-Smtp-Source: APXvYqxe/QEgJLzKt4K0MeP/0qcGwovcfsSTSLZjfhEa/JCVfvhp1a7JpTi/cBqYTuNs23a1BflqT3YKIDTIiF0gLFQ= X-Received: by 2002:ac2:44b1:: with SMTP id c17mr30578410lfm.87.1564061664366; Thu, 25 Jul 2019 06:34:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Jul 2019 15:34:07 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000e9541f058e817b4e" Subject: Re: [RFC] Namespace-scoped declares, again From: nikita.ppv@gmail.com (Nikita Popov) --000000000000e9541f058e817b4e Content-Type: text/plain; charset="UTF-8" On Mon, Dec 11, 2017 at 2:43 PM Nikita Popov wrote: > Hi internals! > > 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. > > The reason why I'm picking it up again is some feedback I received for the > explicit call-time send-by-ref proposal. The main objection seems to be > that the feature has limited usefulness if it's optional rather than > required, because you still can't be sure that something is a by-value > pass, just because no & is present. At the same time, we can't make this > required anytime soon due to the large BC impact. > > Namespace-scoped declares are perfectly suited to resolve this problem. We > can introduce a require_explicit_send_by_ref declare directive to make the > call-site annotation required, and libraries/projects can easily opt-in to > it using namespace_declare(). There would be no BC impact, while at the > same time projects could benefit from the additional clarity and > performance improvements immediately. > > Thanks, > Nikita > I plan to pick up this proposal again. I think the motivation here has become more pressing in the meantime. The strict_operators proposal is under discussion, and Rowan's "locked classes" essentially concluded with "doing this with a declare is better". I also think that this proposal will be helpful for the explicit call-site by-reference passing RFC. Based on the received feedback, I plan to change this proposal from being "namespace-scoped" to being "directory-scoped" instead. This should both resolve some of the concerns and make the proposal more flexible: Not all code sharing the same namespace is part of the same package (multiple packages may have classes in the same namespace), or not of the same type (code and tests may share a namespace) and sometimes people use incorrect namespaces out of ignorance (e.g. place their own Doctrine models under the Doctrine namespace). Making the declares apply to a directory avoids these issues. Nikita --000000000000e9541f058e817b4e--