Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104685 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78268 invoked from network); 13 Mar 2019 00:55:59 -0000 Received: from unknown (HELO mail-wr1-f44.google.com) (209.85.221.44) by pb1.pair.com with SMTP; 13 Mar 2019 00:55:59 -0000 Received: by mail-wr1-f44.google.com with SMTP id p8so4336383wrq.6 for ; Tue, 12 Mar 2019 14:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=pkOuzQrCDS0/sA951oSLeGCvq7tkyRqRg552OXNPXPE=; b=FasSeOFpzI06o4cOFfSVhJ4ntLbol49o71OvgvPPYyuMLplpNJ0rEiJiwWyAX85e+R P79SWe/1YQYB7C09KjM31pS50r4Q6aC1w96Fm1G7Hfb0F9+9CY/tVv+vMpXOqD3JmwDV vSbxroXbzoIYR7YTKF4M1Sn6pf5Zax+3Nnhd6N0J2D0ocZDkq4cY/EH893Cf4O9+pIVL NI6Q70P+ZONbpp/sl17Cqq8868FkEYvXDp95A69a4GnocGN21zxVkdvBvao8FyN6urNk BUHkypb6M4HhDvLDyfo1Dj0t/BlCwG27U2LxiMw+EO6632SMhAnMWSWbY9lm0SviHelQ G4/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=pkOuzQrCDS0/sA951oSLeGCvq7tkyRqRg552OXNPXPE=; b=JsemjUXtKhULi9UFRo7W5a6Uu9QvZ2AuSedc8r0Yhz4U9dlGqd8qv9srqeqyOHGwV5 sWUD18+Dft+lpjzD8oYEVZR41umj9NfmS829zOwe9AooRRp83z5uHCDGefvSLuG0Yf53 ahhC/86Cf+fx0evQeOAjt3HBtGVKG51yyC78FsCnzZoReOHKjvhM04/2NLS/bkHKz3hl 9+oSCPhe1R29snRJvU+6L9r6azP+i3ymxE60GjixDwV83bur1s7u2CiCpkeSqgqvzZXn 3JN3iunAU9wdyIwaM9Qb1SQvvCsS2qrTii9ZWTzYVnsCF8e6GxF/bk71KcU7BEJcmwuN /d8A== X-Gm-Message-State: APjAAAVSJZ+FrbZN7Z25+k5s94l3gd7rLpTRWgJs3obRZwM4iegNLkHG Tvqa0kxs1s+H+4azB5z65UE= X-Google-Smtp-Source: APXvYqw9PiHDv82uwjzIZP5FQQPgCPkaVUaw6WQ7Md9IcjC4L7FZYEdbnHvobSAPIMZIG+YD8MXiaQ== X-Received: by 2002:adf:f742:: with SMTP id z2mr3200444wrp.162.1552427157376; Tue, 12 Mar 2019 14:45:57 -0700 (PDT) Received: from ?IPv6:2001:a61:464:5501:34af:1cf3:6fd:78e5? ([2001:a61:464:5501:34af:1cf3:6fd:78e5]) by smtp.gmail.com with ESMTPSA id q135sm5959298wme.43.2019.03.12.14.45.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 14:45:56 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) In-Reply-To: Date: Tue, 12 Mar 2019 22:45:55 +0100 Cc: Rowan Collins , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <2c497732-96f8-3ef0-bc18-912220fbff4d@gmail.com> To: Stanislav Malyshev X-Mailer: Apple Mail (2.3445.102.3) Subject: Re: [PHP-DEV] RFC: Locked Classes From: gadelat@gmail.com (Gabriel O) It was already addressed how using such trivial solution is = insufficient, please read whole thread > On 12. Mar 2019, at 22:40, Stanislav Malyshev = wrote: >=20 > Hi! >=20 >> While it can be useful, the ability to set an object property which = is >> not part of the class definition can also lead to subtle bugs. = Banning >> this for all objects would be a significant and painful breaking = change, >> so I propose instead the option to mark a particular class with a new >> keyword, "locked". >=20 > Isn't it just: >=20 > trait Locked { > public function __set($name, $value) { > throw new RuntimeException("Property $name not declared!"); > } > public function __get($name) { > throw new RuntimeException("Property $name not declared!"); > } > public function __unset($name) { > throw new RuntimeException("Property $name not declared!"); > } > } >=20 > The RFC says: >=20 > While this can be achieved through strategic use of the __set, __get, > and __unset magic methods, this is long-winded, hard to optimise, and > interferes with other uses of those methods. >=20 > I don't see how it's "long-winded" - it's just three one-liners, I = don't > see how "interferes with other uses" of these methods (if you want = other > uses, just add code to the method), and as for optimization, I think = we > already have optimization for pre-declared properties, and if you = don't > use any others, it would work just as well. >=20 >=20 > --=20 > Stas Malyshev > smalyshev@gmail.com >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20