Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106565 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26766 invoked from network); 13 Aug 2019 11:34:22 -0000 Received: from unknown (HELO mail-wm1-f53.google.com) (209.85.128.53) by pb1.pair.com with SMTP; 13 Aug 2019 11:34:22 -0000 Received: by mail-wm1-f53.google.com with SMTP id p74so759311wme.4 for ; Tue, 13 Aug 2019 02:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=q0DEUTa8H5y7HHCgq+v8ji/UinV9OP76XGgGAR9gp4Y=; b=pQawBp6Ul5cYCOmCVcezqbqkHSZw07fzpGPeHFsEJ1yJjgZj+oe/5LQYjW/xgjAzXj QLGrmz5xKDgcf07CmWel90WakLUtR8GCpOkacrfR/bcqDGpl274EliRYWjBCFHKhy1CJ hIIgY4fddvwNMieUQ44oNpiLfb1TL2+1eCeLo9HTyvRjOEOYajijaR2WzGbbVE3qMe6D U6QhVxYvcIRheO6RLpczd8hdPtLZnGMLKCY68pP7KCrFM2YN9iKxOqOPC+jqwzVPhUeR mXTLebhcH3rhgIWt15p5Ff0csOzcgMdlRrvx8CdoayJoWA+clkIVrt9dbZOSmi4dbYcW HMnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=q0DEUTa8H5y7HHCgq+v8ji/UinV9OP76XGgGAR9gp4Y=; b=b8rAI2kdYJwBVlopK5WKxN8tDOcmZFFA12Cs4tSLB4XK9O1ZyMqDFZ4wRz9crGe4Jg YYhxZerr3/8VbMFqeGH9gGuGsESN/O1wE5CWfb1/pvz9Rjy3qEJWUDrCCqu/tuQYD3+d EQRBrJjCryZg5qxZZRAHXN3GFVvUR0aweJFRXa4sPLN7w2U6OzDuvHEPGYOCuQhqWZw0 aEJ+4eL9L18cm81ZKepx6++KejR4s1OEuou3GXDguLzyYLEvNjtx78EVz0plxPTr1AU1 AOWEQWZdJUKsNQ0r7LBNmFskk69AEAagvJYz/VB4HvkLT4nFrFq5W5Gi/vOHB+bQBP0v Yjyw== X-Gm-Message-State: APjAAAWa3Ui8AQwrP6jhSj7/eeGqcROxIwN3rZY5l8wrqLRQ3XITlwlq XECuCfYXcL62EcGU4dOI0Ye2sHFX X-Google-Smtp-Source: APXvYqxvbsjgip4TCrshht3dATpvjJh+wBL/NFChSV1h1QYfQ4a64+L0jUTdLZq0rclSAAUlRGGpaA== X-Received: by 2002:a7b:c247:: with SMTP id b7mr1967741wmj.13.1565686963048; Tue, 13 Aug 2019 02:02:43 -0700 (PDT) Received: from [192.168.0.16] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id c65sm1151272wma.44.2019.08.13.02.02.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Aug 2019 02:02:42 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <25d774e8-183b-d39c-4ac4-81c1b7770229@gmail.com> Date: Tue, 13 Aug 2019 10:02:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: rowan.collins@gmail.com (Rowan Collins) On 12/08/2019 09:17, Nicolas Grekas wrote: > Individual files could declare their package using this style: > > That would be enough to group a set of files together and make them share > eg some private classes, some optional PHP behaviors, etc. > > The right side "MyVendor\MyPackage" would also be a FQCN that PHP would > autoload as a regular class. The corresponding class would then be the > place where ppl would declare the engine behavior they want for their > package (strict types, etc). To enforce this, the engine could require that > the "MyPackage" class implements some interface/extend some base abstract > class. I really like this approach. It allows a package definition file to exist, without either the language or the header of each file having to define its location. Importantly, although it would trigger the autoloader if not yet defined, the package could be defined in advance, for instance as part of a preload directive. It could even be possible to define multiple packages in one file, or define them dynamically, using all the existing features of the language like require and eval. On a bikeshedding note, I've never liked the way declare syntax looks, so would prefer a new keyword, but the symmetry of replacing