Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11766 invoked from network); 2 Oct 2016 18:30:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2016 18:30:25 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.46 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.46 mail-wm0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:38128] helo=mail-wm0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/B0-06241-E3251F75 for ; Sun, 02 Oct 2016 14:30:22 -0400 Received: by mail-wm0-f46.google.com with SMTP id p138so113382168wmb.1 for ; Sun, 02 Oct 2016 11:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=NZKOtaERkqBpFDsIzJlRHaXk6JH1e9hXyqhyTlUEy8E=; b=z/nz5/HzB8elWQZnmXy3mKle0MEQTFCDdSVTADpkLCe9rwvcUS6mf3rGFdvAURH5i5 dtOKueu8GAb7tbVvVsWVg7h4nOvgdEVWKLJYkliaxqWLg9PkSlRLdsxQjsvSE8/AbnwX EhPXPyFUjw5eKQ/RdEQ06gy76iEdPo6/Vax2yyQZ9ZEl776MonqrqKGD22i/PoyPgwky +8fWoQbMo1DHUoJo5ZnxPOINVBCfUum0zHOHzixSf7xx0xadfLpuKl7LDm63oSdq+Z45 gL32yyNL7iP+tJKN2VTe/bfWj7aMSKzdTbisV1aHaIiBrOGuTewZ9Qd2wopDhq97wntC xFOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=NZKOtaERkqBpFDsIzJlRHaXk6JH1e9hXyqhyTlUEy8E=; b=iWR3T9CxBgrEPUmblbJieApNi7iKUcBNH5lnI2KxEg4M1umMak0CJW/xXL3/xxMPi6 9QXCLWUxxQk5tYMFsxzTL7oo73Sc8YiOc+WmTvicLvfoN5bmmxAAI48xPsL4Mj7+7V9h OwhWCDArT0Y+HvgzqqV1FEaQZaHMLjs63BnCCTlxTOfeM4VHl+l8EBoknKO+I+Lb3EIz tfdLehreLenMnQPVc+IQvF+m/iyqCB1+WV0g/D0ar9Ndu4gOgCfWMqM6QYvPaPckI6fi wfWwed86fe7YUlW6gkruP1+7PbbljZRk5+MMltsmwJItmszaBlyIOTb8+pNaUhm8/OX+ CKFw== X-Gm-Message-State: AA6/9RlWnZHRn+80AFzjv44MJ7iMq8pLZwg5tGpGkKNBYW5YrDVdv2dinPsRauSd6Uvfkg== X-Received: by 10.194.123.228 with SMTP id md4mr15695244wjb.78.1475433018556; Sun, 02 Oct 2016 11:30:18 -0700 (PDT) Received: from [192.168.1.5] ([95.148.161.240]) by smtp.googlemail.com with ESMTPSA id bj8sm30496562wjc.49.2016.10.02.11.30.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Oct 2016 11:30:17 -0700 (PDT) To: internals@lists.php.net References: Message-ID: Date: Sun, 2 Oct 2016 19:30:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares From: rowan.collins@gmail.com (Rowan Collins) On 23/09/2016 12:41, Nikita Popov wrote: > Hi internals! > > I'd like to propose the ability of specifying declare directives like > "strict_types" at the namespace level. > > The broader context of this proposal is to provide a simple and usable > mechanism that will allow developers to opt-in to stricter language > semantics on a per-library (or more specifically, per-namespace) basis, > thus alleviating backwards compatibility and library interoperability > concerns for such changes. I'm with others on not liking the idea of adding a new set of "at a distance" settings into the language. If distributing a package of PHP code was like distributing a compiled library, then it might make more sense, but even then we could all end up learning multiple variants of the same language. It's interesting that you pick as your example preventing dynamic object properties. That's definitely a useful option, but it turns out it can already be done, on a class by class basis. I've put together a quick library here: https://github.com/IMSoP/php-strict It lets you write this: class SomeModel { use \IMSoP\Strict\Properties; public $someProperty; } To me, that seems a lot clearer than this: namespace Some\Project; class SomeModel { public $someProperty; } Where "Some\Project" happens to have had a compiler option activated that injects invisible code to make the class behave more strictly. If we did want to build such a switch into the language, declaring it inside the class in a similar way to using a trait would seem pretty sensible to me. > namespace Symfony\Whatever\Namespace; > function strlen($str) { > return \strlen($str) + 1; > } > // Repeat for a few more namespaces. > > This will end up hijacking uses of the strlen() function within the Symfony > codebase due to the way the global namespace fallback works. Well, as the recent autoloading discussion showed, that global namespace fallback is not without its problems. And it looks like 7.0 has finally removed the ability to redefine "true" and "false" as namespace constants, although I'm not sure if this was just a side-effect of the phpng work https://3v4l.org/S2AFZ Regards, -- Rowan Collins [IMSoP]