Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104634 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98003 invoked from network); 10 Mar 2019 23:59:00 -0000 Received: from unknown (HELO mail-wm1-f42.google.com) (209.85.128.42) by pb1.pair.com with SMTP; 10 Mar 2019 23:59:00 -0000 Received: by mail-wm1-f42.google.com with SMTP id x7so2430345wmj.0 for ; Sun, 10 Mar 2019 13:48:28 -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=ga5uPs5yioQvs4r5TW7Vu5iUyPAQJmOmgeBI4rqEheI=; b=o1/6PJHtbUoqqkk5Gn4Kq9tZp5QTT8+xrkaB+fL8T7vKfB3fEm8jqFsrZHf3Z/gUdB hUfEwNZ6L587Q/GjjNYCnfBKtkBwK8A780XhhgGQWSnho0hpoJxKbJfCz9EJX+Itdyux fe6JeG8REsQR22/v4mNxprMMbmB6w/F0DpumF7Kt5AEZKVjja1wQO0eD3vdBoaAO5AUl 09yI2sHHgsU7Wc4B9kNFfi/ZYHc6l12FrOAcxeNidEgwBG43jQPIz8OUjFjaRra7eGYG Vd9CdDcZF8JoxjQFNsCUNnJtaiwPkCqbcf8GALhcUvVwCxBZ5grRVnRcEe1OKs5CRnSD nt5Q== 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=ga5uPs5yioQvs4r5TW7Vu5iUyPAQJmOmgeBI4rqEheI=; b=aGrV6LlAgU3pM7ODQJiMufiRlYbpJNZTX567Sg9Z8GhmnXckIMogXqiaD1RW5Frfm+ sTh5nXB9hig4mQsU8xZ0CTXcUOA+zUmbDpw0rQVd3VkDfHAK5T69jc/1+N6uLaJSIkeT kzjMvJIuLrafG7ia80xlhcYD2iMvCI8BLC2S7CpOyI3gHxfgnfRCkS0pMGXJdUDS1Gj0 roMhbz/mX2GfWx3zinAuARd5MveGNB0L1SccFqPobBrDPu/X46AOPCcfb6O16waic7m0 qt5h5ShSmybF52IvKr93vJzDHpbGa+2k0vDZu2XGyxRWQAdbImKPoYt1fjE+YVpjxpuS 0Vkw== X-Gm-Message-State: APjAAAVCvsQxVZ3scb/veqU3sqgw5mEt/9FJg1w9uB+8oXXYiVhJ29YN yA+5FEcyXDNptr1JNiBTVLgAZ24H X-Google-Smtp-Source: APXvYqwOu+NmR8OPHMNaDjp+sKefxXxReRv0Zx06VJtguhKpD+O8bntr8b9bapIq+KYyEVSf6VOrgA== X-Received: by 2002:a1c:eb14:: with SMTP id j20mr15991204wmh.32.1552250907507; Sun, 10 Mar 2019 13:48:27 -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 h13sm6483016wrt.89.2019.03.10.13.48.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Mar 2019 13:48:26 -0700 (PDT) To: PHP Internals References: <2c497732-96f8-3ef0-bc18-912220fbff4d@gmail.com> Message-ID: <3719a9c2-40f0-db56-b49b-92eee99e68a1@gmail.com> Date: Sun, 10 Mar 2019 20:48:26 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 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: Locked Classes From: rowan.collins@gmail.com (Rowan Collins) On 10/03/2019 20:19, Dan Ackroyd wrote: > I believe those two parts of the RFC are completely possible already > in user-land with a trait similar to the one below. What would be the > compelling case for making it be a keyword, rather than the user-land > implementation that is already achievable? Hi Dan, Yes, such a trait had occurred to me before. My main motivation for proposing it as part of the language is to make it as easy as possible to opt into, and standardising the mechanics - I can see "all classes must be strict" making it into far more coding standards than "all projects must include this Trait and add it to all classes". It occurred to me that language support might also allow optimisation around it, whereas implementing __get()/__set() would likely do the opposite. Apart from that, I was partly just experimenting with how hard it would be to add; the answer, so far at least, is surprisingly easy. The alternative would be to simply deprecate dynamic property getting and setting altogether. I suspect that would affect a lot of code, though, so would be wary of actually removing it as soon as PHP 8, given that the set part doesn't even raise a notice right now. > and now this RFC (or at least 2/3 of it) could be implemented by > adding some traits by default to all classes in a package. This wasn't really relevant to my motivation - you'd still have to add it to each class under the proposed RFC - but it is an interesting idea. In general, I think such packages would be a great addition to the language, but they'd also be a big change in how things work, and take a lot of working out, so I'm not going to hold my breath. Regards, -- Rowan Collins [IMSoP]